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/Basic/SourceManager.cpp | |
| parent | 96146791456d66ac778b04138ec057ddfc5ce231 (diff) | |
[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/Basic/SourceManager.cpp')
| -rw-r--r-- | lib/Basic/SourceManager.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 0a51985614..3bf70b6669 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -955,6 +955,12 @@ SourceManager::getImmediateExpansionRange(SourceLocation Loc) const { return Expansion.getExpansionLocRange(); } +SourceLocation SourceManager::getTopMacroCallerLoc(SourceLocation Loc) const { + while (isMacroArgExpansion(Loc)) + Loc = getImmediateSpellingLoc(Loc); + return Loc; +} + /// getExpansionRange - Given a SourceLocation object, return the range of /// tokens covered by the expansion in the ultimate file. std::pair<SourceLocation,SourceLocation> |
