diff options
author | Chris Lattner <sabre@nondot.org> | 2009-01-27 07:57:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-01-27 07:57:44 +0000 |
commit | b9c3f966b103f7cfe8e5e60007c4c8b38f7298eb (patch) | |
tree | d10a3e7c028ae1ae13bef1b61f7da4aff02ef207 /Driver/DependencyFile.cpp | |
parent | 52c29081281955d3db9e11d10573b2d38f709099 (diff) |
Introduce a new PresumedLoc class to represent the concept of a location
as reported to the user and as manipulated by #line. This is what __FILE__,
__INCLUDE_LEVEL__, diagnostics and other things should follow (but not
dependency generation!).
This patch also includes several cleanups along the way:
- SourceLocation now has a dump method, and several other places
that did similar things now use it.
- I cleaned up some code in AnalysisConsumer, but it should probably be
simplified further now that NamedDecl is better.
- TextDiagnosticPrinter is now simplified and cleaned up a bit.
This patch is a prerequisite for #line, but does not actually provide
any #line functionality.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/DependencyFile.cpp')
-rw-r--r-- | Driver/DependencyFile.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Driver/DependencyFile.cpp b/Driver/DependencyFile.cpp index 282164fdd6..0d4ee91f01 100644 --- a/Driver/DependencyFile.cpp +++ b/Driver/DependencyFile.cpp @@ -13,6 +13,7 @@ #include "clang.h" #include "clang/Basic/SourceManager.h" +#include "clang/Basic/FileManager.h" #include "clang/Lex/Preprocessor.h" #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/DirectoryLookup.h" @@ -167,8 +168,14 @@ void DependencyFileCallback::FileChanged(SourceLocation Loc, SrcMgr::CharacteristicKind FileType) { if (Reason != PPCallbacks::EnterFile) return; - - const char *Filename = PP->getSourceManager().getSourceName(Loc); + + // Depedency generation really does want to go all the way to the file entry + // for a source location to find out what is depended on. We do not want + // #line markers to affect dependency generation! + SourceManager &SM = PP->getSourceManager(); + + FileID FID = SM.getFileID(SM.getInstantiationLoc(Loc)); + const char *Filename = SM.getFileEntryForID(FID)->getName(); if (!FileMatchesDepCriteria(Filename, FileType)) return; |