[clang] [clang-format] Don't remove parentheses in macro definitions (PR #81444)

2024-02-11 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/81444 Closes #81399. >From 9d91878e9cb65ab67de8251976ee748ed03fc2b6 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sun, 11 Feb 2024 23:28:25 -0800 Subject: [PATCH] [clang-format] Don't remove parentheses in macro defini

[clang] f5d71b7 - Reland "[clang-format][NFC] Make LangOpts global in namespace Format (#81390)"

2024-02-12 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2024-02-12T00:04:34-08:00 New Revision: f5d71b79fe978f1e70f4a41adfd15f65dec6e210 URL: https://github.com/llvm/llvm-project/commit/f5d71b79fe978f1e70f4a41adfd15f65dec6e210 DIFF: https://github.com/llvm/llvm-project/commit/f5d71b79fe978f1e70f4a41adfd15f65dec6e210.diff LOG:

[clang] 33108fa - Reverted due to wrong commit message

2024-02-12 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2024-02-12T00:07:47-08:00 New Revision: 33108fae9020cb49577fc3ee0aed219cc581f82a URL: https://github.com/llvm/llvm-project/commit/33108fae9020cb49577fc3ee0aed219cc581f82a DIFF: https://github.com/llvm/llvm-project/commit/33108fae9020cb49577fc3ee0aed219cc581f82a.diff LOG:

[clang] 7f40c5c - Reland "[clang-format] Update FormatToken::isSimpleTypeSpecifier() (#80241)"

2024-02-12 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2024-02-12T00:10:24-08:00 New Revision: 7f40c5cc4e15a0a67b031f13370afc342a5dc14b URL: https://github.com/llvm/llvm-project/commit/7f40c5cc4e15a0a67b031f13370afc342a5dc14b DIFF: https://github.com/llvm/llvm-project/commit/7f40c5cc4e15a0a67b031f13370afc342a5dc14b.diff LOG:

[clang] [clang-format] Rename option AlwaysBreakAfterReturnType. (PR #80827)

2024-02-12 Thread Owen Pan via cfe-commits
@@ -677,6 +677,23 @@ TEST(ConfigParseTest, ParsesConfiguration) { " AfterControlStatement: false", BraceWrapping.AfterControlStatement, FormatStyle::BWACS_Never); + Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_All; + CHECK_PARSE("BreakAft

[clang] [clang-format] Don't remove parentheses in macro definitions (PR #81444)

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

[clang] [clang-format] Don't remove parentheses in macro definitions (PR #81444)

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

[clang] [clang-format] Don't remove parentheses in macro definitions (PR #81444)

2024-02-12 Thread Owen Pan via cfe-commits
owenca wrote: /cherry-pick 4af24d4ab765 https://github.com/llvm/llvm-project/pull/81444 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Don't remove parentheses in macro definitions (PR #81444)

2024-02-12 Thread Owen Pan via cfe-commits
owenca wrote: > Any hope that this lands in 18.1? Thanks anyway! Most likely. https://github.com/llvm/llvm-project/pull/81444 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Rename option AlwaysBreakAfterReturnType. (PR #80827)

2024-02-12 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/80827 >From 3c3e167711dccfcc0a56c5b465b20c17854451a4 Mon Sep 17 00:00:00 2001 From: rmarker Date: Tue, 6 Feb 2024 21:53:20 +1030 Subject: [PATCH 1/2] [clang-format] Rename option AlwaysBreakAfterReturnType. --- clang/

[clang] [clang-format] Rename option AlwaysBreakAfterReturnType. (PR #80827)

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

[clang] [clang-format] Rename option AlwaysBreakAfterReturnType. (PR #80827)

2024-02-12 Thread Owen Pan via cfe-commits
owenca wrote: Feel free to open another PR if you're interested. πŸ™‚ https://github.com/llvm/llvm-project/pull/80827 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Always insert a space between #if and l_paren (PR #81578)

2024-02-13 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/81578 Fixes #81569. >From 2292ccb78839a90a15215b11c473fcbfc47aa00c Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 13 Feb 2024 00:03:19 -0800 Subject: [PATCH] [clang-format] Always insert a space between #if and l_p

[clang] [clang-format] Always insert a space between #if and l_paren (PR #81578)

2024-02-13 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/81578 >From 02d2d44046a4cf6ca8c5bb1897b6677c01d81974 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 13 Feb 2024 00:03:19 -0800 Subject: [PATCH] [clang-format] Always add a space after #if and #elif Fixes #81569. --

[clang] [clang-format] Always add a space after #if and #elif (PR #81578)

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

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-05 Thread Owen Pan via cfe-commits
@@ -71,8 +71,21 @@ bool FormatToken::isSimpleTypeSpecifier() const { } } -bool FormatToken::isTypeOrIdentifier() const { - return isSimpleTypeSpecifier() || Tok.isOneOf(tok::kw_auto, tok::identifier); +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywor

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-05 Thread Owen Pan via cfe-commits
@@ -268,20 +268,24 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeRight( if (isPossibleMacro(TypeToken)) return Tok; + const bool IsCpp = Style.isCpp(); + // The case `const long long int volatile` -> `long long int const volatile` // The case `lo

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-05 Thread Owen Pan via cfe-commits
@@ -620,6 +620,23 @@ TEST_F(TokenAnnotatorTest, UnderstandsCasts) { ASSERT_EQ(Tokens.size(), 8u) << Tokens; EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_Unknown); EXPECT_TOKEN(Tokens[4], tok::amp, TT_BinaryOperator); + + Tokens = annotate("#define FOO(bar) foo((uint64_t)&bar

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-05 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/83709 >From 91d6e4c6e0ae2e1d79edf496df22978a4e1f3e1a Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 2 Mar 2024 22:08:29 -0800 Subject: [PATCH 1/6] [clang-format] Handle common C++ non-keyword types as such Fixes #

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-08 Thread Owen Pan via cfe-commits
owenca wrote: > Can the TypeNames mechanism be prepopulated with this list of types instead? I don't see how that would work. Please note that the TypeNames option is not specific to C/C++/Objective-C. Otherwise, I could simply change `isTypeName(bool IsCpp)` to `isCppTypeName()`. https://git

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-08 Thread Owen Pan via cfe-commits
owenca wrote: > Just thinking out loud and maybe not for this patch but for a more general > solution, what we seem to never do is collect information about types local > to the file as we go; For example what if a first pass identified types from > declarations and function argument declarati

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

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

[clang] [clang-format][NFC] Eliminate the IsCpp parameter in all functions (PR #84599)

2024-03-08 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/84599 None >From bd3e866189ad4c238ea0afbbc30fbe88e0406eb9 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 8 Mar 2024 19:47:54 -0800 Subject: [PATCH] [clang-format][NFC] Eliminate the IsCpp parameter in all function

[clang] [clang-format][NFC] Eliminate the IsCpp parameter in all functions (PR #84599)

2024-03-08 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/84599 >From 43238d58ff490073c13ff621faddceb89b05b22e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 8 Mar 2024 19:47:54 -0800 Subject: [PATCH] [clang-format][NFC] Eliminate the IsCpp parameter in all functions ---

[clang] [clang-format] Fix a bug in annotating function declaration names (PR #76206)

2024-03-09 Thread Owen Pan via cfe-commits
owenca wrote: > Thanks for doing this. Does it mean we would have to add every type we use to > our config? It would be much more convenient if clang-format treated the > argument list the same way that it treats in definitions. For example > > ```shell > printf "int\niso_time(time_t) { return

[clang] [clang-format][NFC] Eliminate the IsCpp parameter in all functions (PR #84599)

2024-03-09 Thread Owen Pan via cfe-commits
owenca wrote: > That's okay for clang-format, but you couldn't use libFormat with different > languages at once anymore. I believe we still could because `IsCpp` is set to `Style.isCpp()` every time new instances of the classes are constructed. I'll add a couple of test cases to demonstrate t

[clang] [clang-format][NFC] Eliminate the IsCpp parameter in all functions (PR #84599)

2024-03-09 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/84599 >From 43238d58ff490073c13ff621faddceb89b05b22e Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 8 Mar 2024 19:47:54 -0800 Subject: [PATCH 1/2] [clang-format][NFC] Eliminate the IsCpp parameter in all functions

[clang] [clang-format][NFC] Eliminate the IsCpp parameter in all functions (PR #84599)

2024-03-10 Thread Owen Pan via cfe-commits
owenca wrote: > Then I'd go back to `Style.isCpp()`. That would still require passing `Style.isCpp()` as the parameter to the `FormatToken` (and other) functions. > What happens if you use libFormat concurrently? Can you elaborate? Doesn't each process get its own copy of the globals of a sh

[clang] [clang-format][NFC] Eliminate the IsCpp parameter in all functions (PR #84599)

2024-03-11 Thread Owen Pan via cfe-commits
owenca wrote: > I mean multiple threads in the same process with different languages. maybe > unlikely, but not impossible. But libFormat/clang-format are _not_ multithreaded, right? https://github.com/llvm/llvm-project/pull/84599 ___ cfe-commits mai

[clang] [clang-format][NFC] Enable RemoveSemicolon for clang-format style (PR #82735)

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

[clang] [clang-format] Add a parameter to getStyle() and guessLanguage() (PR #82911)

2024-02-25 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/82911 Add a boolean parameter GuessObjC that defaults to true. This allows e.g. clangd to bypass ObjCHeaderStyleGuesser.process() by passing false for the parameter. >From bd85fd1dff5ac7b72913ed175daec3809896e6c0 Mon Se

[clang] [clang-format] Limit how much work guessLanguage() can do (PR #78925)

2024-02-25 Thread Owen Pan via cfe-commits
owenca wrote: @HighCommander4 see #82911 https://github.com/llvm/llvm-project/pull/78925 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] 085f9b0 - [clang-format][doc] Update documentation for RemoveSemicolon

2024-02-25 Thread Owen Pan via cfe-commits
Author: Owen Pan Date: 2024-02-25T16:08:37-08:00 New Revision: 085f9b0d146fc99bbb0e193593aad696fc50a056 URL: https://github.com/llvm/llvm-project/commit/085f9b0d146fc99bbb0e193593aad696fc50a056 DIFF: https://github.com/llvm/llvm-project/commit/085f9b0d146fc99bbb0e193593aad696fc50a056.diff LOG:

[clang] [clang-format][NFC] Skip ObjCHeaderStyleGuesser for empty code (PR #82957)

2024-02-25 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/82957 None >From 9334d008b4c7ae13fdeb674a6bb9b4dc62c6a1dd Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sun, 25 Feb 2024 20:58:25 -0800 Subject: [PATCH] [clang-format][NFC] Skip ObjCHeaderStyleGuesser for empty code

[clang] [clang-format] Limit how much work guessLanguage() can do (PR #78925)

2024-02-25 Thread Owen Pan via cfe-commits
owenca wrote: @HighCommander4 I got a better idea. It seems that we don't need to add the parameter! See #82957. I think all you need to do is to call `getStyle()` with the default `""` for the `StringRef Code` argument to skip the Objective-C guesser. https://github.com/llvm/llvm-project/pul

[clang] [clang-format] Add a parameter to getStyle() and guessLanguage() (PR #82911)

2024-02-25 Thread Owen Pan via cfe-commits
https://github.com/owenca converted_to_draft https://github.com/llvm/llvm-project/pull/82911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format] Add a parameter to getStyle() and guessLanguage() (PR #82911)

2024-02-25 Thread Owen Pan via cfe-commits
owenca wrote: I will abandon this pull request if #82957 gets approved. https://github.com/llvm/llvm-project/pull/82911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-format][NFC] Skip ObjCHeaderStyleGuesser for empty code (PR #82957)

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

[clang] [clang-format] Add a parameter to getStyle() and guessLanguage() (PR #82911)

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

[clang] [clang-format] Limit how much work guessLanguage() can do (PR #78925)

2024-02-26 Thread Owen Pan via cfe-commits
owenca wrote: > > @HighCommander4 I got a better idea. It seems that we don't need to add the > > parameter! See #82957. I think all you need to do is to call `getStyle()` > > with the default `""` for the `StringRef Code` argument to skip the > > Objective-C guesser. > > Thanks. That does se

[clang] [clang-format] Enable again some operator tests (PR #83380)

2024-02-29 Thread Owen Pan via cfe-commits
@@ -16671,9 +16667,8 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) { SpaceFuncDecl); verifyFormat("int f () throw(Deprecated);", SpaceFuncDecl); verifyFormat("typedef void (*cb)(int);", SpaceFuncDecl); - // FIXME these tests regressed behaviour. - //

[clang] [clang-format] Enable again some operator tests (PR #83380)

2024-02-29 Thread Owen Pan via cfe-commits
@@ -16797,7 +16792,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) { verifyFormat("int f() throw (Deprecated);", SomeSpace2); verifyFormat("typedef void (*cb) (int);", SomeSpace2); verifyFormat("T A::operator()();", SomeSpace2); - // verifyFormat("X A::operator++

[clang] [clang-format] Enable again some operator tests (PR #83380)

2024-02-29 Thread Owen Pan via cfe-commits
@@ -16710,7 +16705,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) { verifyFormat("typedef void (*cb)(int);", SpaceFuncDef); verifyFormat("T A::operator()();", SpaceFuncDef); verifyFormat("X A::operator++(T);", SpaceFuncDef); - // verifyFormat("T A::operator() ()

[clang] [clang-format] Enable again some operator tests (PR #83380)

2024-02-29 Thread Owen Pan via cfe-commits
@@ -16797,7 +16792,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) { verifyFormat("int f() throw (Deprecated);", SomeSpace2); verifyFormat("typedef void (*cb) (int);", SomeSpace2); verifyFormat("T A::operator()();", SomeSpace2); - // verifyFormat("X A::operator++

[clang] [clang-format] Enable again some operator tests (PR #83380)

2024-02-29 Thread Owen Pan via cfe-commits
@@ -16671,9 +16667,8 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) { SpaceFuncDecl); verifyFormat("int f () throw(Deprecated);", SpaceFuncDecl); verifyFormat("typedef void (*cb)(int);", SpaceFuncDecl); - // FIXME these tests regressed behaviour. - //

[clang] [clang-format] Enable again some operator tests (PR #83380)

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

[clang] [clang-format] Enable again some operator tests (PR #83380)

2024-02-29 Thread Owen Pan via cfe-commits
@@ -16710,7 +16705,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) { verifyFormat("typedef void (*cb)(int);", SpaceFuncDef); verifyFormat("T A::operator()();", SpaceFuncDef); verifyFormat("X A::operator++(T);", SpaceFuncDef); - // verifyFormat("T A::operator() ()

[clang] [clang-format] Enable again some operator tests (PR #83380)

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

[clang] [clang-format][NFC] Replace Style.isCpp() with IsCpp (PR #83533)

2024-02-29 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/83533 None >From a643963e818a9c6c4abea93c15f8c48f7291a837 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Thu, 29 Feb 2024 23:07:58 -0800 Subject: [PATCH] [clang-format][NFC] Replace Style.isCpp() with IsCpp --- clang/

[clang] [clang][Documentation] fix documentation for clang-format (PR #83415)

2024-02-29 Thread Owen Pan via cfe-commits
owenca wrote: Hi, you need to edit `clang/include/clang/Format/Format.h` and then run `clang/docs/tools/dump_format_style.py` to regenerate `clang/docs/ClangFormatStyleOptions.rst`. https://github.com/llvm/llvm-project/pull/83415 ___ cfe-commits mail

[clang] [clang-format][doc] fix documentation for clang-format (PR #83415)

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

[clang] [clang-format][NFC] Replace Style.isCpp() with IsCpp (PR #83533)

2024-03-01 Thread Owen Pan via cfe-commits
owenca wrote: > The question is: why? And why handle c++ different than all other languages? This is the preparation for fixing/extending `FormatToken::isSimpleTypeSpecifier()`, which I'll add a couple of parameters to, e.g. `isSimpleTypeSpecifier(bool IsCpp, const LangOptions &LangOpts)`. Al

[clang] [clang-format][NFC] Replace Style.isCpp() with IsCpp (PR #83533)

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

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-02 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/83709 Fixes #83400. >From 91d6e4c6e0ae2e1d79edf496df22978a4e1f3e1a Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 2 Mar 2024 22:08:29 -0800 Subject: [PATCH] [clang-format] Handle common C++ non-keyword types as suc

[clang] [clang-format][doc] fix documentation for clang-format (PR #83415)

2024-03-02 Thread Owen Pan via cfe-commits
owenca wrote: > So I did added a simple search and replace to the generating script so now > every time [[[NAME]]] is reference it will use the members name. Nice! Though why `[[[NAME]]]` in particular? Can we use `` instead? https://github.com/llvm/llvm-project/pull/83415

[clang] [clang-format][doc] fix documentation for clang-format (PR #83415)

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

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/83709 >From 91d6e4c6e0ae2e1d79edf496df22978a4e1f3e1a Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 2 Mar 2024 22:08:29 -0800 Subject: [PATCH 1/2] [clang-format] Handle common C++ non-keyword types as such Fixes #

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
@@ -66,13 +72,17 @@ bool FormatToken::isSimpleTypeSpecifier() const { case tok::kw_decltype: case tok::kw__Atomic: return true; + case tok::identifier: +return IsCpp && std::binary_search(CppNonKeywordTypes.begin(), + CppNonKey

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

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

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
owenca wrote: > Another possibility to consider for the original bug: `(single_identifier)` > is almost certainly a cast, not redundant parentheses, unless > `single_identifier` names a macro argument. So I wonder if that would be a > better heuristic to use to fix the regression. I don’t thi

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
owenca wrote: > > > Another possibility to consider for the original bug: > > > `(single_identifier)` is almost certainly a cast, not redundant > > > parentheses, unless `single_identifier` names a macro argument. So I > > > wonder if that would be a better heuristic to use to fix the regressi

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", owenca wrote: Good point abo

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
owenca wrote: > > This patch does not only fix formatting of C-casting to a C++ standard > > type. It correctly identifies (most of) such types and might have fixed > > other kinds of bugs. > > Sure, this patch seems like a good change. But it does not fix #83400. It does fix the example give

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
owenca wrote: > But looking for a parenthesized single identifier addresses all of the > examples in the issue. I don't think it would work, but you are welcome to submit a patch to prove me wrong. πŸ™‚ https://github.com/llvm/llvm-project/pull/83709

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
@@ -34,9 +34,15 @@ const char *getTokenTypeName(TokenType Type) { return nullptr; } +// Sorted common C++ non-keyword types. +static SmallVector CppNonKeywordTypes = { +"byte", "int16_t", "int32_t", "int64_t", "int8_t", +"size_t", "uint16_t", "uint32_t", "uint64

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/83709 >From 91d6e4c6e0ae2e1d79edf496df22978a4e1f3e1a Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 2 Mar 2024 22:08:29 -0800 Subject: [PATCH 1/3] [clang-format] Handle common C++ non-keyword types as such Fixes #

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/83709 >From 91d6e4c6e0ae2e1d79edf496df22978a4e1f3e1a Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 2 Mar 2024 22:08:29 -0800 Subject: [PATCH 1/4] [clang-format] Handle common C++ non-keyword types as such Fixes #

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-03 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/83709 >From 91d6e4c6e0ae2e1d79edf496df22978a4e1f3e1a Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Sat, 2 Mar 2024 22:08:29 -0800 Subject: [PATCH 1/5] [clang-format] Handle common C++ non-keyword types as such Fixes #

[clang] [clang-format][doc] fix documentation for clang-format (PR #83415)

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

[clang] [clang-format] Handle common C++ non-keyword types as such (PR #83709)

2024-03-05 Thread Owen Pan via cfe-commits
owenca wrote: > > It does fix the example given. > > #83400 has 6 real-world examples. This patch fixes none of them. It also has > a reduced testcase, which this patch does fix. But fixing the reduced > testcase without fixing the real-world examples is not fixing the bug. You took what I sa

[clang] [clang-format] Explicitly open DOC_FILE with utf-8 in dump_format_style.py (PR #79805)

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

[clang] [clang-format] Explicitly open DOC_FILE with utf-8 in dump_format_style.py (PR #79805)

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

[clang] [clang-format] Handles Elaborated type specifier for enum in trailing return (PR #80085)

2024-01-30 Thread Owen Pan via cfe-commits
@@ -1760,8 +1760,8 @@ void UnwrappedLineParser::parseStructuralElement( break; } case tok::kw_enum: - // Ignore if this is part of "template is(tok::less)) { + // Ignore if this is part of "template enum". + if (Previous && (Previous->is(tok::less)

[polly] [clang] [clang-format] Add AllowShortType and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-30 Thread Owen Pan via cfe-commits
owenca wrote: > Let's leave `None` alone and add `ExceptShortType` I meant to add `ExceptShortType` instead of `AllowShortType`. Sorry I didn't realize that adding `AllowShortType` and making it to mean "not `None`" might work, in which case we don't need to add `ExceptShortType`. https://git

[flang] [libcxx] [compiler-rt] [llvm] [clang] [libc] [clang] Improved isSimpleTypeSpecifier (PR #79037)

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

[clang] [clang-format] Handles Elaborated type specifier for enum in trailing return (PR #80085)

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

[clang] [clang][NFC] Move isSimpleTypeSpecifier() from Sema to Token (PR #80101)

2024-01-30 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/80101 So that it can be used by clang-format. >From f3ad3ceebba663615e75b5a6fc8969f4a98a03ea Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 30 Jan 2024 19:11:30 -0800 Subject: [PATCH] [clang][NFC] Move isSimpleType

[clang] [clang-format] Update FormatToken::isSimpleTypeSpecifier() (PR #79115)

2024-01-30 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/79115 >From f3ad3ceebba663615e75b5a6fc8969f4a98a03ea Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 30 Jan 2024 19:11:30 -0800 Subject: [PATCH] [clang][NFC] Move isSimpleTypeSpecifier() from Sema to Token So that i

[clang] [clang-format] Update FormatToken::isSimpleTypeSpecifier() (PR #79115)

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

[clang] [clang-format] Update FormatToken::isSimpleTypeSpecifier() (PR #79115)

2024-01-30 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/79115 >From f3ad3ceebba663615e75b5a6fc8969f4a98a03ea Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 30 Jan 2024 19:11:30 -0800 Subject: [PATCH 1/2] [clang][NFC] Move isSimpleTypeSpecifier() from Sema to Token So t

[clang] [clang][NFC] Move isSimpleTypeSpecifier() from Sema to Token (PR #80101)

2024-01-31 Thread Owen Pan via cfe-commits
https://github.com/owenca updated https://github.com/llvm/llvm-project/pull/80101 >From f3ad3ceebba663615e75b5a6fc8969f4a98a03ea Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Tue, 30 Jan 2024 19:11:30 -0800 Subject: [PATCH 1/2] [clang][NFC] Move isSimpleTypeSpecifier() from Sema to Token So t

[clang] [clang][NFC] Move isSimpleTypeSpecifier() from Sema to Token (PR #80101)

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

[clang] [clang-format] Simplify the AfterPlacementOperator option (PR #79796)

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

[clang] [clang-format] Update FormatToken::isSimpleTypeSpecifier() (PR #80241)

2024-01-31 Thread Owen Pan via cfe-commits
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/80241 Now with a8279a8bc541, we can make the update. >From fda19165bc1195be01159c7d071839822ff3f929 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Wed, 31 Jan 2024 20:43:29 -0800 Subject: [PATCH] [clang-format] Update F

[clang] [clang-format] Update FormatToken::isSimpleTypeSpecifier() (PR #79115)

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

[clang] [clang-format] Update FormatToken::isSimpleTypeSpecifier() (PR #79115)

2024-01-31 Thread Owen Pan via cfe-commits
owenca wrote: See #80241. https://github.com/llvm/llvm-project/pull/79115 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[polly] [clang] [clang-format] Add AllowShortType and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-31 Thread Owen Pan via cfe-commits
owenca wrote: > Now that we've got both options, should we keep them? Currently, `None` > sometimes forbids breaking after short return types and sometimes allows it > and just bases things off the penalty configuration. I feel like there will > be some people who use `None` who would want the

[polly] [clang] [clang-format] Add AllowShortType and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-31 Thread Owen Pan via cfe-commits
@@ -922,8 +922,39 @@ struct FormatStyle { /// }; /// int f(); /// int f() { return 1; } +/// int LongName:: +/// AnotherLongName(); /// \endcode RTBS_None, +/// Break after return type automatically. +/// This mode doesn't hav

[clang] [polly] [clang-format] Add AllowShortType and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

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

[clang] [polly] [clang-format] Add AllowShortType and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-31 Thread Owen Pan via cfe-commits
@@ -922,8 +922,39 @@ struct FormatStyle { /// }; /// int f(); /// int f() { return 1; } +/// int LongName:: +/// AnotherLongName(); /// \endcode owenca wrote: Change the comments (lines 917-927) to something like the foll

[polly] [clang] [clang-format] Add AllowShortType and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-31 Thread Owen Pan via cfe-commits
@@ -922,8 +922,39 @@ struct FormatStyle { /// }; /// int f(); /// int f() { return 1; } +/// int LongName:: +/// AnotherLongName(); /// \endcode RTBS_None, +/// Break after return type automatically. +/// This mode doesn't hav

[clang] [polly] [clang-format] Add AllowShortType and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-31 Thread Owen Pan via cfe-commits
https://github.com/owenca commented: There is no need to update the release notes for new option values. https://github.com/llvm/llvm-project/pull/78011 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/list

[clang] [polly] [clang-format] Add AllowShortType and ExceptShortType options for AlwaysBreakAfterReturnType. (PR #78011)

2024-01-31 Thread Owen Pan via cfe-commits
@@ -922,8 +922,39 @@ struct FormatStyle { /// }; /// int f(); /// int f() { return 1; } +/// int LongName:: +/// AnotherLongName(); /// \endcode RTBS_None, +/// Break after return type automatically. +/// This mode doesn't hav

[clang] [clang-format] Allow decltype in requires clause (PR #78847)

2024-01-31 Thread Owen Pan via cfe-commits
owenca wrote: Should we merge this patch? https://github.com/llvm/llvm-project/pull/78847 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

<    1   2   3   4   5   6   7   8   9   10   >