[clang] [libcxx] [clang] Add -Wuninitialized-const-pointer (PR #148337)

2025-07-12 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. https://github.com/llvm/llvm-project/pull/148337 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix suppressing diagnostics for uninitialized variables (PR #148336)

2025-07-12 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. https://github.com/llvm/llvm-project/pull/148336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Fix pointer comparisons between pointers to constexpr-unknown (PR #147663)

2025-07-11 Thread Richard Smith via cfe-commits
@@ -14544,6 +14538,23 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E, (LHSValue.Base && isZeroSized(RHSValue))) return DiagComparison( diag::note_constexpr_pointer_comparison_zero_sized); + // A constexpr-unknown

[clang] [clang] Combine ConstRefUse with other warnings for uninitialized values (PR #147898)

2025-07-10 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Thanks! https://github.com/llvm/llvm-project/pull/147898 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Combine ConstRefUse with other warnings for uninitialized values (PR #147898)

2025-07-10 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. https://github.com/llvm/llvm-project/pull/147898 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Combine ConstRefUse with other warnings for uninitialized values (PR #147898)

2025-07-10 Thread Richard Smith via cfe-commits
@@ -1580,13 +1570,21 @@ class UninitValsDiagReporter : public UninitVariablesHandler { // guaranteed to produce them in line/column order, this will provide // a stable ordering. llvm::sort(*vec, [](const UninitUse &a, const UninitUse &b) { + /

[clang] [clang] Combine ConstRefUse with other warnings for uninitialized values (PR #147898)

2025-07-10 Thread Richard Smith via cfe-commits
@@ -27,7 +27,7 @@ int const_use(const int i); void f(int a) { int i; const_ref_use(i); // expected-warning {{variable 'i' is uninitialized when passed as a const reference argument here}} - int j = j + const_ref_use(j); // expected-warning {{variable 'j' is u

[clang] [clang] Combine ConstRefUse with other warnings for uninitialized values (PR #147898)

2025-07-10 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Thanks, LGTM https://github.com/llvm/llvm-project/pull/147898 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Combine ConstRefUse with other warnings for uninitialized values (PR #147898)

2025-07-10 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/147898 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)

2025-07-07 Thread Richard Smith via cfe-commits
@@ -453,7 +450,7 @@ void ClassifyRefs::VisitCallExpr(CallExpr *CE) { const auto *UO = dyn_cast(Ex); if (UO && UO->getOpcode() == UO_AddrOf) Ex = UO->getSubExpr(); - classify(Ex, Ignore); + classify(Ex, Use); zygoloid wrote: > Your

[clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)

2025-07-07 Thread Richard Smith via cfe-commits
@@ -453,7 +450,7 @@ void ClassifyRefs::VisitCallExpr(CallExpr *CE) { const auto *UO = dyn_cast(Ex); if (UO && UO->getOpcode() == UO_AddrOf) Ex = UO->getSubExpr(); - classify(Ex, Ignore); + classify(Ex, Use); zygoloid wrote: That s

[clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)

2025-07-07 Thread Richard Smith via cfe-commits
https://github.com/zygoloid requested changes to this pull request. https://github.com/llvm/llvm-project/pull/147221 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libcxx] [clang] Fix -Wuninitialized for values passed by const pointers (PR #147221)

2025-07-07 Thread Richard Smith via cfe-commits
@@ -453,7 +450,7 @@ void ClassifyRefs::VisitCallExpr(CallExpr *CE) { const auto *UO = dyn_cast(Ex); if (UO && UO->getOpcode() == UO_AddrOf) Ex = UO->getSubExpr(); - classify(Ex, Ignore); + classify(Ex, Use); zygoloid wrote: I beli

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-07-01 Thread Richard Smith via cfe-commits
https://github.com/zygoloid closed https://github.com/llvm/llvm-project/pull/130369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-30 Thread Richard Smith via cfe-commits
https://github.com/zygoloid updated https://github.com/llvm/llvm-project/pull/130369 >From 78c9d5da85723040c30f00cb53e77c9dd4cc14b8 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 7 Mar 2025 22:49:37 + Subject: [PATCH 1/6] Switch misc-confusable-identifiers check to a fas

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-30 Thread Richard Smith via cfe-commits
@@ -181,42 +160,105 @@ void ConfusableIdentifierCheck::check( if (!ND) return; - IdentifierInfo *NDII = ND->getIdentifier(); + addDeclToCheck(ND, cast(ND->getDeclContext() +->getNonTransparentContext())); + + // Associate template p

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-30 Thread Richard Smith via cfe-commits
@@ -181,42 +160,105 @@ void ConfusableIdentifierCheck::check( if (!ND) return; - IdentifierInfo *NDII = ND->getIdentifier(); + addDeclToCheck(ND, cast(ND->getDeclContext() +->getNonTransparentContext())); + + // Associate template p

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-30 Thread Richard Smith via cfe-commits
https://github.com/zygoloid updated https://github.com/llvm/llvm-project/pull/130369 >From 78c9d5da85723040c30f00cb53e77c9dd4cc14b8 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 7 Mar 2025 22:49:37 + Subject: [PATCH 1/5] Switch misc-confusable-identifiers check to a fas

[clang] Disable -fdollars-in-identifiers by default (PR #135407)

2025-06-30 Thread Richard Smith via cfe-commits
zygoloid wrote: (I guess we could also warn if an object-like macro is expanded and the macro name is preceded or followed by a `$` with no whitespace, since that would also behave differently under `-fdollars-in-identifiers`, but I suspect that's not worth worrying about in practice.) https:

[clang] Disable -fdollars-in-identifiers by default (PR #135407)

2025-06-30 Thread Richard Smith via cfe-commits
zygoloid wrote: > This will indeed break building the Linux kernel for x86_64 at least in my > brief test [...] > ``` > In file included from arch/x86/kernel/acpi/wakeup_64.S:11: > arch/x86/include/asm/nospec-branch.h:80:7: warning: '$' in identifier; did > you mean to enable '-fdollars-in-iden

[clang] [clang] Remove separate evaluation step for static class member init. (PR #142713)

2025-06-17 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/142713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Remove separate evaluation step for static class member init. (PR #142713)

2025-06-10 Thread Richard Smith via cfe-commits
@@ -143,3 +143,8 @@ namespace fold_initializer { const float A::f = __builtin_is_constant_evaluated(); static_assert(fold(A::f == 1.0f)); } + +struct GH99680 { + static const int x = 1/(1-__builtin_is_constant_evaluated()); // expected-error {{in-class initializer for sta

[clang] [clang] Remove separate evaluation step for static class member init. (PR #142713)

2025-06-06 Thread Richard Smith via cfe-commits
@@ -143,3 +143,8 @@ namespace fold_initializer { const float A::f = __builtin_is_constant_evaluated(); static_assert(fold(A::f == 1.0f)); } + +struct GH99680 { + static const int x = 1/(1-__builtin_is_constant_evaluated()); // expected-error {{in-class initializer for sta

[clang] [clang] Remove separate evaluation step for static class member init. (PR #142713)

2025-06-06 Thread Richard Smith via cfe-commits
@@ -143,3 +143,8 @@ namespace fold_initializer { const float A::f = __builtin_is_constant_evaluated(); static_assert(fold(A::f == 1.0f)); } + +struct GH99680 { + static const int x = 1/(1-__builtin_is_constant_evaluated()); // expected-error {{in-class initializer for sta

[clang] [clang] Remove separate evaluation step for static class member init. (PR #142713)

2025-06-06 Thread Richard Smith via cfe-commits
@@ -143,3 +143,8 @@ namespace fold_initializer { const float A::f = __builtin_is_constant_evaluated(); static_assert(fold(A::f == 1.0f)); } + +struct GH99680 { + static const int x = 1/(1-__builtin_is_constant_evaluated()); // expected-error {{in-class initializer for sta

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-06-06 Thread Richard Smith via cfe-commits
zygoloid wrote: @PiotrZSL @5chmidti @HerrCai0907 Ping again. This has been waiting for review for a few months, could someone take a look? https://github.com/llvm/llvm-project/pull/130369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:/

[clang] [llvm] Enable fexec-charset option (PR #138895)

2025-06-02 Thread Richard Smith via cfe-commits
@@ -0,0 +1,35 @@ +// RUN: %clang_cc1 %s -emit-llvm -triple s390x-none-zos -fexec-charset IBM-1047 -o - | FileCheck %s zygoloid wrote: Should there be tests here for wide (`L`-prefixed) character and string literals too? https://github.com/llvm/llvm-project/pul

[clang] [llvm] Enable fexec-charset option (PR #138895)

2025-06-02 Thread Richard Smith via cfe-commits
@@ -7245,6 +7245,11 @@ let Visibility = [CC1Option, CC1AsOption, FC1Option] in { def tune_cpu : Separate<["-"], "tune-cpu">, HelpText<"Tune for a specific cpu type">, MarshallingInfoString>; +def fexec_charset : Separate<["-"], "fexec-charset">, MetaVarName<"">, + HelpText

[clang] [llvm] Enable fexec-charset option (PR #138895)

2025-06-02 Thread Richard Smith via cfe-commits
@@ -491,6 +491,9 @@ class Triple { /// For example, "fooos1.2.3" would return "1.2.3". StringRef getEnvironmentVersionString() const; + /// getSystemCharset - Get the system charset of the triple. + StringRef getSystemCharset() const; + zygoloid wrote:

[clang] [llvm] Enable fexec-charset option (PR #138895)

2025-06-02 Thread Richard Smith via cfe-commits
@@ -243,10 +243,11 @@ // RUN: not %clang_cl /source-charset:utf-16 -### -- %s 2>&1 | FileCheck -check-prefix=source-charset-utf-16 %s // source-charset-utf-16: invalid value 'utf-16' in '/source-charset:utf-16' -// /execution-charset: should warn on everything except UTF-8. -

[clang] [llvm] Enable fexec-charset option (PR #138895)

2025-06-02 Thread Richard Smith via cfe-commits
@@ -416,8 +416,7 @@ Builtin Macros ``__clang_literal_encoding__`` Defined to a narrow string literal that represents the current encoding of narrow string literals, e.g., ``"hello"``. This macro typically expands to - "UTF-8" (but may change in the future if the - ``-fexe

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-05-30 Thread Richard Smith via cfe-commits
zygoloid wrote: Ping x8 @PiotrZSL Any chance you'll find time to look at this soon, or should I look for other reviewers? https://github.com/llvm/llvm-project/pull/130369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/

[clang] Include [[clang::require_explicit_initialization]] warnings in system headers (PR #141133)

2025-05-28 Thread Richard Smith via cfe-commits
zygoloid wrote: > Its more that we assume/like to assume that the Standard Library always 'does > the right thing', even if it does so in ways that look 'wrong'. So we > suppress warnings in the standard library headers, since they are assumed to > all be false-positives. > > This of course i

[clang] Include [[clang::require_explicit_initialization]] warnings in system headers (PR #141133)

2025-05-27 Thread Richard Smith via cfe-commits
zygoloid wrote: I don't think this concern is specific to system headers. I don't think we have precedent for disabling a warning in a SFINAE context. We do suppress warnings produced while substituting into a function template specialization during deduction if we end up not selecting that ov

[clang] Include [[clang::require_explicit_initialization]] warnings in system headers (PR #141133)

2025-05-27 Thread Richard Smith via cfe-commits
zygoloid wrote: There are [techniques](https://github.com/carbon-language/carbon-lang/blob/69ab97d7167146ae1deea662126af66f8f5523a2/common/struct_reflection.h#L74) for determining the number of fields in an aggregate type `T` by attempting to initialize with `T{}` then `T{arg}` then `T{arg, ar

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-05-20 Thread Richard Smith via cfe-commits
zygoloid wrote: Ping x7 https://github.com/llvm/llvm-project/pull/130369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2025-05-19 Thread Richard Smith via cfe-commits
zygoloid wrote: > > If that mode doesn't already permit using unknown pointers and references > > in all language modes, then we should change it so that it does. > > `__builtin_object_size` is best-effort, but we should produce a constant > > value for it that's not the `-1` or `0` fallback v

[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2025-05-19 Thread Richard Smith via cfe-commits
zygoloid wrote: > Should `foo` in the following code return 4 when `-fstrict-flex-arrays` is 2 > or 3 (but not when it's 0 or 1) only when the target is `-std=c++23` or > newer? Or should it return 4 for older standards too? We evaluate the operand of `__builtin_object_size` in `EM_IgnoreSideE

[clang] [Serialization] Fix lazy template loading (PR #133057)

2025-05-16 Thread Richard Smith via cfe-commits
zygoloid wrote: Conversion function templates might be a special case here because of how conversion function template specializations are found by deduction as part of class member name lookup. Maybe we're doing something different in that deduction in particular that means we're not properly

[clang] [Clang] Add `noalias` to `this` pointer in C++ constructors (PR #136792)

2025-05-13 Thread Richard Smith via cfe-commits
zygoloid wrote: > @zygoloid Can you explain in your example why `a.n == 2` must be true, when > your interpretation (which I understood in the same manner) of the standard's > wording does indicate that the object's state is unspecified? My reading is that the standard says that the value of `

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-05-11 Thread Richard Smith via cfe-commits
zygoloid wrote: Ping x6 https://github.com/llvm/llvm-project/pull/130369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [ObjC] Stop hard-coding the list of keywords that are allowed in selectors (PR #138952)

2025-05-07 Thread Richard Smith via cfe-commits
@@ -1095,75 +1095,8 @@ IdentifierInfo *Parser::ParseObjCSelectorPiece(SourceLocation &SelectorLoc) { } case tok::identifier: - case tok::kw_asm: - case tok::kw_auto: - case tok::kw_bool: - case tok::kw_break: - case tok::kw_case: - case tok::kw_catch: - case tok::k

[clang] [clang] Document -fstrict-flex-arrays option (PR #138388)

2025-05-03 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Thank you! https://github.com/llvm/llvm-project/pull/138388 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Document -fstrict-flex-arrays option (PR #138388)

2025-05-03 Thread Richard Smith via cfe-commits
@@ -1554,7 +1554,10 @@ def fstrict_flex_arrays_EQ : Joined<["-"], "fstrict-flex-arrays=">, Group, NormalizedValuesScope<"LangOptions::StrictFlexArraysLevelKind">, NormalizedValues<["Default", "OneZeroOrIncomplete", "ZeroOrIncomplete", "IncompleteOnly"]>, - HelpText<"Enabl

[clang] [clang] Document -fstrict-flex-arrays option (PR #138388)

2025-05-03 Thread Richard Smith via cfe-commits
@@ -1554,7 +1554,10 @@ def fstrict_flex_arrays_EQ : Joined<["-"], "fstrict-flex-arrays=">, Group, NormalizedValuesScope<"LangOptions::StrictFlexArraysLevelKind">, NormalizedValues<["Default", "OneZeroOrIncomplete", "ZeroOrIncomplete", "IncompleteOnly"]>, - HelpText<"Enabl

[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2025-05-01 Thread Richard Smith via cfe-commits
zygoloid wrote: Looks like a bug to me. This warning presumably ought to be checking whether it's valid to read / write to the given location using something like [`isUserWritingOffTheEnd`](https://github.com/llvm/llvm-project/blob/b2e2ae8702e9fbbe0ef0eb5929aa2d5dc867b1c5/clang/lib/AST/ExprCons

[clang] [Clang] Implement P2280R4 Using unknown pointers and references in constant expressions (PR #95474)

2025-05-01 Thread Richard Smith via cfe-commits
zygoloid wrote: > Is the warning valid? Is the change in clang's behavior intentional? What do you have `-fstrict-flex-arrays` set to? Per [the documentation](https://releases.llvm.org/15.0.0/tools/clang/docs/ClangCommandLineReference.html#cmdoption-clang-fstrict-flex-arrays) (which weirdly se

[clang] [C] Diagnose use of C++ keywords in C (PR #137234)

2025-04-30 Thread Richard Smith via cfe-commits
zygoloid wrote: For what it's worth, the existing "keyword from language you're not using" warnings [already fire for analogous Objective-C++ cases](https://godbolt.org/z/3K6835PPK)... which in those cases is correct, since Clang does *not* accept C++11-onwards keywords as selector names in th

[clang] [C] Diagnose use of C++ keywords in C (PR #137234)

2025-04-29 Thread Richard Smith via cfe-commits
@@ -6118,6 +6120,10 @@ void Sema::warnOnReservedIdentifier(const NamedDecl *D) { Diag(D->getLocation(), diag::warn_reserved_extern_symbol) << D << static_cast(Status); } + // Diagnose use of C++ keywords in C as being incompatible with C++. + if (const Identifie

[clang] [C] Diagnose use of C++ keywords in C (PR #137234)

2025-04-29 Thread Richard Smith via cfe-commits
@@ -258,8 +283,13 @@ static void AddKeyword(StringRef Keyword, const LangOptions &LangOpts, IdentifierTable &Table) { KeywordStatus AddResult = getKeywordStatus(LangOpts, Flags); - // Don't add this keyword if disabled in this language. - if (AddResu

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-04-28 Thread Richard Smith via cfe-commits
zygoloid wrote: Ping x5. https://github.com/llvm/llvm-project/pull/130369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [BPF] Fix issues with external declarations of C++ structor decls (PR #137079)

2025-04-24 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. https://github.com/llvm/llvm-project/pull/137079 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Add `noalias` to `this` pointer in C++ constructors (PR #136792)

2025-04-23 Thread Richard Smith via cfe-commits
zygoloid wrote: > * I'm not sure this matches the requirements for C++ semantics; noalias is > very aggressive, so we might end up with undefined behavior in unintended > cases. I'd like someone familiar with the relevant standard bits to comment > on the requirements here. CC @zygoloid The

[clang] [ConstEval] Fix crash when comparing strings past the end (PR #137078)

2025-04-23 Thread Richard Smith via cfe-commits
zygoloid wrote: Yeah. I agree that using the overlap diagnostic only in the case where there's at least one byte of potential overlap (as this PR does) is best. https://github.com/llvm/llvm-project/pull/137078 ___ cfe-commits mailing list cfe-commits@

[clang] [ConstEval] Fix crash when comparing strings past the end (PR #137078)

2025-04-23 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. Thanks for the fix! I was wondering if the new code paths should actually return `true` not `false`, but I think it makes sense that for a comparison like `"hello" + 6 == "world"`, we say that the strings are *not* potentially-overlapping

[clang] [Clang] Make the result type of sizeof/pointer subtraction/size_t lit… (PR #136542)

2025-04-23 Thread Richard Smith via cfe-commits
zygoloid wrote: > If the type is an extension, we can define its compatibility rules, can't we? Well, the type `size_t` is not an extension, and we can't make strictly conforming C programs observably use a compatibility rule that the C standard doesn't permit. I think we *could* make the clai

[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-22 Thread Richard Smith via cfe-commits
zygoloid wrote: > We don't know which function is called until the object `p` is provided. See > case 2 in > https://discourse.llvm.org/t/rfc-implement-gcc-bound-pmf-in-clang/85951. Perhaps we could provide a builtin function that takes an object pointer and a pointer-to-member-function and r

[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

2025-04-21 Thread Richard Smith via cfe-commits
zygoloid wrote: > Not sure if anyone has mentioned this elsewhere, but there's a significant > problem with the type of the returned function pointer: a normal function > pointer doesn't necessarily have the correct calling convention. In practice, > this is likely to cause problems on Windows

[clang] [Clang] Make the result type of sizeof/pointer subtraction/size_t lit… (PR #136542)

2025-04-21 Thread Richard Smith via cfe-commits
zygoloid wrote: Another possibility would be to add a new kind of type sugar for these cases that has the same canonical type but knows that it should print as `size_t` / `ptrdiff_t` etc. That'd allow you to produce an identical AST regardless of whether the typedefs are included, which seems

[clang] Make the `-disable-free` flag more full featured (PR #136213)

2025-04-17 Thread Richard Smith via cfe-commits
@@ -7889,9 +7889,13 @@ def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">, def skip_function_bodies : Flag<["-"], "skip-function-bodies">, HelpText<"Skip function bodies when possible">, MarshallingInfoFlag>; -def disable_free : Flag<["-"], "disab

[clang] Make the `-disable-free` flag more full featured (PR #136213)

2025-04-17 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. https://github.com/llvm/llvm-project/pull/136213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Make the `-disable-free` flag more full featured (PR #136213)

2025-04-17 Thread Richard Smith via cfe-commits
@@ -7889,9 +7889,13 @@ def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">, def skip_function_bodies : Flag<["-"], "skip-function-bodies">, HelpText<"Skip function bodies when possible">, MarshallingInfoFlag>; -def disable_free : Flag<["-"], "disab

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-04-16 Thread Richard Smith via cfe-commits
zygoloid wrote: Ping x4. https://github.com/llvm/llvm-project/pull/130369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Disable -fdollars-in-identifiers by default (PR #135407)

2025-04-11 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/135407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Disable -fdollars-in-identifiers by default (PR #135407)

2025-04-11 Thread Richard Smith via cfe-commits
@@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fdollars-in-identifiers -fasm-blocks -emit-llvm -o - | FileCheck %s

[clang] Disable -fdollars-in-identifiers by default (PR #135407)

2025-04-11 Thread Richard Smith via cfe-commits
@@ -119,7 +119,7 @@ LANGOPT(WChar , 1, 0, "wchar_t keyword") LANGOPT(Char8 , 1, 0, "char8_t keyword") LANGOPT(IEEE128 , 1, 0, "__ieee128 keyword") LANGOPT(DeclSpecKeyword , 1, 0, "__declspec keyword") -BENIGN_LANGOPT(DollarIdents , 1, 1, "'

[clang] Disable -fdollars-in-identifiers by default (PR #135407)

2025-04-11 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/135407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C99] Remove the tgmath.h header (PR #135236)

2025-04-10 Thread Richard Smith via cfe-commits
zygoloid wrote: > > For some reason, WG21 has trampled over that meaning of "freestanding" and > > we no longer have such a separation for C++, but it still exists for C > > See #132232. Sigh. So we can't use "freestanding" as the line between compiler and standard library anywhere any more,

[clang] [C99] Remove the tgmath.h header (PR #135236)

2025-04-10 Thread Richard Smith via cfe-commits
zygoloid wrote: A few datapoints: * uClibc [uses `__builtin_classify_type`](https://git.uclibc.org/uClibc/tree/include/tgmath.h) and it looks like that'd work fine for us. * newlib [uses `__builtin_choose_expr`](https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/include/tgmat

[clang] [C99] Remove the tgmath.h header (PR #135236)

2025-04-10 Thread Richard Smith via cfe-commits
zygoloid wrote: I see. The glibc header comment gives an idea of what's going on here: ```c /* There are two variant implementations of type-generic macros in this file: one for GCC 8 and later, using __builtin_tgmath and where each macro expands each of its arguments only once, and one

[clang] No longer add enumeration constants to the wrong scope (PR #134998)

2025-04-10 Thread Richard Smith via cfe-commits
zygoloid wrote: > > I thought CWG's preferred direction on this was to reject entirely? > > What do they wish to reject? Defining an enum in a different declaration > context than its primary context? That seems odd. > > Do you have an idea of the CWG DR? We looked but couldn't find anything t

[clang] Support '-fmodule-file-home-is-cwd' for C++ modules. (PR #135147)

2025-04-10 Thread Richard Smith via cfe-commits
zygoloid wrote: > But if we want relocatable modules without using `-fmodules-embed-all-files` > though, is there a solution for that? Do you use `-no-canonical-prefixes`? https://github.com/llvm/llvm-project/pull/135147 ___ cfe-commits mailing list

[clang] [C99] Remove the tgmath.h header (PR #135236)

2025-04-10 Thread Richard Smith via cfe-commits
zygoloid wrote: > > I wonder if we can put it into an AIX-only (plus whatever other targets > > still need it) include directory, though, so we only find and use it on the > > targets where it's necessary? > > That, or, generally `#include_next` except for certain platforms (like AIX)? Possib

[clang] [C99] Remove the tgmath.h header (PR #135236)

2025-04-10 Thread Richard Smith via cfe-commits
zygoloid wrote: > Background: it's not clear to me which C Standard Library headers Clang > should or should not provide, Historically, the easiest line to draw has been that we aim to provide the freestanding headers. This matches GCC's [documented position](https://gcc.gnu.org/onlinedocs/gc

[clang] No longer add enumeration constants to the wrong scope (PR #134998)

2025-04-09 Thread Richard Smith via cfe-commits
zygoloid wrote: This came up on the core reflector again just yesterday; would be worth asking there. https://github.com/llvm/llvm-project/pull/134998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listi

[clang] No longer add enumeration constants to the wrong scope (PR #134998)

2025-04-09 Thread Richard Smith via cfe-commits
zygoloid wrote: I thought CWG's preferred direction on this was to reject entirely? https://github.com/llvm/llvm-project/pull/134998 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Reject invalid integer constants in unevaluated preprocessor operands (PR #134884)

2025-04-08 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. LGTM. I suppose if people complain, we can make the non-live value case a warning rather than an error, but given no other implementation does, I think it makes sense not to do that speculatively. https://github.com/llvm/llvm-project/pul

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-04-06 Thread Richard Smith via cfe-commits
zygoloid wrote: Ping. https://github.com/llvm/llvm-project/pull/130369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

2025-03-31 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: I think we should do this. Even if WG21 decides that they only want to allow this and not require it, it seems like a good change that we stand a decent chance of reaching implementation consensus on. https://github.com/llvm/llvm-project/pull/133426 _

[clang] [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

2025-03-31 Thread Richard Smith via cfe-commits
@@ -10230,9 +10307,15 @@ Sema::AddArgumentDependentLookupCandidates(DeclarationName Name, /*AllowExplicit=*/true, ADLCallKind::UsesADL); if (CandidateSet.getRewriteInfo().shouldAddReversed( *this, Args, FTD->getTemplatedDecl())) { + +// As

[clang] [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

2025-03-31 Thread Richard Smith via cfe-commits
@@ -8455,11 +8524,17 @@ void Sema::AddNonMemberOperatorCandidates( if (FunTmpl) { AddTemplateOverloadCandidate(FunTmpl, F.getPair(), ExplicitTemplateArgs, FunctionArgs, CandidateSet); - if (CandidateSet.getRewriteInfo().shouldAd

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-03-28 Thread Richard Smith via cfe-commits
zygoloid wrote: Ping. https://github.com/llvm/llvm-project/pull/130369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-27 Thread Richard Smith via cfe-commits
zygoloid wrote: > But still I feel generate a warning for this case went too far. Yeah, that's probably right. Maybe for `-` on a signed operand, we should just return the original range with the `NonNegative` flag cleared out, and shouldn't add the extra bit for the `-128 -> 128` edge case. T

[clang] [Sema] Diagnose by-value copy constructors in template instantiations (PR #130866)

2025-03-24 Thread Richard Smith via cfe-commits
zygoloid wrote: This error is [produced for the following code](https://github.com/carbon-language/carbon-lang/pull/5170): ```c++ template class SetView { SetView(SetView, KeyContextT> other_view) requires(!std::same_as>); }; ``` ... which is never an eligible copy constructor. Is that in

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-20 Thread Richard Smith via cfe-commits
zygoloid wrote: > > But still I feel generate a warning for this case went too far. > > Yeah, that's probably right. Maybe for `-` on a signed operand, we should > just return the original range with the `NonNegative` flag cleared out, and > shouldn't add the extra bit for the `-128 -> 128` ed

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-19 Thread Richard Smith via cfe-commits
zygoloid wrote: > Would it be possible to provide better fine grained control over the > `-Wsign-compare` so the clang could still flag the the cases like the one in > the summary but ignore the cases where implicit conversion has no side > effects or UB? The warning being produced is a `-Wim

[clang] [clang-tools-extra] Suppress pedantic diagnostic for a file not ending in EOL (PR #131794)

2025-03-18 Thread Richard Smith via cfe-commits
@@ -127,8 +127,10 @@ C2y Feature Support that ``_Generic`` selection associations may now have ``void`` type, but it also removes UB with code like ``(void)(void)1;``. - Implemented `WG14 N3411 `_ - which allows

[clang] [clang-tools-extra] Suppress pedantic diagnostic for a file not ending in EOL (PR #131794)

2025-03-18 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: LG https://github.com/llvm/llvm-project/pull/131794 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] Suppress pedantic diagnostic for a file not ending in EOL (PR #131794)

2025-03-18 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/131794 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] Suppress pedantic diagnostic for a file not ending in EOL (PR #131794)

2025-03-18 Thread Richard Smith via cfe-commits
@@ -627,8 +627,6 @@ buildPreamble(PathRef FileName, CompilerInvocation CI, return DiagnosticsEngine::Ignored; switch (Info.getID()) { case diag::warn_no_newline_eof: -case diag::warn_cxx98_compat_no_newline_eof: -case diag::ext_no_newline_eof: // If

[clang] [C++20][Modules] Prevent premature call to PassInterestingDeclsToConsumer() within FinishedDeserializing(). (PR #129982)

2025-03-14 Thread Richard Smith via cfe-commits
zygoloid wrote: Thank you! I can imagine figuring out what was wrong here was not easy! https://github.com/llvm/llvm-project/pull/129982 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C++20][Modules] Prevent premature call to PassInterestingDeclsToConsumer() within FinishedDeserializing(). (PR #129982)

2025-03-14 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. https://github.com/llvm/llvm-project/pull/129982 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [C++20][Modules] Prevent premature call to PassInterestingDeclsToConsumer() within FinishedDeserializing(). (PR #129982)

2025-03-14 Thread Richard Smith via cfe-commits
https://github.com/zygoloid commented: Thanks, the explanation and code change makes sense to me. Should this bugfix have a release note? https://github.com/llvm/llvm-project/pull/129982 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-03-07 Thread Richard Smith via cfe-commits
fter ``` >From 78c9d5da85723040c30f00cb53e77c9dd4cc14b8 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 7 Mar 2025 22:49:37 + Subject: [PATCH 1/2] Switch misc-confusable-identifiers check to a faster algorithm. - Only build the skeleton for each identifier once. - Only compute the

[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

2025-03-07 Thread Richard Smith via cfe-commits
https://github.com/zygoloid updated https://github.com/llvm/llvm-project/pull/130369 >From 78c9d5da85723040c30f00cb53e77c9dd4cc14b8 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 7 Mar 2025 22:49:37 + Subject: [PATCH 1/3] Switch misc-confusable-identifiers check to a fas

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-07 Thread Richard Smith via cfe-commits
zygoloid wrote: Can you update the first comment on this PR to reflect what you want to be in the commit message? I notice that it doesn't describe what you're doing with negation yet. Thanks! https://github.com/llvm/llvm-project/pull/126846 ___ cfe-

[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)

2025-03-07 Thread Richard Smith via cfe-commits
https://github.com/zygoloid approved this pull request. https://github.com/llvm/llvm-project/pull/126846 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][diagnostics] add '-Wundef-true' warning option (PR #128265)

2025-03-01 Thread Richard Smith via cfe-commits
@@ -257,7 +257,10 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT, // preprocessor keywords and it wasn't macro expanded, it turns // into a simple 0 if (ValueLive) { - PP.Diag(PeekTok, diag::warn_pp_undef_ident

[clang] [clang][diagnostics] add '-Wundef-true' warning option (PR #128265)

2025-03-01 Thread Richard Smith via cfe-commits
https://github.com/zygoloid edited https://github.com/llvm/llvm-project/pull/128265 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][diagnostics] add '-Wundef-true' warning option (PR #128265)

2025-03-01 Thread Richard Smith via cfe-commits
@@ -791,6 +791,8 @@ def ReservedIdAsMacroAlias : DiagGroup<"reserved-id-macro", [ReservedIdAsMacro]> def ReservedAttributeIdentifier : DiagGroup<"reserved-attribute-identifier">; def RestrictExpansionMacro : DiagGroup<"restrict-expansion">; def FinalMacro : DiagGroup<"final-ma

  1   2   3   4   5   6   7   8   9   10   >