summaryrefslogtreecommitdiffstats
path: root/clang/tools/libclang/Indexing.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-10-02 16:10:41 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-10-02 16:10:41 +0000
commitb36ee5c59284a6f0b85a42c084f2019c431bb340 (patch)
tree49eb5fd159d4966d2320a096ca101cfa4c18b95e /clang/tools/libclang/Indexing.cpp
parent472eda06b00f4963dcdeb3e4417d2f2176e85c21 (diff)
downloadbcm5719-llvm-b36ee5c59284a6f0b85a42c084f2019c431bb340.tar.gz
bcm5719-llvm-b36ee5c59284a6f0b85a42c084f2019c431bb340.zip
[libclang] Even though we disable the preprocessing record during indexing,
make sure that it gets enabled for when a module needs to be created. llvm-svn: 165021
Diffstat (limited to 'clang/tools/libclang/Indexing.cpp')
-rw-r--r--clang/tools/libclang/Indexing.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp
index efae7eecd83..963e0026438 100644
--- a/clang/tools/libclang/Indexing.cpp
+++ b/clang/tools/libclang/Indexing.cpp
@@ -192,10 +192,20 @@ public:
unsigned indexOptions,
CXTranslationUnit cxTU)
: IndexCtx(clientData, indexCallbacks, indexOptions, cxTU),
- CXTU(cxTU) { }
+ CXTU(cxTU), EnablePPDetailedRecordForModules(false) { }
+
+ bool EnablePPDetailedRecordForModules;
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
+ // We usually disable the preprocessing record for indexing even if the
+ // original preprocessing options had it enabled. Now that the indexing
+ // Preprocessor has been created (without a preprocessing record), re-enable
+ // the option in case modules are enabled, so that the detailed record
+ // option can be propagated when the module file is generated.
+ if (CI.getLangOpts().Modules && EnablePPDetailedRecordForModules)
+ CI.getPreprocessorOpts().DetailedRecord = true;
+
IndexCtx.setASTContext(CI.getASTContext());
Preprocessor &PP = CI.getPreprocessor();
PP.addPPCallbacks(new IndexPPCallbacks(PP, IndexCtx));
@@ -353,9 +363,6 @@ static void clang_indexSourceFile_Impl(void *UserData) {
// precompiled headers are involved), we disable it.
CInvok->getLangOpts()->SpellChecking = false;
- if (!requestedToGetTU)
- CInvok->getPreprocessorOpts().DetailedRecord = false;
-
if (index_options & CXIndexOpt_SuppressWarnings)
CInvok->getDiagnosticOpts().IgnoreWarnings = true;
@@ -381,7 +388,6 @@ static void clang_indexSourceFile_Impl(void *UserData) {
bool PrecompilePreamble = false;
bool CacheCodeCompletionResults = false;
PreprocessorOptions &PPOpts = CInvok->getPreprocessorOpts();
- PPOpts.DetailedRecord = false;
PPOpts.AllowPCHWithCompilerErrors = true;
if (requestedToGetTU) {
@@ -395,6 +401,13 @@ static void clang_indexSourceFile_Impl(void *UserData) {
}
}
+ IndexAction->EnablePPDetailedRecordForModules
+ = PPOpts.DetailedRecord ||
+ (TU_options & CXTranslationUnit_DetailedPreprocessingRecord);
+
+ if (!requestedToGetTU)
+ PPOpts.DetailedRecord = false;
+
DiagnosticErrorTrap DiagTrap(*Diags);
bool Success = ASTUnit::LoadFromCompilerInvocationAction(CInvok.getPtr(), Diags,
IndexAction.get(),
OpenPOWER on IntegriCloud