[clang] [llvm] [Clang] Repair the function "rParenEndsCast" to make incorrect judgments in template variable cases (PR #120904)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 22 23:13:03 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff db2307d2d7f650aa8f0d9ba727abfe83a32bc3bf 8b1d1162378e7a11902b92a44bfdd75001ea6239 --extensions cpp -- clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/TokenAnnotatorTest.cpp llvm/lib/Target/X86/X86ISelLowering.cpp llvm/lib/Transforms/Vectorize/VectorCombine.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index da9860c7cd..3f44b8c185 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -42,7 +42,7 @@ namespace {
// TODO: Add new Type modifiers
llvm::SmallVector<llvm::StringRef> castIdentifiers{"__type_identity_t",
- "remove_reference_t"};
+ "remove_reference_t"};
/// Returns \c true if the line starts with a token that can start a statement
/// with an initializer.
@@ -2481,9 +2481,10 @@ private:
Current.setType(TT_StringInConcatenation);
}
} else if (Style.isCpp() && Current.is(tok::kw_using)) {
- if (Current.Next && Current.Next->Next && Current.Next->Next->Next)
+ if (Current.Next && Current.Next->Next && Current.Next->Next->Next) {
if (Current.Next->Next->Next->isTypeName(LangOpts))
castIdentifiers.push_back(Current.Next->TokenText);
+ }
} else if (Current.is(tok::l_paren)) {
if (lParenStartsCppCast(Current))
Current.setType(TT_CppCastLParen);
@@ -2842,9 +2843,11 @@ private:
bool ParensCouldEndDecl =
AfterRParen->isOneOf(tok::equal, tok::semi, tok::l_brace, tok::greater);
if (ParensAreType && !ParensCouldEndDecl) {
- if (BeforeRParen->is(TT_TemplateCloser) ) {
- if (determineUnaryOperatorByUsage(*AfterRParen)) return true;
- if (AfterRParen->isOneOf(tok::plus, tok::minus, tok::star, tok::exclaim, tok::amp)) {
+ if (BeforeRParen->is(TT_TemplateCloser)) {
+ if (determineUnaryOperatorByUsage(*AfterRParen))
+ return true;
+ if (AfterRParen->isOneOf(tok::plus, tok::minus, tok::star, tok::exclaim,
+ tok::amp)) {
auto *Prev = BeforeRParen->MatchingParen->getPreviousNonComment();
for (auto &name : castIdentifiers)
if (Prev->TokenText == name)
``````````
</details>
https://github.com/llvm/llvm-project/pull/120904
More information about the llvm-commits
mailing list