r289361 - [CrashReproducer] Setup a module collector callback for HeaderInclude
Bruno Cardoso Lopes via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 10 20:27:31 PST 2016
Author: bruno
Date: Sat Dec 10 22:27:31 2016
New Revision: 289361
URL: http://llvm.org/viewvc/llvm-project?rev=289361&view=rev
Log:
[CrashReproducer] Setup a module collector callback for HeaderInclude
Collect missing include that cannot be fetched otherwise (e.g. when
using headermaps).
rdar://problem/27913709
Modified:
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
cfe/trunk/test/Modules/crash-vfs-headermaps.m
Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=289361&r1=289360&r2=289361&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Sat Dec 10 22:27:31 2016
@@ -38,6 +38,24 @@ public:
}
};
+struct ModuleDependencyPPCallbacks : public PPCallbacks {
+ ModuleDependencyCollector &Collector;
+ SourceManager &SM;
+ ModuleDependencyPPCallbacks(ModuleDependencyCollector &Collector,
+ SourceManager &SM)
+ : Collector(Collector), SM(SM) {}
+
+ void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
+ StringRef FileName, bool IsAngled,
+ CharSourceRange FilenameRange, const FileEntry *File,
+ StringRef SearchPath, StringRef RelativePath,
+ const Module *Imported) override {
+ if (!File)
+ return;
+ Collector.addFile(File->getName());
+ }
+};
+
struct ModuleDependencyMMCallbacks : public ModuleMapCallbacks {
ModuleDependencyCollector &Collector;
ModuleDependencyMMCallbacks(ModuleDependencyCollector &Collector)
@@ -102,6 +120,8 @@ void ModuleDependencyCollector::attachTo
}
void ModuleDependencyCollector::attachToPreprocessor(Preprocessor &PP) {
+ PP.addPPCallbacks(llvm::make_unique<ModuleDependencyPPCallbacks>(
+ *this, PP.getSourceManager()));
PP.getHeaderSearchInfo().getModuleMap().addModuleMapCallbacks(
llvm::make_unique<ModuleDependencyMMCallbacks>(*this));
}
Modified: cfe/trunk/test/Modules/crash-vfs-headermaps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-headermaps.m?rev=289361&r1=289360&r2=289361&view=diff
==============================================================================
--- cfe/trunk/test/Modules/crash-vfs-headermaps.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-headermaps.m Sat Dec 10 22:27:31 2016
@@ -40,6 +40,13 @@
// CHECKYAML-NEXT: 'overlay-relative': 'true',
// CHECKYAML-NEXT: 'ignore-non-existent-contents': 'false'
// CHECKYAML: 'type': 'directory'
+// CHECKYAML: 'name': "/[[PATH:.*]]/Foo.framework/Headers",
+// CHECKYAML-NEXT: 'contents': [
+// CHECKYAML-NEXT: {
+// CHECKYAML-NEXT: 'type': 'file',
+// CHECKYAML-NEXT: 'name': "Foo.h",
+// CHECKYAML-NEXT: 'external-contents': "/[[PATH]]/Foo.framework/Headers/Foo.h"
+// CHECKYAML: 'type': 'directory'
// CHECKYAML: 'name': "/[[PATH:.*]]/i",
// CHECKYAML-NEXT: 'contents': [
// CHECKYAML-NEXT: {
More information about the cfe-commits
mailing list