[clang] a5cefd9 - [libTooling] Fix use of `char` in comparison.
Yitzhak Mandelbaum via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 05:24:45 PDT 2020
Author: Yitzhak Mandelbaum
Date: 2020-09-11T12:24:09Z
New Revision: a5cefd95cc60318fbf8610ee782bd22b492692a2
URL: https://github.com/llvm/llvm-project/commit/a5cefd95cc60318fbf8610ee782bd22b492692a2
DIFF: https://github.com/llvm/llvm-project/commit/a5cefd95cc60318fbf8610ee782bd22b492692a2.diff
LOG: [libTooling] Fix use of `char` in comparison.
Fixes Transformer's `Range` parser to handle `char` in a platform-independent way.
Differential Revision: https://reviews.llvm.org/D87409
Added:
Modified:
clang/lib/Tooling/Transformer/Parsing.cpp
Removed:
################################################################################
diff --git a/clang/lib/Tooling/Transformer/Parsing.cpp b/clang/lib/Tooling/Transformer/Parsing.cpp
index fb5fd4a800bb..66fa04a15594 100644
--- a/clang/lib/Tooling/Transformer/Parsing.cpp
+++ b/clang/lib/Tooling/Transformer/Parsing.cpp
@@ -148,7 +148,7 @@ static ParseState advance(ParseState S, size_t N) {
}
static StringRef consumeWhitespace(StringRef S) {
- return S.drop_while([](char c) { return c >= 0 && isWhitespace(c); });
+ return S.drop_while([](char c) { return isASCII(c) && isWhitespace(c); });
}
// Parses a single expected character \c c from \c State, skipping preceding
@@ -165,7 +165,7 @@ static ExpectedProgress<llvm::NoneType> parseChar(char c, ParseState State) {
static ExpectedProgress<std::string> parseId(ParseState State) {
State.Input = consumeWhitespace(State.Input);
auto Id = State.Input.take_while(
- [](char c) { return c >= 0 && isIdentifierBody(c); });
+ [](char c) { return isASCII(c) && isIdentifierBody(c); });
if (Id.empty())
return makeParseError(State, "failed to parse name");
return makeParseProgress(advance(State, Id.size()), Id.str());
More information about the cfe-commits
mailing list