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 | 7a759606d93975866051f67104ae58446e55f404 (patch) | |
tree | 7cea5f3d5011bf43b5ba37f3163aa33b3e48ccb1 /lib/Basic/SourceManager.cpp | |
parent | 14ef3191a75b8bcdab391e6ffa6367b731c2ce67 (diff) |
Move SourceManager::isAt[Start/End]OfMacroInstantiation functions to the Lexer, since they depend on it now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134644 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/SourceManager.cpp')
-rw-r--r-- | lib/Basic/SourceManager.cpp | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 137da0d87a..cd098b23aa 100644 --- a/lib/Basic/SourceManager.cpp +++ b/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. //===----------------------------------------------------------------------===// |