r196311 - Fix corner case in module-based layering warning.
Daniel Jasper
djasper at google.com
Tue Dec 3 12:30:36 PST 2013
Author: djasper
Date: Tue Dec 3 14:30:36 2013
New Revision: 196311
URL: http://llvm.org/viewvc/llvm-project?rev=196311&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/test/Modules/Inputs/declare-use/e.h
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=196311&r1=196310&r2=196311&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Dec 3 14:30:36 2013
@@ -540,7 +540,8 @@ Module *Preprocessor::getModuleForLocati
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();
Modified: cfe/trunk/test/Modules/Inputs/declare-use/e.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/declare-use/e.h?rev=196311&r1=196310&r2=196311&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/declare-use/e.h (original)
+++ cfe/trunk/test/Modules/Inputs/declare-use/e.h Tue Dec 3 14:30:36 2013
@@ -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
More information about the cfe-commits
mailing list