From a474d5bae4773782d50d4a5a62300c0f4a2dff28 Mon Sep 17 00:00:00 2001 From: Eduardo Caldas Date: Fri, 10 Jul 2020 09:23:09 +0000 Subject: [PATCH] Use FileRange::text instead of Lexer::getSpelling * as we are using them only for integer and floating literals they have the same behavior * FileRange::text is simpler to call and is within the context of syntax trees --- clang/lib/Tooling/Syntax/BuildTree.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp index 5afe4965793..6d13f1ace83 100644 --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -737,20 +737,18 @@ public: // information from the token. As integer and floating point have the same // token kind, we run `NumericLiteralParser` again to distinguish them. auto TokLoc = S->getBeginLoc(); - auto buffer = SmallVector(); - bool invalidSpelling = false; auto TokSpelling = - Lexer::getSpelling(TokLoc, buffer, Context.getSourceManager(), - Context.getLangOpts(), &invalidSpelling); - assert(!invalidSpelling); + Builder.findToken(TokLoc)->text(Context.getSourceManager()); auto Literal = NumericLiteralParser(TokSpelling, TokLoc, Context.getSourceManager(), Context.getLangOpts(), Context.getTargetInfo(), Context.getDiagnostics()); if (Literal.isIntegerLiteral()) return new (allocator()) syntax::IntegerUserDefinedLiteralExpression; - else + else { + assert(Literal.isFloatingLiteral()); return new (allocator()) syntax::FloatUserDefinedLiteralExpression; + } } } -- 2.11.0