summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-05-10 01:28:51 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-05-10 01:28:51 +0000
commit1c7455f42ff8f51e09477fbfa763f56fd3a85a65 (patch)
treed2f61ce243668f6052579b56aa67bef678d5a428 /clang
parentea2d5f818b0573255740a80b42605999b28eefea (diff)
downloadbcm5719-llvm-1c7455f42ff8f51e09477fbfa763f56fd3a85a65.tar.gz
bcm5719-llvm-1c7455f42ff8f51e09477fbfa763f56fd3a85a65.zip
[libclang] When parsing with CXTranslationUnit_ForSerialization, make sure to install the ASTWriter that we create as an ASTMutationListener.
Fixes rdar://13833268 llvm-svn: 181575
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Frontend/ASTUnit.h1
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp10
-rw-r--r--clang/test/Index/pch-with-module.m23
3 files changed, 34 insertions, 0 deletions
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index 02c57d7472a..9bd0ef31e09 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -471,6 +471,7 @@ public:
return OriginalSourceFile;
}
+ ASTMutationListener *getASTMutationListener();
ASTDeserializationListener *getDeserializationListener();
/// \brief Add a temporary file that the ASTUnit depends on.
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index f05d7225465..7850dc697be 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -638,6 +638,12 @@ void StoredDiagnosticConsumer::HandleDiagnostic(DiagnosticsEngine::Level Level,
StoredDiags.push_back(StoredDiagnostic(Level, Info));
}
+ASTMutationListener *ASTUnit::getASTMutationListener() {
+ if (WriterData)
+ return &WriterData->Writer;
+ return 0;
+}
+
ASTDeserializationListener *ASTUnit::getDeserializationListener() {
if (WriterData)
return &WriterData->Writer;
@@ -929,6 +935,10 @@ public:
handleTopLevelDecl(*it);
}
+ virtual ASTMutationListener *GetASTMutationListener() {
+ return Unit.getASTMutationListener();
+ }
+
virtual ASTDeserializationListener *GetASTDeserializationListener() {
return Unit.getDeserializationListener();
}
diff --git a/clang/test/Index/pch-with-module.m b/clang/test/Index/pch-with-module.m
new file mode 100644
index 00000000000..e839c811dab
--- /dev/null
+++ b/clang/test/Index/pch-with-module.m
@@ -0,0 +1,23 @@
+// RUN: rm -rf %t.cache
+// RUN: c-index-test -write-pch %t.h.pch %s -target x86_64-apple-macosx10.7 -fobjc-arc -fmodules-cache-path=%t.cache -fmodules -F %S/../Modules/Inputs -Xclang -fdisable-module-hash
+// RUN: %clang -fsyntax-only %s -target x86_64-apple-macosx10.7 -include %t.h -fobjc-arc -fmodules-cache-path=%t.cache -fmodules -F %S/../Modules/Inputs \
+// RUN: -Xclang -fdisable-module-hash -Xclang -detailed-preprocessing-record -Xclang -verify
+
+// expected-no-diagnostics
+
+#ifndef PCH_HEADER
+#define PCH_HEADER
+
+#include <Module/Module.h>
+
+@interface Module(PCHCat)
+-(id)PCH_meth;
+@end
+
+#else
+
+void foo(Module *m) {
+ [m PCH_meth];
+}
+
+#endif
OpenPOWER on IntegriCloud