[clang] a474d5b - Use FileRange::text instead of Lexer::getSpelling
Eduardo Caldas via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 10 09:21:27 PDT 2020
Author: Eduardo Caldas
Date: 2020-07-10T16:21:12Z
New Revision: a474d5bae4773782d50d4a5a62300c0f4a2dff28
URL: https://github.com/llvm/llvm-project/commit/a474d5bae4773782d50d4a5a62300c0f4a2dff28
DIFF: https://github.com/llvm/llvm-project/commit/a474d5bae4773782d50d4a5a62300c0f4a2dff28.diff
LOG: 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
Added:
Modified:
clang/lib/Tooling/Syntax/BuildTree.cpp
Removed:
################################################################################
diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 5afe4965793a..6d13f1ace83b 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -737,20 +737,18 @@ class BuildTreeVisitor : public RecursiveASTVisitor<BuildTreeVisitor> {
// 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;
+ }
}
}
More information about the cfe-commits
mailing list