diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2017-06-09 01:20:48 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2017-06-09 01:20:48 +0000 |
commit | 735e92c29a1413761c6db5e1ae8e7ad48ae17d67 (patch) | |
tree | bcf8f6f8bbafe724dee521d1bd8943fc04e363ab /clang/lib/Lex/PPDirectives.cpp | |
parent | fdf499bf2d589bee2a6a3da49a74840c4c511c59 (diff) | |
download | bcm5719-llvm-735e92c29a1413761c6db5e1ae8e7ad48ae17d67.tar.gz bcm5719-llvm-735e92c29a1413761c6db5e1ae8e7ad48ae17d67.zip |
[libclang] Introduce a new parsing option 'CXTranslationUnit_SingleFileParse' that puts preprocessor in a mode for parsing a single file only.
This is useful for parsing a single file, as a fast/inaccurate 'mode' that can still provide declarations from the file, like the classes and their methods.
llvm-svn: 305044
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index b2c3c2e7076..89c2ebd00a6 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -30,6 +30,7 @@ #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Pragma.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Lex/PreprocessorOptions.h" #include "clang/Lex/PTHLexer.h" #include "clang/Lex/Token.h" #include "llvm/ADT/ArrayRef.h" @@ -1845,10 +1846,13 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, // we've imported or already built. bool ShouldEnter = true; + if (PPOpts->SingleFileParseMode) + ShouldEnter = false; + // Determine whether we should try to import the module for this #include, if // there is one. Don't do so if precompiled module support is disabled or we // are processing this module textually (because we're building the module). - if (File && SuggestedModule && getLangOpts().Modules && + if (ShouldEnter && File && SuggestedModule && getLangOpts().Modules && SuggestedModule.getModule()->getTopLevelModuleName() != getLangOpts().CurrentModule) { // If this include corresponds to a module but that module is |