aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-01-17 18:48:07 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-01-17 18:48:07 +0000
commit7fe90f3bfa6bd7f779ecfd4ba201a296a3a1c8cb (patch)
treed6071f63e1d34459d1cec753e9c344d73433a08a
parent4c86fdb84ff016ee708e71f563ffe2a1c1b96b26 (diff)
[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
-rw-r--r--include/clang/Frontend/ASTUnit.h1
-rw-r--r--lib/Frontend/ASTUnit.cpp2
-rw-r--r--tools/libclang/Indexing.cpp1
-rw-r--r--tools/libclang/IndexingContext.cpp4
-rw-r--r--tools/libclang/IndexingContext.h1
5 files changed, 9 insertions, 0 deletions
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<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;
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;