summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Lex
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-10-24 07:51:24 +0000
committerManuel Klimek <klimek@google.com>2013-10-24 07:51:24 +0000
commit1f76c4e8101b9beaf8f1b10a57faa80256ab2b05 (patch)
treea61f6a66dfd47cc8caf4b470e487f183d66d24d8 /clang/unittests/Lex
parente90c975dbc0d9083b51604e75bb191c01d1b8874 (diff)
downloadbcm5719-llvm-1f76c4e8101b9beaf8f1b10a57faa80256ab2b05.tar.gz
bcm5719-llvm-1f76c4e8101b9beaf8f1b10a57faa80256ab2b05.zip
Use the same SourceManager for ModuleMaps and compilations.
This allows using virtual file mappings on the original SourceManager to map in virtual module.map files. Without this patch, the ModuleMap search will find a module.map file (as the FileEntry exists in the FileManager), but will be unable to get the content from the SourceManager (as ModuleMap previously created its own SourceManager). Two problems needed to be fixed which this patch exposed: 1. Storing the inferred module map When writing out a module, the ASTWriter stores the names of the files in the main source manager; when loading the AST again, the ASTReader errs out if such a file is found missing, unless it is overridden. Previously CompilerInstance's compileModule method would store the inferred module map to a temporary file; the problem with this approach is that now that the module map is handled by the main source manager, the ASTWriter stores the name of the temporary module map as source to the compilation; later, when the module is loaded, the temporary file has already been deleted, which leads to a compilation error. This patch changes the inferred module map to instead inject a virtual file into the source manager. This both saves some disk IO, and works with how the ASTWriter/ASTReader handle overridden source files. 2. Changing test input in test/Modules/Inputs/* Now that the module map file is handled by the main source manager, the VerifyDiagnosticConsumer will not ignore diagnostics created while parsing the module map file. The module test test/Modules/renamed.m uses -I test/Modules/Inputs and triggers recursive loading of all module maps in test/Modules/Inputs, some of which had conflicting names, thus leading errors while parsing the module maps. Those diagnostics already occur on trunk, but before this patch they would not break the test, as they were ignored by the VerifyDiagnosticConsumer. This patch thus changes the module maps that have been recently introduced which broke the invariant of compatible modules maps in test/Modules/Inputs. llvm-svn: 193314
Diffstat (limited to 'clang/unittests/Lex')
-rw-r--r--clang/unittests/Lex/LexerTest.cpp2
-rw-r--r--clang/unittests/Lex/PPCallbacksTest.cpp5
-rw-r--r--clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp2
3 files changed, 5 insertions, 4 deletions
diff --git a/clang/unittests/Lex/LexerTest.cpp b/clang/unittests/Lex/LexerTest.cpp
index a8e25cb2a39..40ce928014d 100644
--- a/clang/unittests/Lex/LexerTest.cpp
+++ b/clang/unittests/Lex/LexerTest.cpp
@@ -62,7 +62,7 @@ protected:
(void) SourceMgr.createMainFileIDForMemBuffer(buf);
VoidModuleLoader ModLoader;
- HeaderSearch HeaderInfo(new HeaderSearchOptions, FileMgr, Diags, LangOpts,
+ HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
Target.getPtr());
Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, Target.getPtr(),
SourceMgr, HeaderInfo, ModLoader, /*IILookup =*/ 0,
diff --git a/clang/unittests/Lex/PPCallbacksTest.cpp b/clang/unittests/Lex/PPCallbacksTest.cpp
index fd407b52c6e..9405a84024b 100644
--- a/clang/unittests/Lex/PPCallbacksTest.cpp
+++ b/clang/unittests/Lex/PPCallbacksTest.cpp
@@ -162,7 +162,8 @@ protected:
VoidModuleLoader ModLoader;
IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts = new HeaderSearchOptions();
- HeaderSearch HeaderInfo(HSOpts, FileMgr, Diags, LangOpts, Target.getPtr());
+ HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts,
+ Target.getPtr());
AddFakeHeader(HeaderInfo, HeaderPath, SystemHeader);
IntrusiveRefCntPtr<PreprocessorOptions> PPOpts = new PreprocessorOptions();
@@ -198,7 +199,7 @@ protected:
(void)SourceMgr.createMainFileIDForMemBuffer(sourceBuf);
VoidModuleLoader ModLoader;
- HeaderSearch HeaderInfo(new HeaderSearchOptions, FileMgr, Diags,
+ HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags,
OpenCLLangOpts, Target.getPtr());
Preprocessor PP(new PreprocessorOptions(), Diags, OpenCLLangOpts,
diff --git a/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp b/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
index 082eced2d85..58857fa5a13 100644
--- a/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
+++ b/clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
@@ -90,7 +90,7 @@ TEST_F(PPConditionalDirectiveRecordTest, PPRecAPI) {
SourceMgr.createMainFileIDForMemBuffer(buf);
VoidModuleLoader ModLoader;
- HeaderSearch HeaderInfo(new HeaderSearchOptions, FileMgr, Diags, LangOpts,
+ HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts,
Target.getPtr());
Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts,Target.getPtr(),
SourceMgr, HeaderInfo, ModLoader,
OpenPOWER on IntegriCloud