1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #pragma once 27 28 #include "PreprocessorClient.h" 29 #include "CppDocument.h" 30 #include "pp.h" 31 32 #include <cplusplus/Control.h> 33 34 #include <QSet> 35 #include <QString> 36 37 namespace CPlusPlus { 38 39 class CPLUSPLUS_EXPORT FastPreprocessor: public Client 40 { 41 Environment _env; 42 Snapshot _snapshot; 43 Preprocessor _preproc; 44 QSet<QString> _merged; 45 Document::Ptr _currentDoc; 46 bool _addIncludesToCurrentDoc; 47 48 void mergeEnvironment(const QString &fileName); 49 50 public: 51 FastPreprocessor(const Snapshot &snapshot); 52 53 QByteArray run(Document::Ptr newDoc, 54 const QByteArray &source, 55 bool mergeDefinedMacrosOfDocument = false); 56 57 // CPlusPlus::Client 58 virtual void sourceNeeded(int line, const QString &fileName, IncludeType mode, 59 const QStringList &initialIncludes = QStringList()); 60 61 virtual void macroAdded(const Macro &); 62 63 virtual void passedMacroDefinitionCheck(int, int, int, const Macro &); 64 virtual void failedMacroDefinitionCheck(int, int, const ByteArrayRef &); 65 66 virtual void notifyMacroReference(int, int, int, const Macro &); 67 68 virtual void startExpandingMacro(int, 69 int, 70 int, 71 const Macro &, 72 const QVector<MacroArgumentReference> &); stopExpandingMacro(int,const Macro &)73 virtual void stopExpandingMacro(int, const Macro &) {} 74 virtual void markAsIncludeGuard(const QByteArray ¯oName); 75 startSkippingBlocks(int)76 virtual void startSkippingBlocks(int) {} stopSkippingBlocks(int)77 virtual void stopSkippingBlocks(int) {} 78 }; 79 80 } // namespace CPlusPlus 81