summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-12-03 20:30:36 +0000
committerDaniel Jasper <djasper@google.com>2013-12-03 20:30:36 +0000
commit88d8695ab40326d9fb168ba19ad084542b5dc428 (patch)
tree0222202ee246681a868de98db94ccfed87daa79d
parent748fe483a0bdfbc6a584ef55d6281aaa5440bae1 (diff)
downloadbcm5719-llvm-88d8695ab40326d9fb168ba19ad084542b5dc428.tar.gz
bcm5719-llvm-88d8695ab40326d9fb168ba19ad084542b5dc428.zip
Fix corner case in module-based layering warning.
Before, there SourceManager would not return a FileEntry for a SourceLocation of a macro expansion (if the header name itself is defined in a macro). We'd then fallback to assume that the module currently being built is the including module. However, in this case we are actually interested in the spelling location of the filename loc in order to derive the including module. llvm-svn: 196311
-rw-r--r--clang/lib/Lex/PPDirectives.cpp3
-rw-r--r--clang/test/Modules/Inputs/declare-use/e.h3
2 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 224508637f0..446eac36418 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -540,7 +540,8 @@ Module *Preprocessor::getModuleForLocation(SourceLocation FilenameLoc) {
return HeaderInfo.getModuleMap().SourceModule; // Compiling a source.
}
// Try to determine the module of the include directive.
- FileID IDOfIncl = SourceMgr.getFileID(FilenameLoc);
+ // FIXME: Look into directly passing the FileEntry from LookupFile instead.
+ FileID IDOfIncl = SourceMgr.getFileID(SourceMgr.getSpellingLoc(FilenameLoc));
if (const FileEntry *EntryOfIncl = SourceMgr.getFileEntryForID(IDOfIncl)) {
// The include comes from a file.
return ModMap.findModuleForHeader(EntryOfIncl).getModule();
diff --git a/clang/test/Modules/Inputs/declare-use/e.h b/clang/test/Modules/Inputs/declare-use/e.h
index ed8d843f9a8..31247f7f9c7 100644
--- a/clang/test/Modules/Inputs/declare-use/e.h
+++ b/clang/test/Modules/Inputs/declare-use/e.h
@@ -1,6 +1,7 @@
#ifndef E_H
#define E_H
-#include "a.h"
+#define HEADER "a.h"
+#include HEADER
#include "b.h"
const int e = a*b;
#endif
OpenPOWER on IntegriCloud