diff options
-rw-r--r-- | clang/lib/AST/Stmt.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 7dfa3a9df13..f514ed21f47 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -503,6 +503,9 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces, bool HasVariants = !C.getTargetInfo().hasNoAsmVariants(); + unsigned LastAsmStringToken = 0; + unsigned LastAsmStringOffset = 0; + while (1) { // Done with the string? if (CurPtr == StrEnd) { @@ -589,10 +592,12 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces, // (BeginLoc, EndLoc) represents the range of the operand we are currently // processing. Unlike Str, the range includes the leading '%'. - SourceLocation BeginLoc = - getAsmString()->getLocationOfByte(Percent - StrStart, SM, LO, TI); - SourceLocation EndLoc = - getAsmString()->getLocationOfByte(CurPtr - StrStart, SM, LO, TI); + SourceLocation BeginLoc = getAsmString()->getLocationOfByte( + Percent - StrStart, SM, LO, TI, &LastAsmStringToken, + &LastAsmStringOffset); + SourceLocation EndLoc = getAsmString()->getLocationOfByte( + CurPtr - StrStart, SM, LO, TI, &LastAsmStringToken, + &LastAsmStringOffset); Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc); continue; @@ -623,10 +628,12 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces, // (BeginLoc, EndLoc) represents the range of the operand we are currently // processing. Unlike Str, the range includes the leading '%'. - SourceLocation BeginLoc = - getAsmString()->getLocationOfByte(Percent - StrStart, SM, LO, TI); - SourceLocation EndLoc = - getAsmString()->getLocationOfByte(NameEnd + 1 - StrStart, SM, LO, TI); + SourceLocation BeginLoc = getAsmString()->getLocationOfByte( + Percent - StrStart, SM, LO, TI, &LastAsmStringToken, + &LastAsmStringOffset); + SourceLocation EndLoc = getAsmString()->getLocationOfByte( + NameEnd + 1 - StrStart, SM, LO, TI, &LastAsmStringToken, + &LastAsmStringOffset); Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc); |