aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-09-27 01:42:07 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-09-27 01:42:07 +0000
commitda313592441db36cf4b06be97c4bcc238ee6fa9c (patch)
tree2f8a1bcce21d4a56f6c118b8968154c0a9b79cec /lib/Lex
parent69e80c58bcfdeeadc90f205b9c1b234f8eed14ed (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164743 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r--lib/Lex/PPDirectives.cpp8
-rw-r--r--lib/Lex/PreprocessingRecord.cpp13
2 files changed, 14 insertions, 7 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp
index 70302f10ae..ccbee631ae 100644
--- a/lib/Lex/PPDirectives.cpp
+++ b/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/lib/Lex/PreprocessingRecord.cpp b/lib/Lex/PreprocessingRecord.cpp
index dfdeba3f9c..40250f6786 100644
--- a/lib/Lex/PreprocessingRecord.cpp
+++ b/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));