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
This commit is contained in:
Eduardo Caldas 2020-07-10 09:23:09 +00:00
parent 1db5b348c4
commit a474d5bae4
1 changed files with 4 additions and 6 deletions

View File

@ -737,22 +737,20 @@ 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<char, 16>();
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;
}
}
}
bool WalkUpFromUserDefinedLiteral(UserDefinedLiteral *S) {
Builder.markChildToken(S->getBeginLoc(), syntax::NodeRole::LiteralToken);