From 791a735f8ce9abbad83d7cd14c1543d58c1ed829 Mon Sep 17 00:00:00 2001 From: George Karpenkov Date: Fri, 9 Feb 2018 23:30:07 +0000 Subject: [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 --- lib/Edit/Commit.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/Edit') 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)) -- cgit v1.2.1