[PATCH] D121756: [clang-format] Clean up code looking for if statements
sstwcw updated this revision to Diff 420031. sstwcw retitled this revision from "[clang-format] Clean up code looking for if statements NFC" to "[clang-format] Clean up code looking for if statements". sstwcw edited the summary of this revision. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121756/new/ https://reviews.llvm.org/D121756 Files: clang/lib/Format/FormatToken.h clang/lib/Format/TokenAnnotator.cpp clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Index: clang/unittests/Format/TokenAnnotatorTest.cpp === --- clang/unittests/Format/TokenAnnotatorTest.cpp +++ clang/unittests/Format/TokenAnnotatorTest.cpp @@ -646,6 +646,55 @@ EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_ObjCBlockLBrace); } +TEST_F(TokenAnnotatorTest, UnderstandsConditionParen) { + auto Tokens = annotate("if (true) {\n}"); + ASSERT_EQ(Tokens.size(), 7u) << Tokens; + EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_ConditionLParen); + Tokens = annotate("if constexpr (true) {\n}"); + ASSERT_EQ(Tokens.size(), 8u) << Tokens; + EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_ConditionLParen); + Tokens = annotate("if CONSTEXPR (true) {\n}"); + ASSERT_EQ(Tokens.size(), 8u) << Tokens; + EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_ConditionLParen); + + // The parentheses following for is not TT_ConditionLParen, because inside is + // not just a condition. + Tokens = annotate("for (;;) {\n}"); + ASSERT_EQ(Tokens.size(), 8u) << Tokens; + EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_Unknown); + Tokens = annotate("foreach (Item *item, itemlist) {\n}"); + ASSERT_EQ(Tokens.size(), 11u) << Tokens; + EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_Unknown); + Tokens = annotate("Q_FOREACH (Item *item, itemlist) {\n}"); + ASSERT_EQ(Tokens.size(), 11u) << Tokens; + EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_Unknown); + Tokens = annotate("BOOST_FOREACH (Item *item, itemlist) {\n}"); + ASSERT_EQ(Tokens.size(), 11u) << Tokens; + EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_Unknown); + Tokens = annotate("try {\n" +"} catch (Exception &bar) {\n" +"}"); + ASSERT_EQ(Tokens.size(), 12u) << Tokens; + EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_Unknown); + + Tokens = annotate("while (true) {\n}"); + ASSERT_EQ(Tokens.size(), 7u) << Tokens; + EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_ConditionLParen); + Tokens = annotate("do {\n} while (true);"); + ASSERT_EQ(Tokens.size(), 9u) << Tokens; + EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_ConditionLParen); + + Tokens = annotate("switch (true) {\n}"); + ASSERT_EQ(Tokens.size(), 7u) << Tokens; + EXPECT_TOKEN(Tokens[1], tok::l_paren, TT_ConditionLParen); + Tokens = annotate("switch (x * x) {\n}"); + ASSERT_EQ(Tokens.size(), 9u) << Tokens; + EXPECT_TOKEN(Tokens[3], tok::star, TT_BinaryOperator); + Tokens = annotate("switch (x & x) {\n}"); + ASSERT_EQ(Tokens.size(), 9u) << Tokens; + EXPECT_TOKEN(Tokens[3], tok::amp, TT_BinaryOperator); +} + } // namespace } // namespace format } // namespace clang Index: clang/unittests/Format/FormatTest.cpp === --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -2628,6 +2628,10 @@ "[[likely]] case 2:\n" " return;\n" "}"); + verifyFormat("switch (x * x) { //\n" + "}"); + verifyFormat("switch (x & x) { //\n" + "}"); FormatStyle Attributes = getLLVMStyle(); Attributes.AttributeMacros.push_back("LIKELY"); Attributes.AttributeMacros.push_back("OTHER_LIKELY"); @@ -3177,6 +3181,15 @@ Style.ColumnLimit = 20; // to concentrate at brace wrapping, not line wrap due to column limit + verifyFormat("if (xx\n" + ".xx)\n" + " continue;", + Style); + verifyFormat("while (xx\n" + " .xx)\n" + " continue;", + Style); + Style.BraceWrapping.BeforeElse = true; EXPECT_EQ( "if (foo) {\n" Index: clang/lib/Format/UnwrappedLineParser.cpp === --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -2422,8 +2422,10 @@ } else { if (FormatTok->isOneOf(tok::kw_constexpr, tok::identifier)) nextToken(); -if (FormatTok->is(tok::l_paren)) +if (FormatTok->is(tok::l_paren)) { + FormatTok->setFinalizedType(TT_ConditionLParen); parseParens(); +} } handleAttributes(); @@ -2714,14 +2716,20 @@ void UnwrappedLineParser::parseForOrWhileLoop() { assert(FormatTok->isOneOf(tok::kw_for, tok::kw_while, TT_ForEachMacro) && "'for', 'while' or foreach macro expected"); + const FormatToken &FirstTok = *FormatTo
[PATCH] D121756: [clang-format] Clean up code looking for if statements
sstwcw marked 2 inline comments as done. sstwcw added inline comments. Comment at: clang/lib/Format/TokenAnnotator.cpp:252-256 +} else if (OpeningParen.isConditionLParen(/*IncludeFor=*/false) || + (OpeningParen.Previous && +OpeningParen.Previous->isOneOf(TT_BinaryOperator, tok::l_paren, + tok::comma, + tok::kw_static_assert))) { owenpan wrote: > owenpan wrote: > > I don't think this is NFC. > > Before: > > ``` > > } else if (OpeningParen.Previous && > >(OpeningParen.Previous->isOneOf(tok::kw_static_assert, > >tok::kw_while, tok::l_paren, > >tok::comma, tok::kw_if, > >TT_BinaryOperator) || > > OpeningParen.Previous->endsSequence(tok::kw_constexpr, > > tok::kw_if) || > > OpeningParen.Previous->endsSequence(tok::identifier, > > tok::kw_if))) { > > ``` > > After: > > ``` > > } else if ((OpeningParen.is(tok::l_paren) && > > OpeningParen.is(TT_ConditionLParen)) || > >// PreviousNonComment = OpeningParen.getPreviousNonComment() > >(PreviousNonComment && > > PreviousNonComment->isOneOf(tok::kw_if, tok::kw_while, > > tok::kw_switch, tok::kw_case, > > tok::kw_constexpr)) || > >(OpeningParen.Previous && > > OpeningParen.Previous->isOneOf(tok::kw_static_assert, > >tok::l_paren, tok::comma, > >TT_BinaryOperator))) { > > ``` > > After: > > ``` > > } else if ((OpeningParen.is(tok::l_paren) && > > OpeningParen.is(TT_ConditionLParen)) || > > ... > > tok::kw_constexpr)) || > >... > > ``` > > After: > ``` > } else if ((OpeningParen.is(tok::l_paren) && > (OpeningParen.is(TT_ConditionLParen) || > ... > tok::kw_constexpr || >... > ``` I removed NFC from the title. It would affect things like this: ``` new: switch (x * x) old: switch (x *x) ``` However the entire llvm codebase doesn't seem to have such things. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121756/new/ https://reviews.llvm.org/D121756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1f0b8ba - [C++20][Modules] Fix a testcase warning on Windows [NFC].
Author: Iain Sandoe Date: 2022-04-03T11:39:00+01:00 New Revision: 1f0b8ba47ab0f1dc678099d4830d0cc0d10850b6 URL: https://github.com/llvm/llvm-project/commit/1f0b8ba47ab0f1dc678099d4830d0cc0d10850b6 DIFF: https://github.com/llvm/llvm-project/commit/1f0b8ba47ab0f1dc678099d4830d0cc0d10850b6.diff LOG: [C++20][Modules] Fix a testcase warning on Windows [NFC]. As reported, using "-DTDIR=%t" with a path name of 'C:\Users\...' causes a warning to be emitted about the use of \U without following hex digits. Since the value is only required for the FileCheck cases resolve this by omitting the -D from the compile lines. Added: Modified: clang/test/Modules/cxx20-hu-04.cpp Removed: diff --git a/clang/test/Modules/cxx20-hu-04.cpp b/clang/test/Modules/cxx20-hu-04.cpp index 1de8ceff3e7f5..da6056d4d47ed 100644 --- a/clang/test/Modules/cxx20-hu-04.cpp +++ b/clang/test/Modules/cxx20-hu-04.cpp @@ -19,10 +19,10 @@ // RUN: FileCheck --check-prefix=CHECK-HU2 %s -DTDIR=%t // RUN: %clang_cc1 -std=c++20 -emit-module-interface importer-01.cpp \ -// RUN: -fmodule-file=hu-02.pcm -o B.pcm -DTDIR=%t -verify +// RUN: -fmodule-file=hu-02.pcm -o B.pcm -verify // RUN: %clang_cc1 -std=c++20 -emit-module-interface importer-02.cpp \ -// RUN: -fmodule-file=hu-02.pcm -o C.pcm -DTDIR=%t -Rmodule-import 2>&1 | \ +// RUN: -fmodule-file=hu-02.pcm -o C.pcm -Rmodule-import 2>&1 | \ // RUN: FileCheck --check-prefix=CHECK-IMP-HU2 %s -DTDIR=%t //--- hu-01.h ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D122155: Add warning when eval-method is set in the presence of value unsafe floating-point calculations.
zahiraam updated this revision to Diff 420035. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122155/new/ https://reviews.llvm.org/D122155 Files: clang/include/clang/Basic/DiagnosticFrontendKinds.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Sema/SemaAttr.cpp clang/test/Driver/eval-method-with-unsafe-math.c clang/test/Sema/eval-method-with-unsafe-math.c Index: clang/test/Sema/eval-method-with-unsafe-math.c === --- /dev/null +++ clang/test/Sema/eval-method-with-unsafe-math.c @@ -0,0 +1,56 @@ +// RUN: not %clang_cc1 -fexperimental-strict-floating-point \ +// RUN: -triple x86_64-linux-gnu \ +// RUN: -verify %s 2>&1 | FileCheck %s --check-prefixes=CHECK-PRGM + +// RUN: not %clang_cc1 -fexperimental-strict-floating-point \ +// RUN: -triple x86_64-linux-gnu -freciprocal-math \ +// RUN: -verify %s 2>&1 | FileCheck %s --check-prefixes=CHECK-RECPR,CHECK-PRGM + +// RUN: not %clang_cc1 -fexperimental-strict-floating-point \ +// RUN: -triple x86_64-linux-gnu -mreassociate \ +// RUN: -verify %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ASSOC,CHECK-PRGM + +// RUN: not %clang_cc1 -fexperimental-strict-floating-point \ +// RUN: -triple x86_64-linux-gnu -fapprox-func \ +// RUN: -verify %s 2>&1 | FileCheck %s --check-prefixes=CHECK-FUNC,CHECK-PRGM + +// RUN: not %clang_cc1 -fexperimental-strict-floating-point \ +// RUN: -triple x86_64-linux-gnu -freciprocal-math -mreassociate -verify \ +// RUN: %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ASSOC,CHECK-RECPR,CHECK-PRGM + +// RUN: not %clang_cc1 -fexperimental-strict-floating-point \ +// RUN: -triple x86_64-linux-gnu -freciprocal-math -mreassociate -fapprox-func \ +// RUN: -verify %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=CHECK-FUNC,CHECK-ASSOC,CHECK-RECPR,CHECK-PRGM + +// RUN: not %clang_cc1 -fexperimental-strict-floating-point \ +// RUN: -triple x86_64-linux-gnu -ffp-eval-method=source \ +// RUN: -verify %s 2>&1 | FileCheck %s --check-prefixes=CHECK-FFP-OPT,CHECK-PRGM + +// expected-no-diagnostics + +float f1(float a, float b, float c) { + a = b + c; + return a * b + c; +} + +float f2(float a, float b, float c) { + // CHECK-FFP-OPT: option 'ffp-eval-method' cannot be used with '#pragma clang fp reassociate' +#pragma clang fp reassociate(on) + return (a + b) + c; +} + +float f3(float a, float b, float c) { +#pragma clang fp reassociate(off) + return (a - b) - c; +} + +float f4(float a, float b, float c) { +#pragma clang fp eval_method(double) + // CHECK-FUNC: '#pragma clang fp eval_method' cannot be used with option 'fapprox-func' + // CHECK-ASSOC: '#pragma clang fp eval_method' cannot be used with option 'mreassociate' + // CHECK-RECPR: '#pragma clang fp eval_method' cannot be used with option 'freciprocal' + // CHECK-PRGM: '#pragma clang fp eval_method' cannot be used with '#pragma clang fp reassociate' +#pragma clang fp reassociate(on) + return (a * c) - (b * c); +} Index: clang/test/Driver/eval-method-with-unsafe-math.c === --- /dev/null +++ clang/test/Driver/eval-method-with-unsafe-math.c @@ -0,0 +1,29 @@ +// RUN: not %clang -Xclang -fexperimental-strict-floating-point \ +// RUN: -Xclang -triple -Xclang x86_64-linux-gnu -fapprox-func \ +// RUN: -Xclang -verify -ffp-eval-method=source %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=CHECK-FUNC + +// RUN: not %clang -Xclang -fexperimental-strict-floating-point \ +// RUN: -Xclang -triple -Xclang x86_64-linux-gnu -Xclang -mreassociate \ +// RUN: -ffp-eval-method=source -Xclang -verify %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=CHECK-ASSOC + +// RUN: not %clang -Xclang -fexperimental-strict-floating-point \ +// RUN: -Xclang -triple -Xclang x86_64-linux-gnu -Xclang -freciprocal-math \ +// RUN: -ffp-eval-method=source -Xclang -verify %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=CHECK-RECPR + +// RUN: not %clang -Xclang -fexperimental-strict-floating-point \ +// RUN: -Xclang -triple -Xclang x86_64-linux-gnu -Xclang -freciprocal-math \ +// RUN: -Xclang -mreassociate -ffp-eval-method=source -Xclang -verify %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=CHECK-ASSOC,CHECK-RECPR + +// RUN: not %clang -Xclang -fexperimental-strict-floating-point \ +// RUN: -Xclang -triple -Xclang x86_64-linux-gnu -Xclang -freciprocal-math \ +// RUN: -Xclang -mreassociate -fapprox-func -ffp-eval-method=source \ +// RUN: -Xclang -verify %s 2>&1 \ +// RUN: | FileCheck %s --check-prefixes=CHECK-ASSOC,CHECK-RECPR,CHECK-FUNC + +// CHECK-FUNC: (frontend): option 'ffp-eval-method' cannot be used with option 'fapprox-func' +// CHECK-ASSOC: (frontend): option 'ffp-eval-method' cannot be used with option 'mreassociate' +// CHECK-RECPR: (frontend): option 'ffp-eval-method' cannot be used with option 'freciprocal' Index: clang/lib/Sema/SemaAttr.cpp ==
[PATCH] D122992: Remove wrong warning. Fix for https://github.com/llvm/llvm-project/issues/54625
zahiraam created this revision. zahiraam added reviewers: andrew.w.kaylor, aaron.ballman, efriedma. Herald added a project: All. zahiraam requested review of this revision. Herald added a subscriber: MaskRay. Herald added a project: clang. When driver's floating-point options change, the user is made aware via a diagnostic. In the case of combining a fast math option with a non-fast option there should be no diagnostic. This patch removes the wrong diagnostic. This is a fix for https://github.com/llvm/llvm-project/issues/54625. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D122992 Files: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/fp-model.c Index: clang/test/Driver/fp-model.c === --- clang/test/Driver/fp-model.c +++ clang/test/Driver/fp-model.c @@ -3,6 +3,8 @@ // // REQUIRES: clang-driver +// expected-no-diagnostics + // RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=WARN %s // WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option] @@ -19,6 +21,13 @@ // RUN: | FileCheck --check-prefix=WARN3 %s // WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option] +// RUN: %clang -c -ffast-math -fno-fast-math -Xclang -verify %s 2>&1 +// RUN: %clang -c -fno-fast-math -ffast-math -Xclang -verify %s 2>&1 +// RUN: %clang -c -ffast-math -ffp-contract=on -Xclang -verify %s 2>&1 +// RUN: %clang -c -ffp-contract=on -ffast-math -Xclang -verify %s 2>&1 +// RUN: %clang -c -ffp-contract=on -ffp-model=fast -Xclang -verify %s 2>&1 +// RUN: %clang -c -ffp-model=fast -ffp-contract=on -Xclang -verify %s 2>&1 + // RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=WARN4 %s // WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option] @@ -63,6 +72,9 @@ // RUN: | FileCheck --check-prefix=WARNf %s // WARNf: warning: overriding '-ffp-model=strict' option with '-Ofast' [-Woverriding-t-option] +// RUN: %clang -c -Ofast -fno-fast-math -Xclang -verify %s 2>&1 +// RUN: %clang -c -fno-fast-math -Ofast -Xclang -verify %s 2>&1 + // RUN: %clang -### -ffp-model=strict -fdenormal-fp-math=preserve-sign,preserve-sign -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=WARN10 %s // WARN10: warning: overriding '-ffp-model=strict' option with '-fdenormal-fp-math=preserve-sign,preserve-sign' [-Woverriding-t-option] @@ -102,6 +114,9 @@ // CHECK-FPM-PRECISE: "-ffp-contract=on" // CHECK-FPM-PRECISE: "-fno-rounding-math" +// RUN: %clang -c -ffp-model=precise -ffp-contract=fast -Xclang -verify %s 2>&1 +// RUN: %clang -c -ffp-contract=fast -ffp-model=precise -Xclang -verify %s 2>&1 + // RUN: %clang -### -nostdinc -ffp-model=strict -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FPM-STRICT %s // CHECK-FPM-STRICT: "-cc1" Index: clang/lib/Driver/ToolChains/Clang.cpp === --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -3006,9 +3006,6 @@ !JA.isOffloading(Action::OFK_HIP)) if (FPContract == "fast") { FPContract = "on"; - D.Diag(clang::diag::warn_drv_overriding_flag_option) - << "-ffp-contract=fast" - << "-ffp-contract=on"; } break; } Index: clang/test/Driver/fp-model.c === --- clang/test/Driver/fp-model.c +++ clang/test/Driver/fp-model.c @@ -3,6 +3,8 @@ // // REQUIRES: clang-driver +// expected-no-diagnostics + // RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=WARN %s // WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option] @@ -19,6 +21,13 @@ // RUN: | FileCheck --check-prefix=WARN3 %s // WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option] +// RUN: %clang -c -ffast-math -fno-fast-math -Xclang -verify %s 2>&1 +// RUN: %clang -c -fno-fast-math -ffast-math -Xclang -verify %s 2>&1 +// RUN: %clang -c -ffast-math -ffp-contract=on -Xclang -verify %s 2>&1 +// RUN: %clang -c -ffp-contract=on -ffast-math -Xclang -verify %s 2>&1 +// RUN: %clang -c -ffp-contract=on -ffp-model=fast -Xclang -verify %s 2>&1 +// RUN: %clang -c -ffp-model=fast -ffp-contract=on -Xclang -verify %s 2>&1 + // RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=WARN4 %s // WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option] @@ -63,6 +72,9 @@ // RUN: | FileCheck --check-prefix=WARNf %s // WARNf: warning: overriding '-ffp-model=strict' option with '-Ofast' [-Woverriding-t-option] +// RUN: %clang -c -Ofast -fno
[libunwind] 282b3eb - [libunwind] Add missing licenses in test files
Author: Louis Dionne Date: 2022-04-03T08:55:57-04:00 New Revision: 282b3eb72372f6a0139923d326b05fc16d86c9fa URL: https://github.com/llvm/llvm-project/commit/282b3eb72372f6a0139923d326b05fc16d86c9fa DIFF: https://github.com/llvm/llvm-project/commit/282b3eb72372f6a0139923d326b05fc16d86c9fa.diff LOG: [libunwind] Add missing licenses in test files Added: Modified: libunwind/test/frameheadercache_test.pass.cpp libunwind/test/libunwind_01.pass.cpp libunwind/test/libunwind_02.pass.cpp libunwind/test/remember_state_leak.pass.sh.s libunwind/test/unw_getcontext.pass.cpp Removed: diff --git a/libunwind/test/frameheadercache_test.pass.cpp b/libunwind/test/frameheadercache_test.pass.cpp index 9abff5e8cda9a..6b648e7284914 100644 --- a/libunwind/test/frameheadercache_test.pass.cpp +++ b/libunwind/test/frameheadercache_test.pass.cpp @@ -1,3 +1,12 @@ +// -*- C++ -*- +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + // The other libunwind tests don't test internal interfaces, so the include path // is a little wonky. #include "../src/config.h" diff --git a/libunwind/test/libunwind_01.pass.cpp b/libunwind/test/libunwind_01.pass.cpp index d89f8d16ce70d..8b4825ac30dca 100644 --- a/libunwind/test/libunwind_01.pass.cpp +++ b/libunwind/test/libunwind_01.pass.cpp @@ -1,3 +1,12 @@ +// -*- C++ -*- +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + // TODO: Investigate these failures on x86_64 macOS back deployment // UNSUPPORTED: target=x86_64-apple-darwin{{.+}} diff --git a/libunwind/test/libunwind_02.pass.cpp b/libunwind/test/libunwind_02.pass.cpp index a4f47c521858a..c0d6b05c2a729 100644 --- a/libunwind/test/libunwind_02.pass.cpp +++ b/libunwind/test/libunwind_02.pass.cpp @@ -1,3 +1,12 @@ +// -*- C++ -*- +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + // TODO: Figure out why this fails with Memory Sanitizer. // XFAIL: msan diff --git a/libunwind/test/remember_state_leak.pass.sh.s b/libunwind/test/remember_state_leak.pass.sh.s index a02c8213c669c..63beb7e4701ec 100644 --- a/libunwind/test/remember_state_leak.pass.sh.s +++ b/libunwind/test/remember_state_leak.pass.sh.s @@ -1,7 +1,15 @@ +#======# +# +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# +#======# + # REQUIRES: target={{x86_64-.+-linux-gnu}} -// Inline assembly isn't supported by Memory Sanitizer -// UNSUPPORTED: msan +# Inline assembly isn't supported by Memory Sanitizer +# UNSUPPORTED: msan # RUN: %{build} -no-pie # RUN: %{run} diff --git a/libunwind/test/unw_getcontext.pass.cpp b/libunwind/test/unw_getcontext.pass.cpp index a1f2baee12b4b..7e2735e418be7 100644 --- a/libunwind/test/unw_getcontext.pass.cpp +++ b/libunwind/test/unw_getcontext.pass.cpp @@ -1,3 +1,12 @@ +// -*- C++ -*- +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + #include #include ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D121097: [C++20][Modules][HU 3/5] Emit module macros for header units.
iains added a comment. applied [C++20][Modules] Fix a testcase warning on Windows [NFC]. https://github.com/llvm/llvm-project/commit/1f0b8ba47ab0f1dc678099d4830d0cc0d10850b6 should be fixed now. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121097/new/ https://reviews.llvm.org/D121097 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] ef19de5 - [clang-tidy] Add release notes for changes made in 2b21fc5520b39fba555f4e5f2480a5651056be84
Author: Danny Mösch Date: 2022-04-03T15:48:39+02:00 New Revision: ef19de52ed59a739b0381f2b9b41604e7fa49b59 URL: https://github.com/llvm/llvm-project/commit/ef19de52ed59a739b0381f2b9b41604e7fa49b59 DIFF: https://github.com/llvm/llvm-project/commit/ef19de52ed59a739b0381f2b9b41604e7fa49b59.diff LOG: [clang-tidy] Add release notes for changes made in 2b21fc5520b39fba555f4e5f2480a5651056be84 Added: Modified: clang-tools-extra/docs/ReleaseNotes.rst Removed: diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index e5140ed45cbb3..919ec64519232 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -99,6 +99,12 @@ Improvements to clang-tidy - Added trace code to help narrow down any checks and the relevant source code that result in crashes. +- Clang-tidy now consideres newlines as separators of single elements in the `Checks` section in + `.clang-tidy` configuration files. Where previously a comma had to be used to distinguish elements in + this list from each other, newline characters now also work as separators in the parsed YAML. That + means it is advised to use YAML's block style initiated by the pipe character `|` for the `Checks` + section in order to benefit from the easier syntax that works without commas. + New checks ^^ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct
yihanaa marked an inline comment as done. yihanaa added inline comments. Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2113-2117 if (CanonicalType->isRecordType()) { - TmpRes = dumpRecord(CGF, CanonicalType, FieldPtr, Align, Func, Lvl + 1); + TmpRes = dumpRecord(CGF, CanonicalType, FieldLV, Align, Func, Lvl + 1); Res = CGF.Builder.CreateAdd(TmpRes, Res); continue; } yihanaa wrote: > yihanaa wrote: > > rsmith wrote: > > > After this patch, this case no longer prints the field name. Eg: > > > https://godbolt.org/z/o7vcbWaEf > > > > > > ``` > > > #include > > > > > > struct A {}; > > > > > > struct B { > > > A a; > > > }; > > > > > > > > > int main() { > > > B x; > > > __builtin_dump_struct(&x, &printf); > > > } > > > ``` > > > > > > now prints: > > > > > > ``` > > > B { > > > A { > > > } > > > } > > > ``` > > > > > > This seems like an important regression; please can you take a look? This > > > also suggests to me that there's a hole in our test coverage. > > Thanks for taking the time to review my patch and writing the Compiler > > Explorer examples, I'll take a look at this problem > > After this patch, this case no longer prints the field name. Eg: > > https://godbolt.org/z/o7vcbWaEf > > > > ``` > > #include > > > > struct A {}; > > > > struct B { > > A a; > > }; > > > > > > int main() { > > B x; > > __builtin_dump_struct(&x, &printf); > > } > > ``` > > > > now prints: > > > > ``` > > B { > > A { > > } > > } > > ``` > > > > This seems like an important regression; please can you take a look? This > > also suggests to me that there's a hole in our test coverage. > > I'm sorry for introducing this bug. 😔 Do you think the following is correct > behavior? If yes I will try to fix it. > ``` > struct B { > struct A a = { > } > } > ``` I have submitted a patch to fix this. https://reviews.llvm.org/D122920 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122248/new/ https://reviews.llvm.org/D122248 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 50186b6 - Revert "[GH54588]Fix ItaniumMangler for NTTP unnamed unions w/ unnamed structs"
Author: Nico Weber Date: 2022-04-03T17:21:27-04:00 New Revision: 50186b63d1807d389f31c515377d94185795ab44 URL: https://github.com/llvm/llvm-project/commit/50186b63d1807d389f31c515377d94185795ab44 DIFF: https://github.com/llvm/llvm-project/commit/50186b63d1807d389f31c515377d94185795ab44.diff LOG: Revert "[GH54588]Fix ItaniumMangler for NTTP unnamed unions w/ unnamed structs" This reverts commit 4cf98f973a13c5049322abff43f0dff3c214311b. The test fails on mac bots, see comments on https://reviews.llvm.org/D122820 Also reverts follow-ups eb920989865d992093993143ba3c6e71126cbb89 and 861c189d2a5203ba8c8e983e8d2e109c0de153a5. Added: Modified: clang/lib/AST/ItaniumMangle.cpp Removed: clang/test/CodeGenCXX/mangle-nttp-anon-union.cpp diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 50e110ec1f57e..fb76fa7b896fc 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -5545,47 +5545,6 @@ static QualType getLValueType(ASTContext &Ctx, const APValue &LV) { return T; } -static IdentifierInfo *getUnionInitName(SourceLocation UnionLoc, -DiagnosticsEngine &Diags, -const FieldDecl *FD) { - // According to: - // http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling.anonymous - // For the purposes of mangling, the name of an anonymous union is considered - // to be the name of the first named data member found by a pre-order, - // depth-first, declaration-order walk of the data members of the anonymous - // union. - - if (FD->getIdentifier()) -return FD->getIdentifier(); - - // The only cases where the identifer of a FieldDecl would be blank is if the - // field represents an anonymous record type or if it is an unnamed bitfield. - // There is no type to descend into in the case of a bitfield, so we can just - // return nullptr in that case. - if (FD->isBitField()) -return nullptr; - const CXXRecordDecl *RD = FD->getType()->getAsCXXRecordDecl(); - - // Consider only the fields in declaration order, searched depth-first. We - // don't care about the active member of the union, as all we are doing is - // looking for a valid name. We also don't check bases, due to guidance from - // the Itanium ABI folks. - for (const FieldDecl *RDField : RD->fields()) { -if (IdentifierInfo *II = getUnionInitName(UnionLoc, Diags, RDField)) - return II; - } - - // According to the Itanium ABI: If there is no such data member (i.e., if all - // of the data members in the union are unnamed), then there is no way for a - // program to refer to the anonymous union, and there is therefore no need to - // mangle its name. However, we should diagnose this anyway. - unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, "cannot mangle this unnamed union NTTP yet"); - Diags.Report(UnionLoc, DiagID); - - return nullptr; -} - void CXXNameMangler::mangleValueInTemplateArg(QualType T, const APValue &V, bool TopLevel, bool NeedExactType) { @@ -5669,10 +5628,7 @@ void CXXNameMangler::mangleValueInTemplateArg(QualType T, const APValue &V, mangleType(T); if (!isZeroInitialized(T, V)) { Out << "di"; - IdentifierInfo *II = (getUnionInitName( - T->getAsCXXRecordDecl()->getLocation(), Context.getDiags(), FD)); - if (II) -mangleSourceName(II); + mangleSourceName(FD->getIdentifier()); mangleValueInTemplateArg(FD->getType(), V.getUnionValue(), false); } Out << 'E'; diff --git a/clang/test/CodeGenCXX/mangle-nttp-anon-union.cpp b/clang/test/CodeGenCXX/mangle-nttp-anon-union.cpp deleted file mode 100644 index ca2909a9c3dbc..0 --- a/clang/test/CodeGenCXX/mangle-nttp-anon-union.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// RUN: %clang_cc1 -std=c++20 -emit-llvm %s -o - -triple=x86_64-linux-gnu | FileCheck %s -// RUN: %clang_cc1 -std=c++20 -emit-llvm %s -o - -triple=x86_64-linux-gnu | llvm-cxxfilt | FileCheck %s --check-prefix DEMANGLED - -template -struct wrapper1 { - union { -struct { - T RightName; -}; - }; -}; - -template -struct wrapper2 { - union { -struct { - T RightName; -}; -T WrongName; - }; -}; - -struct Base { - int WrongName; -}; - -template -struct wrapper3 { - union { -struct : Base { - T RightName; }; -T WrongName; - }; -}; - -template -struct wrapper4 { - union { -int RightName; -struct { - T WrongName; -}; -T AlsoWrongName; - }; -}; - -template -struct wrapper5 { - union { -struct { - struct { -T RightName; - }; - T WrongName; -}; - }; -}; - -template -struct wrapper6 { - union { -union{ -int : 5; -T RightName; -}; - }; -}; - - - -template
[PATCH] D122820: [GH54588]Fix ItaniumMangler for NTTP unnamed unions w/ unnamed structs
thakis added a comment. Reverted in 50186b63d1807d389f31c515377d94185795ab44 for now. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122820/new/ https://reviews.llvm.org/D122820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D122965: Corrected A Command
smeenai added a comment. Thanks for the typo fix! Comment at: clang/test/CodeGen/c-unicode.c:5 int \uaccess = 0; // ALLOWED: "곎ss": // ALLOWED-NOT: "\uaccess": ps-19 wrote: > Comment Line No: 5 is // ALLOWED: "곎ss": i think "곎ss" in istake here, > according to google it is written in korean and i can not understand it's > meaning, but it should be made more concise and readable for more user. Given that the test is called `c-unicode.c`, I imagine it's intentional. Comment at: mypatch.patch:1 +diff --git a/llvm/utils/vim/indent/llvm.vim b/llvm/utils/vim/indent/llvm.vim +index d1d8c83d1186..75ee9ef485d4 100644 This seems like an unrelated change; can you remove it from this patch please? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122965/new/ https://reviews.llvm.org/D122965 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D123009: [Sema] Enum conversion warning when one signed and other unsigned.
red1bluelost created this revision. red1bluelost added reviewers: rsmith, lebedev.ri, aaron.ballman. Herald added a project: All. red1bluelost requested review of this revision. Herald added a project: clang. Ensures an -Wenum-conversion warning happens when one of the enums is signed and the other is unsigned. Also adds a test file to verify these warnings. This warning would not happen since the -Wsign-conversion would make a diagnostic then return, never allowing the -Wenum-conversion checks. For example: C enum PE { P = -1 }; enum NE { N }; enum NE conv(enum PE E) { return E; } Before this would only create a diagnostic with -Wsign-conversion and never on -Wenum-conversion. Now it will create a diagnostic for both -Wsign-conversion and -Wenum-conversion. I could change it to just warn on -Wenum-conversion as that was what I initially did. Seeing PR35200 (or GitHub Issue 316268), I let both diagnostics check so that the sign conversion could generate a warning. This was tested with `check-clang` and all tests passed along with the new test file. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D123009 Files: clang/lib/Sema/SemaChecking.cpp clang/test/Sema/enum-enum-conversion.c Index: clang/test/Sema/enum-enum-conversion.c === --- /dev/null +++ clang/test/Sema/enum-enum-conversion.c @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wenum-conversion -DENUM_CONV %s +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wconversion %s + +enum NE1 { N1 = -1 }; +enum NE2 { N2 = -2 }; +enum PE1 { P1 }; +enum PE2 { P2 }; + +enum PE2 f1(enum PE1 E) { +#ifdef ENUM_CONV + return E; // expected-warning {{implicit conversion from enumeration type 'enum PE1' to different enumeration type 'enum PE2'}} +#else + return E; // expected-warning {{implicit conversion from enumeration type 'enum PE1' to different enumeration type 'enum PE2'}} +#endif +} + +enum NE1 f2(enum PE1 E) { +#ifdef ENUM_CONV + return E; // expected-warning {{implicit conversion from enumeration type 'enum PE1' to different enumeration type 'enum NE1'}} +#else + return E; // expected-warning {{implicit conversion from enumeration type 'enum PE1' to different enumeration type 'enum NE1'}} expected-warning {{implicit conversion changes signedness: 'enum PE1' to 'enum NE1'}} +#endif +} + +enum PE1 f3(enum NE1 E) { +#ifdef ENUM_CONV + return E; // expected-warning {{implicit conversion from enumeration type 'enum NE1' to different enumeration type 'enum PE1'}} +#else + return E; // expected-warning {{implicit conversion from enumeration type 'enum NE1' to different enumeration type 'enum PE1'}} expected-warning {{implicit conversion changes signedness: 'enum NE1' to 'enum PE1'}} +#endif +} + +enum NE2 f4(enum NE1 E) { +#ifdef ENUM_CONV + return E; // expected-warning {{implicit conversion from enumeration type 'enum NE1' to different enumeration type 'enum NE2'}} +#else + return E; // expected-warning {{implicit conversion from enumeration type 'enum NE1' to different enumeration type 'enum NE2'}} +#endif +} \ No newline at end of file Index: clang/lib/Sema/SemaChecking.cpp === --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -13552,7 +13552,9 @@ *ICContext = true; } -return DiagnoseImpCast(S, E, T, CC, DiagID); +DiagnoseImpCast(S, E, T, CC, DiagID); +if (!isa(Target) || !isa(Source)) + return; } // Diagnose conversions between different enumeration types. Index: clang/test/Sema/enum-enum-conversion.c === --- /dev/null +++ clang/test/Sema/enum-enum-conversion.c @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wenum-conversion -DENUM_CONV %s +// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -verify -Wconversion %s + +enum NE1 { N1 = -1 }; +enum NE2 { N2 = -2 }; +enum PE1 { P1 }; +enum PE2 { P2 }; + +enum PE2 f1(enum PE1 E) { +#ifdef ENUM_CONV + return E; // expected-warning {{implicit conversion from enumeration type 'enum PE1' to different enumeration type 'enum PE2'}} +#else + return E; // expected-warning {{implicit conversion from enumeration type 'enum PE1' to different enumeration type 'enum PE2'}} +#endif +} + +enum NE1 f2(enum PE1 E) { +#ifdef ENUM_CONV + return E; // expected-warning {{implicit conversion from enumeration type 'enum PE1' to different enumeration type 'enum NE1'}} +#else + return E; // expected-warning {{implicit conversion from enumeration type 'enum PE1' to different enumeration type 'enum NE1'}} expected-warning {{implicit conversion changes signedness: 'enum PE1' to 'enum NE1'}} +#endif +} + +enum PE1 f3(enum NE1 E) { +#ifdef ENUM_CONV + return E; // expected-warning {{implicit conversion from enumeratio
[PATCH] D116203: [clang] adds unary type transformations as compiler built-ins
cjdb added a comment. I've noticed that libstdc++ has `using __remove_cv = typename remove_cv::type`, which causes Clang to chuck a wobbly. Changing from `KEYWORD` to `TYPE_TRAIT_1` didn't seem to fix anything. Is there a way we can work around this, or should we just rename `__remove_cv` and friends to something else? Comment at: clang/lib/Sema/SemaType.cpp:9227 -DiagnoseUseOfDecl(ED, Loc); + QualType Underlying = Context.getIntTypeForBitwidth( + Context.getIntWidth(BaseType), IsMakeSigned); rjmccall wrote: > cjdb wrote: > > erichkeane wrote: > > > Can you add a couple of tests to make sure this works with _BitInt? Note > > > that this + the libc++ fixes get this done: > > > https://github.com/llvm/llvm-project/issues/50427 > > Done for `_BitInt`. Is there a corresponding unsigned `_BitInt`? Neither > > `_BitUint`, `BitUInt`, nor `_UBitInt` work :( > I believe `_BitInt` works like `int` et al., so it'd be `unsigned _BitInt`, All done, thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116203/new/ https://reviews.llvm.org/D116203 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D122965: Corrected A Command
ps-19 updated this revision to Diff 420104. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D122965/new/ https://reviews.llvm.org/D122965 Files: clang/test/CodeGen/c-unicode.c Index: clang/test/CodeGen/c-unicode.c === --- clang/test/CodeGen/c-unicode.c +++ clang/test/CodeGen/c-unicode.c @@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang --target=x86_64--linug-gnu -S %s -o - | FileCheck %s -check-prefix=ALLOWED +// RUN: %clang --target=x86_64--linux-gnu -S %s -o - | FileCheck %s -check-prefix=ALLOWED // RUN: not %clang --target=x86_64--linux-gnu -std=c89 -S %s -o - 2>&1 | FileCheck %s -check-prefix=DENIED int \uaccess = 0; // ALLOWED: "곎ss": Index: clang/test/CodeGen/c-unicode.c === --- clang/test/CodeGen/c-unicode.c +++ clang/test/CodeGen/c-unicode.c @@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang --target=x86_64--linug-gnu -S %s -o - | FileCheck %s -check-prefix=ALLOWED +// RUN: %clang --target=x86_64--linux-gnu -S %s -o - | FileCheck %s -check-prefix=ALLOWED // RUN: not %clang --target=x86_64--linux-gnu -std=c89 -S %s -o - 2>&1 | FileCheck %s -check-prefix=DENIED int \uaccess = 0; // ALLOWED: "ê³ss": ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D115187: [clangd] Expose CoawaitExpr's operand in the AST
nridge created this revision. Herald added subscribers: usaxena95, kadircet, arphaman. sammccall added a comment. nridge updated this revision to Diff 407028. nridge updated this revision to Diff 420107. Herald added a project: All. nridge retitled this revision from "[WIP] [clangd] Attempted fix for issue 939" to "[clangd] Expose CoawaitExpr's operand in the AST". nridge edited the summary of this revision. nridge published this revision for review. nridge added reviewers: sammccall, kadircet. Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov. Herald added projects: clang, clang-tools-extra. FWIW I agree the "store" option would be more reliable here and also simpler - I think it's just storing one more pointer per co_await, and one we have easy access to. (I would be worried about what happens to that expression in template instantiation, but dependent CoroutineSuspendExprs only store the written form anyway, so it probably actually becomes cleaner) A change that probably goes along with this one is having RecursiveASTVisitor traverse the syntactic form instead of the semantic one if traversal of implicit code is off. nridge added a comment. Rework to store operand instead of digging it out from the common-expr nridge added a comment. (Keeping this in the WIP state for now, there's some crashiness I need to sort out) nridge added a comment. Add clang test nridge added a comment. Can't seem to reproduce the crashiness any more, so I wrote a clang test and I'm submitting this for review. I'm happy to take guidance on what the clang test should look like. What I have currently is a FileCheck test to verify that a CoawaitExpr has the expected subexpressions. I added a new file for this because the existing coroutine-related tests that I could find did not use FileCheck (they were just testing for expected-errors and such). Previously the Expr returned by getOperand() was actually the subexpression common to the "ready", "suspend", and "resume" expressions, which often isn't just the operand but e.g. await_transform() called on the operand. It's important for the AST to expose the operand as written in the source for traversals and tools like clangd to work correctly. Fixes https://github.com/clangd/clangd/issues/939 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D115187 Files: clang-tools-extra/clangd/unittests/FindTargetTests.cpp clang/include/clang/AST/ExprCXX.h clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaCoroutine.cpp clang/lib/Sema/TreeTransform.h clang/test/SemaCXX/co_await-ast.cpp Index: clang/test/SemaCXX/co_await-ast.cpp === --- /dev/null +++ clang/test/SemaCXX/co_await-ast.cpp @@ -0,0 +1,97 @@ +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -ast-dump -ast-dump-filter=foo %s | FileCheck %s --strict-whitespace + +namespace std { +template struct coroutine_traits; +template struct coroutine_handle { + template + coroutine_handle(coroutine_handle &&) noexcept; + static coroutine_handle from_address(void *__addr) noexcept; +}; +} // namespace std + +struct executor {}; +struct awaitable {}; +struct awaitable_frame { + awaitable get_return_object(); + void return_void(); + void unhandled_exception(); + struct result_t { +~result_t(); +bool await_ready() const noexcept; +void await_suspend(std::coroutine_handle) noexcept; +void await_resume() const noexcept; + }; + result_t initial_suspend() noexcept; + result_t final_suspend() noexcept; + result_t await_transform(executor) noexcept; +}; + +namespace std { +template <> +struct coroutine_traits { + typedef awaitable_frame promise_type; +}; +} // namespace std + +awaitable foo() { + co_await executor(); +} + +// Check that CoawaitExpr contains the correct subexpressions, including +// the operand expression as written in the source. + +// CHECK-LABEL: Dumping foo: +// CHECK: FunctionDecl {{.*}} foo 'awaitable ()' +// CHECK: `-CoroutineBodyStmt {{.*}} +// CHECK: |-CompoundStmt {{.*}} +// CHECK: | `-ExprWithCleanups {{.*}} 'void' +// CHECK: | `-CoawaitExpr {{.*}} 'void' +// CHECK: | |-CXXTemporaryObjectExpr {{.*}} 'executor' 'void () noexcept' zeroing +// CHECK: | |-MaterializeTemporaryExpr {{.*}} 'awaitable_frame::result_t' lvalue +// CHECK: | | `-CXXBindTemporaryExpr {{.*}} 'awaitable_frame::result_t' (CXXTemporary {{.*}}) +// CHECK: | | `-CXXMemberCallExpr {{.*}} 'awaitable_frame::result_t' +// CHECK: | | |-MemberExpr {{.*}} '' .await_transform {{.*}} +// CHECK: | | | `-DeclRefExpr {{.*}} 'std::coroutine_traits::promise_type':'awaitable_frame' lvalue Var {{.*}} '__promise' 'std::coroutine_traits::promise_type':'awaitable_frame' +// CHECK: | | `-CXXTemporaryObjectExpr {{.*}} 'executor' 'void () noexcept' zeroing +// CHECK: | |-ExprWithCleanups {{.*}} 'bool' +// CHECK: | | `-CXXMemberCallExpr {{.*}} 'bool' +//