diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-07 21:54:45 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-07 21:54:45 +0000 |
commit | 61c58f7f43ab6d9042fc432c39df2ccd1853d744 (patch) | |
tree | 22151e08a3e9c7dd76a47d9363eef622944f95f7 /clang/lib/Basic/SourceManager.cpp | |
parent | 53b050aec61d69cd434701fd8e51bdd63db2dff6 (diff) | |
download | llvm-61c58f7f43ab6d9042fc432c39df2ccd1853d744.zip llvm-61c58f7f43ab6d9042fc432c39df2ccd1853d744.tar.gz llvm-61c58f7f43ab6d9042fc432c39df2ccd1853d744.tar.bz2 |
Move SourceManager::isAt[Start/End]OfMacroInstantiation functions to the Lexer, since they depend on it now.
llvm-svn: 134644
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 137da0d..cd098b2 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -11,7 +11,6 @@ // //===----------------------------------------------------------------------===// -#include "clang/Lex/Lexer.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/SourceManagerInternals.h" #include "clang/Basic/Diagnostic.h" @@ -1215,60 +1214,6 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc) const { return PresumedLoc(Filename, LineNo, ColNo, IncludeLoc); } -/// \brief Returns true if the given MacroID location points at the first -/// token of the macro instantiation. -bool SourceManager::isAtStartOfMacroInstantiation(SourceLocation loc, - const LangOptions &LangOpts) const { - assert(loc.isValid() && loc.isMacroID() && "Expected a valid macro loc"); - - std::pair<FileID, unsigned> infoLoc = getDecomposedLoc(loc); - // FIXME: If the token comes from the macro token paste operator ('##') - // this function will always return false; - if (infoLoc.second > 0) - return false; // Does not point at the start of token. - - SourceLocation instLoc = - getSLocEntry(infoLoc.first).getInstantiation().getInstantiationLocStart(); - if (instLoc.isFileID()) - return true; // No other macro instantiations, this is the first. - - return isAtStartOfMacroInstantiation(instLoc, LangOpts); -} - -/// \brief Returns true if the given MacroID location points at the last -/// token of the macro instantiation. -bool SourceManager::isAtEndOfMacroInstantiation(SourceLocation loc, - const LangOptions &LangOpts) const { - assert(loc.isValid() && loc.isMacroID() && "Expected a valid macro loc"); - - SourceLocation spellLoc = getSpellingLoc(loc); - unsigned tokLen = Lexer::MeasureTokenLength(spellLoc, *this, LangOpts); - if (tokLen == 0) - return false; - - std::pair<FileID, unsigned> infoLoc = getDecomposedLoc(loc); - unsigned FID = infoLoc.first.ID; - - unsigned NextOffset; - if (FID+1 == sloc_entry_size()) - NextOffset = getNextOffset(); - else - NextOffset = getSLocEntry(FID+1).getOffset(); - - // FIXME: If the token comes from the macro token paste operator ('##') - // or the stringify operator ('#') this function will always return false; - assert(loc.getOffset() + tokLen < NextOffset); - if (loc.getOffset() + tokLen < NextOffset-1) - return false; // Does not point to the last token. - - SourceLocation instLoc = - getSLocEntry(infoLoc.first).getInstantiation().getInstantiationLocEnd(); - if (instLoc.isFileID()) - return true; // No other macro instantiations. - - return isAtEndOfMacroInstantiation(instLoc, LangOpts); -} - //===----------------------------------------------------------------------===// // Other miscellaneous methods. //===----------------------------------------------------------------------===// |