[all-commits] [llvm/llvm-project] e8b509: [clang] use decl itself in static assert failed bo...
Fan Mo via All-commits
all-commits at lists.llvm.org
Fri Jul 3 00:25:30 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e8b509f10bf34082b6fb35eb35e34f77ea583bef
https://github.com/llvm/llvm-project/commit/e8b509f10bf34082b6fb35eb35e34f77ea583bef
Author: Fan Mo <w007878 at hotmail.com>
Date: 2026-07-03 (Fri, 03 Jul 2026)
Changed paths:
M clang/lib/Sema/SemaTemplate.cpp
A clang/test/SemaCXX/GH203701.cpp
Log Message:
-----------
[clang] use decl itself in static assert failed boolean condition printer (#203736)
fixes #203701
`getName()` assumes the decl used in the static asserts has a simple
identifier name, but in some cases like `operator int` don't — they
fails the assertion `Name.isIdentifier() && "Name is not a simple
identifier"` when the `static_assert` failure diagnostic tries to print
the boolean expression.
Switching to getDeclName() handles these special names properly.
Reproducer:
```c++
struct S {
constexpr S(auto) {}
constexpr operator int() const { return 0; }
};
constexpr auto a = [](this S) { return 1; };
static_assert((&decltype(a)::operator())(1) == 42);
```
---
One thing I'm not sure about: the print helper that walks the boolean
expression lives in `SemaTemplate.cpp` (inside
`printTemplateArgumentList` / the DiagRecursiveConstraintEval visitor
area). Is there a historical reason for it being there rather than
somewhere more general like `SemaOverload.cpp` or a shared diagnostic
utility? Happy to move it if that makes more sense.
---
AI used for generating & fixing unit test
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list