[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-21 Thread LLVM Continuous Integration via cfe-commits
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-clang-aarch64-darwin` running on `doug-worker-4` while building `clang` at step 2 "checkout". Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/11848 Here is the relevant piece of the bu

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-21 Thread via cfe-commits
github-actions[bot] wrote: @amane-ame Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a buil

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-21 Thread Owen Pan via cfe-commits
https://github.com/owenca closed https://github.com/llvm/llvm-project/pull/119428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-21 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119428 From 3a4c1a924faef3a7a09126694fcb943bd7083451 Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 02:13:43 +0800 Subject: [PATCH 1/7] Fix crashes when the macro expansion is empty --- clang/lib/F

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-21 Thread Owen Pan via cfe-commits
https://github.com/owenca approved this pull request. https://github.com/llvm/llvm-project/pull/119428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-21 Thread Owen Pan via cfe-commits
https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/119428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-21 Thread Owen Pan via cfe-commits
@@ -217,6 +219,31 @@ TEST_F(MacroCallReconstructorTest, Identifier) { EXPECT_THAT(std::move(Unexp).takeResult(), matchesLine(line(U.consume("X"; } +TEST_F(MacroCallReconstructorTest, IdentifierObject) { owenca wrote: How about`EmptyDefinition` instead

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-21 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119428 From 3a4c1a924faef3a7a09126694fcb943bd7083451 Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 02:13:43 +0800 Subject: [PATCH 1/6] Fix crashes when the macro expansion is empty --- clang/lib/F

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-21 Thread via cfe-commits
@@ -0,0 +1,5 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style="{Macros: [A(x)=x]}" \ +// RUN: | FileCheck -strict-whitespace %s + +// CHECK: A() +A() amane-ame wrote: Sorry for misunderstood. https://github.com/llvm/llvm-project/pull/119428 ___

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-20 Thread Owen Pan via cfe-commits
@@ -0,0 +1,5 @@ +// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style="{Macros: [A(x)=x]}" \ +// RUN: | FileCheck -strict-whitespace %s + +// CHECK: A() +A() owenca wrote: Don't add a lit test. Instead, add a unittest similar to the one you already added

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-20 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119428 From 3a4c1a924faef3a7a09126694fcb943bd7083451 Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 02:13:43 +0800 Subject: [PATCH 1/6] Fix crashes when the macro expansion is empty --- clang/lib/F

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-20 Thread Owen Pan via cfe-commits
https://github.com/owenca commented: Please add a test case for https://github.com/llvm/llvm-project/issues/119258#issue-2728126922. https://github.com/llvm/llvm-project/pull/119428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-20 Thread Björn Schäpers via cfe-commits
@@ -233,6 +233,10 @@ MacroExpander::expand(FormatToken *ID, if (Result.size() > 1) { ++Result[0]->MacroCtx->StartOfExpansion; ++Result[Result.size() - 2]->MacroCtx->EndOfExpansion; + } else { +// If the macro expansion is empty, mark the start and end ---

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-19 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119428 From 3a4c1a924faef3a7a09126694fcb943bd7083451 Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 02:13:43 +0800 Subject: [PATCH 1/4] Fix crashes when the macro expansion is empty --- clang/lib/F

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-18 Thread Owen Pan via cfe-commits
@@ -217,6 +217,19 @@ TEST_F(MacroCallReconstructorTest, Identifier) { EXPECT_THAT(std::move(Unexp).takeResult(), matchesLine(line(U.consume("X"; } +TEST_F(MacroCallReconstructorTest, EmptyExpansion) { + auto Macros = createExpander({"A(x)=y"}); owenca

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-16 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119428 From 3a4c1a924faef3a7a09126694fcb943bd7083451 Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 02:13:43 +0800 Subject: [PATCH 1/3] Fix crashes when the macro expansion is empty --- clang/lib/F

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-15 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff f4081711f0884ec7afe93577e118ecc89cb7b1cf 1e79973ed4ea56c66f8b7eb1db9d00784edac7f0 --e

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-15 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119428 From 3a4c1a924faef3a7a09126694fcb943bd7083451 Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 02:13:43 +0800 Subject: [PATCH 1/3] Fix crashes when the macro expansion is empty --- clang/lib/F

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-15 Thread Owen Pan via cfe-commits
owenca wrote: You should add unit tests in `clang/unittests/Format/`. https://github.com/llvm/llvm-project/pull/119428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-14 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119428 From 3a4c1a924faef3a7a09126694fcb943bd7083451 Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 02:13:43 +0800 Subject: [PATCH 1/2] Fix crashes when the macro expansion is empty --- clang/lib/F

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-14 Thread Owen Pan via cfe-commits
owenca wrote: Please add unit tests. https://github.com/llvm/llvm-project/pull/119428 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-10 Thread via cfe-commits
https://github.com/amane-ame updated https://github.com/llvm/llvm-project/pull/119428 From 3a4c1a924faef3a7a09126694fcb943bd7083451 Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed, 11 Dec 2024 02:13:43 +0800 Subject: [PATCH] Fix crashes when the macro expansion is empty --- clang/lib/Forma

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-10 Thread via cfe-commits
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-10 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-format Author: 天音あめ (amane-ame) Changes An empty expansion should be valid, like `echo 'A()' | clang-format --style='{Macros: [A(x)=x]}'` See #119258. --- Full diff: https://github.com/llvm/llvm-project/pull/119428.diff 1 Files Affected: - (mo

[clang] [clang-format] Fix crashes when the macro expansion is empty (PR #119428)

2024-12-10 Thread via cfe-commits
https://github.com/amane-ame created https://github.com/llvm/llvm-project/pull/119428 An empty expansion should be valid, like `echo 'A()' | clang-format --style='{Macros: [A(x)=x]}'` See #119258. From 3a4c1a924faef3a7a09126694fcb943bd7083451 Mon Sep 17 00:00:00 2001 From: amane-ame Date: Wed