]> granicus.if.org Git - clang/commitdiff
[libclang] Make sure Preprocessor is set in ASTUnit during indexing.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 17 Jan 2012 18:48:07 +0000 (18:48 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 17 Jan 2012 18:48:07 +0000 (18:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148319 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/ASTUnit.h
lib/Frontend/ASTUnit.cpp
tools/libclang/Indexing.cpp
tools/libclang/IndexingContext.cpp
tools/libclang/IndexingContext.h

index 8feab307ea581f63659ee090458345cea9f78060..4b84e6a8d6b872e21d9a7bc24deac89e1bebb6b0 100644 (file)
@@ -457,6 +457,7 @@ public:
         ASTContext &getASTContext()       { return *Ctx; }
 
   void setASTContext(ASTContext *ctx) { Ctx = ctx; }
+  void setPreprocessor(Preprocessor *pp);
 
   bool hasSema() const { return TheSema; }
   Sema &getSema() const { 
index 5272636fa9013456e405903f5eab9dcbd2c85f6b..e31bf5500ba7b55efee91aaf97401cbbea73b1d9 100644 (file)
@@ -262,6 +262,8 @@ ASTUnit::~ASTUnit() {
   }    
 }
 
+void ASTUnit::setPreprocessor(Preprocessor *pp) { PP = pp; }
+
 /// \brief Determine the set of code-completion contexts in which this 
 /// declaration should be shown.
 static unsigned getDeclShowContexts(NamedDecl *ND,
index 630c55bb335f147a869337ecc756f38544048bbf..6bffc6b97aa69bd0c469f5a3c720702ee9412a0e 100644 (file)
@@ -176,6 +176,7 @@ public:
     IndexCtx.setASTContext(CI.getASTContext());
     Preprocessor &PP = CI.getPreprocessor();
     PP.addPPCallbacks(new IndexPPCallbacks(PP, IndexCtx));
+    IndexCtx.setPreprocessor(PP);
     return new IndexingConsumer(IndexCtx);
   }
 
index befdce90459681ff16bf7f81b21669752898b541..1c58d23f54ca1459cfb3e6583642c5bbdd0c1b98 100644 (file)
@@ -208,6 +208,10 @@ void IndexingContext::setASTContext(ASTContext &ctx) {
   static_cast<ASTUnit*>(CXTU->TUData)->setASTContext(&ctx);
 }
 
+void IndexingContext::setPreprocessor(Preprocessor &PP) {
+  static_cast<ASTUnit*>(CXTU->TUData)->setPreprocessor(&PP);
+}
+
 bool IndexingContext::shouldAbort() {
   if (!CB.abortQuery)
     return false;
index 26b8ecb75d0822ec8e22b47443b51bd440ef2644..bc33005e89dde3eb9218f37daa665fb1052e5757 100644 (file)
@@ -319,6 +319,7 @@ public:
   ASTContext &getASTContext() const { return *Ctx; }
 
   void setASTContext(ASTContext &ctx);
+  void setPreprocessor(Preprocessor &PP);
 
   bool suppressRefs() const {
     return IndexOptions & CXIndexOpt_SuppressRedundantRefs;