diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-02-09 23:30:07 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-02-09 23:30:07 +0000 |
commit | 791a735f8ce9abbad83d7cd14c1543d58c1ed829 (patch) | |
tree | ec19e3523f4455424b6830040a2d2f17edee1d6f /lib/Edit | |
parent | 96146791456d66ac778b04138ec057ddfc5ce231 (diff) | |
download | clang-791a735f8ce9abbad83d7cd14c1543d58c1ed829.tar.gz |
[NFC] Extract method to SourceManager for traversing the macro "stack"
The code for going up the macro arg expansion is duplicated in many
places (and we need it for the analyzer as well, so I did not want to
duplicate it two more times).
This patch is an NFC, so the semantics should remain the same.
Differential Revision: https://reviews.llvm.org/D42458
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324780 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Edit')
-rw-r--r-- | lib/Edit/Commit.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/Edit/Commit.cpp b/lib/Edit/Commit.cpp index cb7a784a41..0cc152bf1e 100644 --- a/lib/Edit/Commit.cpp +++ b/lib/Edit/Commit.cpp @@ -225,8 +225,7 @@ bool Commit::canInsert(SourceLocation loc, FileOffset &offs) { isAtStartOfMacroExpansion(loc, &loc); const SourceManager &SM = SourceMgr; - while (SM.isMacroArgExpansion(loc)) - loc = SM.getImmediateSpellingLoc(loc); + loc = SM.getTopMacroCallerLoc(loc); if (loc.isMacroID()) if (!isAtStartOfMacroExpansion(loc, &loc)) @@ -256,8 +255,7 @@ bool Commit::canInsertAfterToken(SourceLocation loc, FileOffset &offs, isAtEndOfMacroExpansion(loc, &loc); const SourceManager &SM = SourceMgr; - while (SM.isMacroArgExpansion(loc)) - loc = SM.getImmediateSpellingLoc(loc); + loc = SM.getTopMacroCallerLoc(loc); if (loc.isMacroID()) if (!isAtEndOfMacroExpansion(loc, &loc)) |