aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Tooling/Syntax/BuildTree.cpp
diff options
context:
space:
mode:
authorEduardo Caldas <ecaldas@google.com>2020-07-10 09:23:09 +0000
committerEduardo Caldas <ecaldas@google.com>2020-07-10 16:21:12 +0000
commita474d5bae4773782d50d4a5a62300c0f4a2dff28 (patch)
treee86b4b735fe2cd28b25b51615ed6ef3f5fc66609 /clang/lib/Tooling/Syntax/BuildTree.cpp
parent1db5b348c4c93b6610afb4fd515b389989efc302 (diff)
downloadllvm-a474d5bae4773782d50d4a5a62300c0f4a2dff28.zip
llvm-a474d5bae4773782d50d4a5a62300c0f4a2dff28.tar.gz
llvm-a474d5bae4773782d50d4a5a62300c0f4a2dff28.tar.bz2
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
Diffstat (limited to 'clang/lib/Tooling/Syntax/BuildTree.cpp')
-rw-r--r--clang/lib/Tooling/Syntax/BuildTree.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 5afe496..6d13f1a 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<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;
+ }
}
}