diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-09-27 01:42:07 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-09-27 01:42:07 +0000 |
commit | 4fcd2885deb078fa46b39666a2fe8c8d3cdfaa68 (patch) | |
tree | 90a7e008fc606596eb77adfb3c05f1e52c75eb30 /clang/lib | |
parent | 8ba0fba28afcfd9797175281e0fbcb9b2e25dd05 (diff) | |
download | bcm5719-llvm-4fcd2885deb078fa46b39666a2fe8c8d3cdfaa68.tar.gz bcm5719-llvm-4fcd2885deb078fa46b39666a2fe8c8d3cdfaa68.zip |
Per discussion in http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120917/064551.html
have PPCallbacks::InclusionDirective pass the character range for the filename quotes or brackets.
rdar://11113134 & http://llvm.org/PR13880
llvm-svn: 164743
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Frontend/DependencyFile.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Frontend/DependencyGraph.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Lex/PreprocessingRecord.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Rewrite/Frontend/InclusionRewriter.cpp | 4 |
5 files changed, 20 insertions, 13 deletions
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp index 21f5daa9ee3..adc96604e7e 100644 --- a/clang/lib/Frontend/DependencyFile.cpp +++ b/clang/lib/Frontend/DependencyFile.cpp @@ -59,8 +59,8 @@ public: const Token &IncludeTok, StringRef FileName, bool IsAngled, + CharSourceRange FilenameRange, const FileEntry *File, - SourceLocation EndLoc, StringRef SearchPath, StringRef RelativePath); @@ -132,8 +132,8 @@ void DependencyFileCallback::InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, + CharSourceRange FilenameRange, const FileEntry *File, - SourceLocation EndLoc, StringRef SearchPath, StringRef RelativePath) { if (!File) { diff --git a/clang/lib/Frontend/DependencyGraph.cpp b/clang/lib/Frontend/DependencyGraph.cpp index eebaf0c8fe4..7fb4ad72506 100644 --- a/clang/lib/Frontend/DependencyGraph.cpp +++ b/clang/lib/Frontend/DependencyGraph.cpp @@ -51,8 +51,8 @@ public: const Token &IncludeTok, StringRef FileName, bool IsAngled, + CharSourceRange FilenameRange, const FileEntry *File, - SourceLocation EndLoc, StringRef SearchPath, StringRef RelativePath); @@ -72,8 +72,8 @@ void DependencyGraphCallback::InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName, bool IsAngled, + CharSourceRange FilenameRange, const FileEntry *File, - SourceLocation EndLoc, StringRef SearchPath, StringRef RelativePath) { if (!File) diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 70302f10aed..ccbee631ae2 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -1296,9 +1296,6 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, case tok::string_literal: Filename = getSpelling(FilenameTok, FilenameBuffer); End = FilenameTok.getLocation(); - // For an angled include, point the end location at the closing '>'. - if (FilenameTok.is(tok::angle_string_literal)) - End = End.getLocWithOffset(Filename.size()-1); CharEnd = End.getLocWithOffset(Filename.size()); break; @@ -1388,8 +1385,9 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, } // Notify the callback object that we've seen an inclusion directive. - Callbacks->InclusionDirective(HashLoc, IncludeTok, Filename, isAngled, File, - End, SearchPath, RelativePath); + Callbacks->InclusionDirective(HashLoc, IncludeTok, Filename, isAngled, + CharSourceRange::getCharRange(FilenameTok.getLocation(), CharEnd), + File, SearchPath, RelativePath); } if (File == 0) { diff --git a/clang/lib/Lex/PreprocessingRecord.cpp b/clang/lib/Lex/PreprocessingRecord.cpp index dfdeba3f9cd..40250f67862 100644 --- a/clang/lib/Lex/PreprocessingRecord.cpp +++ b/clang/lib/Lex/PreprocessingRecord.cpp @@ -389,8 +389,8 @@ void PreprocessingRecord::InclusionDirective( const clang::Token &IncludeTok, StringRef FileName, bool IsAngled, + CharSourceRange FilenameRange, const FileEntry *File, - clang::SourceLocation EndLoc, StringRef SearchPath, StringRef RelativePath) { InclusionDirective::InclusionKind Kind = InclusionDirective::Include; @@ -415,7 +415,16 @@ void PreprocessingRecord::InclusionDirective( default: llvm_unreachable("Unknown include directive kind"); } - + + SourceLocation EndLoc; + if (!IsAngled) { + EndLoc = FilenameRange.getBegin(); + } else { + EndLoc = FilenameRange.getEnd(); + if (FilenameRange.isCharRange()) + EndLoc = EndLoc.getLocWithOffset(-1); // the InclusionDirective expects + // a token range. + } clang::InclusionDirective *ID = new (*this) clang::InclusionDirective(*this, Kind, FileName, !IsAngled, File, SourceRange(HashLoc, EndLoc)); diff --git a/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp b/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp index 1929d721236..9c3c43bb514 100644 --- a/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp +++ b/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp @@ -57,8 +57,8 @@ private: const Token &IncludeTok, StringRef FileName, bool IsAngled, + CharSourceRange FilenameRange, const FileEntry *File, - SourceLocation EndLoc, StringRef SearchPath, StringRef RelativePath); void WriteLineInfo(const char *Filename, int Line, @@ -152,8 +152,8 @@ void InclusionRewriter::InclusionDirective(SourceLocation HashLoc, const Token &/*IncludeTok*/, StringRef /*FileName*/, bool /*IsAngled*/, + CharSourceRange /*FilenameRange*/, const FileEntry * /*File*/, - SourceLocation /*EndLoc*/, StringRef /*SearchPath*/, StringRef /*RelativePath*/) { assert(LastInsertedFileChange == FileChanges.end() && "Another inclusion " |