forked from qt-creator/qt-creator
		
	C++: Finish gcc's include_next support
This implements the actual include_next logic and thus completes
    commit b934cc1
    C++: pass #include_next down to CppPreprocessor::tryIncludeFile
    commmit 140b502
    C++: Highlight argument to gcc's #include_next extension
Based on https://gcc.gnu.org/onlinedocs/cpp/Wrapper-Headers.html
Task-number: QTCREATORBUG-10225
Change-Id: I7eef7f5ea64a114f6d092304d32b72c55c2ce134
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
			
			
This commit is contained in:
		| @@ -37,6 +37,7 @@ | ||||
| #include "cpptoolstestcase.h" | ||||
| #include "editordocumenthandle.h" | ||||
|  | ||||
| #include <coreplugin/testdatadir.h> | ||||
| #include <texteditor/texteditor.h> | ||||
|  | ||||
| #include <cplusplus/CppDocument.h> | ||||
| @@ -203,3 +204,38 @@ void CppToolsPlugin::test_cppsourceprocessor_macroUses() | ||||
|     QCOMPARE(macroUse.utf16charsEnd(), 35U); | ||||
|     QCOMPARE(macroUse.beginLine(), 2U); | ||||
| } | ||||
|  | ||||
| static bool isMacroDefinedInDocument(const QByteArray ¯oName, const Document::Ptr &document) | ||||
| { | ||||
|     foreach (const Macro ¯o, document->definedMacros()) { | ||||
|         if (macro.name() == macroName) | ||||
|             return true; | ||||
|     } | ||||
|  | ||||
|     return false; | ||||
| } | ||||
|  | ||||
| static inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); } | ||||
|  | ||||
| void CppToolsPlugin::test_cppsourceprocessor_includeNext() | ||||
| { | ||||
|     const Core::Tests::TestDataDir data( | ||||
|         _(SRCDIR "/../../../tests/auto/cplusplus/preprocessor/data/include_next-data/")); | ||||
|     const QString mainFilePath = data.file(QLatin1String("main.cpp")); | ||||
|     const QString customHeaderPath = data.directory(QLatin1String("customIncludePath")); | ||||
|     const QString systemHeaderPath = data.directory(QLatin1String("systemIncludePath")); | ||||
|  | ||||
|     CppSourceProcessor::DocumentCallback documentCallback = [](const CPlusPlus::Document::Ptr &){}; | ||||
|     CppSourceProcessor sourceProcessor(Snapshot(), documentCallback); | ||||
|     ProjectPart::HeaderPaths headerPaths = ProjectPart::HeaderPaths() | ||||
|         << ProjectPart::HeaderPath(customHeaderPath, ProjectPart::HeaderPath::IncludePath) | ||||
|         << ProjectPart::HeaderPath(systemHeaderPath, ProjectPart::HeaderPath::IncludePath); | ||||
|     sourceProcessor.setHeaderPaths(headerPaths); | ||||
|  | ||||
|     sourceProcessor.run(mainFilePath); | ||||
|     const Snapshot snapshot = sourceProcessor.snapshot(); | ||||
|     QVERIFY(!snapshot.isEmpty()); | ||||
|     const Document::Ptr mainDocument = snapshot.document(mainFilePath); | ||||
|     QVERIFY(mainDocument); | ||||
|     QVERIFY(isMacroDefinedInDocument("OK_FEATURE_X_ENABLED", mainDocument)); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user