diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-03-16 18:34:36 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-03-16 18:34:36 +0000 |
commit | b5142bb7af5c70fffd09f05172a1379a35a9c29a (patch) | |
tree | 2d853fec292436890550beaa0f2fd014c5f3fb83 /include | |
parent | 60b3e38d421cab497de1c62c06be6a6a5f321edf (diff) |
Add a 'RawPath' parameter to the PPCallbacks interface. This allows
clients to observe the exact path through which an #included file was
located. This is very useful when trying to record and replay inclusion
operations without it beind influenced by the aggressive caching done
inside the FileManager to avoid redundant system calls and filesystem
operations.
The work to compute and return this is only done in the presence of
callbacks, so it should have no effect on normal compilation.
Patch by Manuel Klimek.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127742 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Lex/DirectoryLookup.h | 13 | ||||
-rw-r--r-- | include/clang/Lex/HeaderMap.h | 8 | ||||
-rw-r--r-- | include/clang/Lex/HeaderSearch.h | 9 | ||||
-rw-r--r-- | include/clang/Lex/PPCallbacks.h | 18 | ||||
-rw-r--r-- | include/clang/Lex/PreprocessingRecord.h | 3 | ||||
-rw-r--r-- | include/clang/Lex/Preprocessor.h | 3 |
6 files changed, 39 insertions, 15 deletions
diff --git a/include/clang/Lex/DirectoryLookup.h b/include/clang/Lex/DirectoryLookup.h index 64687a18e2..1ee19266f3 100644 --- a/include/clang/Lex/DirectoryLookup.h +++ b/include/clang/Lex/DirectoryLookup.h @@ -18,6 +18,7 @@ namespace llvm { class StringRef; + template <typename T> class SmallVectorImpl; } namespace clang { class HeaderMap; @@ -121,11 +122,17 @@ public: /// LookupFile - Lookup the specified file in this search path, returning it /// if it exists or returning null if not. - const FileEntry *LookupFile(llvm::StringRef Filename, HeaderSearch &HS) const; + /// If RawPath is not NULL and the file is found, RawPath will be set to the + /// raw path at which the file was found in the file system. For example, + /// for a search path ".." and a filename "../file.h" this would be + /// "../../file.h". + const FileEntry *LookupFile(llvm::StringRef Filename, HeaderSearch &HS, + llvm::SmallVectorImpl<char> *RawPath) const; private: - const FileEntry *DoFrameworkLookup(llvm::StringRef Filename, - HeaderSearch &HS) const; + const FileEntry *DoFrameworkLookup( + llvm::StringRef Filename, HeaderSearch &HS, + llvm::SmallVectorImpl<char> *RawPath) const; }; diff --git a/include/clang/Lex/HeaderMap.h b/include/clang/Lex/HeaderMap.h index 8a5c83ecf4..54c7eb47c8 100644 --- a/include/clang/Lex/HeaderMap.h +++ b/include/clang/Lex/HeaderMap.h @@ -17,6 +17,7 @@ namespace llvm { class MemoryBuffer; class StringRef; + template <typename T> class SmallVectorImpl; } namespace clang { class FileEntry; @@ -47,7 +48,12 @@ public: /// LookupFile - Check to see if the specified relative filename is located in /// this HeaderMap. If so, open it and return its FileEntry. - const FileEntry *LookupFile(llvm::StringRef Filename, FileManager &FM) const; + /// If RawPath is not NULL and the file is found, RawPath will be set to the + /// raw path at which the file was found in the file system. For example, + /// for a search path ".." and a filename "../file.h" this would be + /// "../../file.h". + const FileEntry *LookupFile(llvm::StringRef Filename, FileManager &FM, + llvm::SmallVectorImpl<char> *RawPath) const; /// getFileName - Return the filename of the headermap. const char *getFileName() const; diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h index ed84ebc144..a63386bd6b 100644 --- a/include/clang/Lex/HeaderSearch.h +++ b/include/clang/Lex/HeaderSearch.h @@ -192,15 +192,18 @@ public: const FileEntry *LookupFile(llvm::StringRef Filename, bool isAngled, const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir, - const FileEntry *CurFileEnt); + const FileEntry *CurFileEnt, + llvm::SmallVectorImpl<char> *RawPath); /// LookupSubframeworkHeader - Look up a subframework for the specified /// #include file. For example, if #include'ing <HIToolbox/HIToolbox.h> from /// within ".../Carbon.framework/Headers/Carbon.h", check to see if HIToolbox /// is a subframework within Carbon.framework. If so, return the FileEntry /// for the designated file, otherwise return null. - const FileEntry *LookupSubframeworkHeader(llvm::StringRef Filename, - const FileEntry *RelativeFileEnt); + const FileEntry *LookupSubframeworkHeader( + llvm::StringRef Filename, + const FileEntry *RelativeFileEnt, + llvm::SmallVectorImpl<char> *RawPath); /// LookupFrameworkCache - Look up the specified framework name in our /// framework cache, returning the DirectoryEntry it is in if we know, diff --git a/include/clang/Lex/PPCallbacks.h b/include/clang/Lex/PPCallbacks.h index b2a80a6298..242986dae5 100644 --- a/include/clang/Lex/PPCallbacks.h +++ b/include/clang/Lex/PPCallbacks.h @@ -75,12 +75,17 @@ public: /// /// \param EndLoc The location of the last token within the inclusion /// directive. + /// + /// \param RawPath Contains the raw path at which the file was found in the + /// file system. For example, for a search path ".." and a filename + /// "../file.h" this would be "../../file.h". virtual void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, llvm::StringRef FileName, bool IsAngled, const FileEntry *File, - SourceLocation EndLoc) { + SourceLocation EndLoc, + const llvm::SmallVectorImpl<char> &RawPath) { } /// EndOfMainFile - This callback is invoked when the end of the main file is @@ -188,11 +193,12 @@ public: llvm::StringRef FileName, bool IsAngled, const FileEntry *File, - SourceLocation EndLoc) { - First->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, File, - EndLoc); - Second->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, File, - EndLoc); + SourceLocation EndLoc, + const llvm::SmallVectorImpl<char> &RawPath) { + First->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, File, + EndLoc, RawPath); + Second->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, File, + EndLoc, RawPath); } virtual void EndOfMainFile() { diff --git a/include/clang/Lex/PreprocessingRecord.h b/include/clang/Lex/PreprocessingRecord.h index afd7ae1187..f5066d4bfd 100644 --- a/include/clang/Lex/PreprocessingRecord.h +++ b/include/clang/Lex/PreprocessingRecord.h @@ -341,7 +341,8 @@ namespace clang { llvm::StringRef FileName, bool IsAngled, const FileEntry *File, - SourceLocation EndLoc); + SourceLocation EndLoc, + const llvm::SmallVectorImpl<char> &RawPath); }; } // end namespace clang diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 42af489d90..5dc13eb4ea 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -832,7 +832,8 @@ public: /// for system #include's or not (i.e. using <> instead of ""). const FileEntry *LookupFile(llvm::StringRef Filename, bool isAngled, const DirectoryLookup *FromDir, - const DirectoryLookup *&CurDir); + const DirectoryLookup *&CurDir, + llvm::SmallVectorImpl<char> *RawPath); /// GetCurLookup - The DirectoryLookup structure used to find the current /// FileEntry, if CurLexer is non-null and if applicable. This allows us to |