From: Argyrios Kyrtzidis Date: Tue, 17 Jan 2012 18:48:07 +0000 (+0000) Subject: [libclang] Make sure Preprocessor is set in ASTUnit during indexing. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7fe90f3bfa6bd7f779ecfd4ba201a296a3a1c8cb;p=clang [libclang] Make sure Preprocessor is set in ASTUnit during indexing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148319 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index 8feab307ea..4b84e6a8d6 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -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 { diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index 5272636fa9..e31bf5500b 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -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, diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp index 630c55bb33..6bffc6b97a 100644 --- a/tools/libclang/Indexing.cpp +++ b/tools/libclang/Indexing.cpp @@ -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); } diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp index befdce9045..1c58d23f54 100644 --- a/tools/libclang/IndexingContext.cpp +++ b/tools/libclang/IndexingContext.cpp @@ -208,6 +208,10 @@ void IndexingContext::setASTContext(ASTContext &ctx) { static_cast(CXTU->TUData)->setASTContext(&ctx); } +void IndexingContext::setPreprocessor(Preprocessor &PP) { + static_cast(CXTU->TUData)->setPreprocessor(&PP); +} + bool IndexingContext::shouldAbort() { if (!CB.abortQuery) return false; diff --git a/tools/libclang/IndexingContext.h b/tools/libclang/IndexingContext.h index 26b8ecb75d..bc33005e89 100644 --- a/tools/libclang/IndexingContext.h +++ b/tools/libclang/IndexingContext.h @@ -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;