]> granicus.if.org Git - clang/commitdiff
Fix corner case in module-based layering warning.
authorDaniel Jasper <djasper@google.com>
Tue, 3 Dec 2013 20:30:36 +0000 (20:30 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 3 Dec 2013 20:30:36 +0000 (20:30 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196311 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPDirectives.cpp
test/Modules/Inputs/declare-use/e.h

index 224508637f04c63ca6088218315b7d8947d90244..446eac36418bdaa084e8eb1911fd884140d013b2 100644 (file)
@@ -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();
index ed8d843f9a852d174e7cb07e6a4a5661164774cf..31247f7f9c7d665deea1032a01a768bc5ea4004d 100644 (file)
@@ -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