aboutsummaryrefslogtreecommitdiff
path: root/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-07-23 04:15:27 +0000
committerChris Lattner <sabre@nondot.org>2007-07-23 04:15:27 +0000
commitf1c99acc544a4e70f308db4e7200ca04cd5a06d2 (patch)
treec48c6046cdc794ef1fb08904d53848b12782dd2e /Lex/Preprocessor.cpp
parent0f67032078de7b8944eb8dc5fea4fef6f483c385 (diff)
refactor the interface to Preprocessor::GetIncludeFilenameSpelling,
no functionality changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40414 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Lex/Preprocessor.cpp')
-rw-r--r--Lex/Preprocessor.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp
index ceab0ba1e7..e6cb218b82 100644
--- a/Lex/Preprocessor.cpp
+++ b/Lex/Preprocessor.cpp
@@ -1584,39 +1584,37 @@ void Preprocessor::HandleIdentSCCSDirective(Token &Tok) {
/// caller is expected to provide a buffer that is large enough to hold the
/// spelling of the filename, but is also expected to handle the case when
/// this method decides to use a different buffer.
-bool Preprocessor::GetIncludeFilenameSpelling(const Token &FilenameTok,
+bool Preprocessor::GetIncludeFilenameSpelling(SourceLocation Loc,
const char *&BufStart,
const char *&BufEnd) {
// Get the text form of the filename.
- unsigned Len = getSpelling(FilenameTok, BufStart);
- BufEnd = BufStart+Len;
assert(BufStart != BufEnd && "Can't have tokens with empty spellings!");
// Make sure the filename is <x> or "x".
bool isAngled;
if (BufStart[0] == '<') {
if (BufEnd[-1] != '>') {
- Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
+ Diag(Loc, diag::err_pp_expects_filename);
BufStart = 0;
return true;
}
isAngled = true;
} else if (BufStart[0] == '"') {
if (BufEnd[-1] != '"') {
- Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
+ Diag(Loc, diag::err_pp_expects_filename);
BufStart = 0;
return true;
}
isAngled = false;
} else {
- Diag(FilenameTok.getLocation(), diag::err_pp_expects_filename);
+ Diag(Loc, diag::err_pp_expects_filename);
BufStart = 0;
return true;
}
// Diagnose #include "" as invalid.
if (BufEnd-BufStart <= 2) {
- Diag(FilenameTok.getLocation(), diag::err_pp_empty_filename);
+ Diag(Loc, diag::err_pp_empty_filename);
BufStart = 0;
return "";
}
@@ -1646,8 +1644,10 @@ void Preprocessor::HandleIncludeDirective(Token &IncludeTok,
llvm::SmallVector<char, 128> FilenameBuffer;
FilenameBuffer.resize(FilenameTok.getLength());
- const char *FilenameStart = &FilenameBuffer[0], *FilenameEnd;
- bool isAngled = GetIncludeFilenameSpelling(FilenameTok,
+ const char *FilenameStart = &FilenameBuffer[0];
+ unsigned Len = getSpelling(FilenameTok, FilenameStart);
+ const char *FilenameEnd = FilenameStart+Len;
+ bool isAngled = GetIncludeFilenameSpelling(FilenameTok.getLocation(),
FilenameStart, FilenameEnd);
// If GetIncludeFilenameSpelling set the start ptr to null, there was an
// error.