Skip to content

Commit 071da92

Browse files
authored
[Clang] ensure mangled names are valid identifiers before being suggested in ifunc/alias attributes notes (#118170)
Fixes #112205 --- Commit that introduced this feature - 9306ef9
1 parent 97f94af commit 071da92

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@ Bug Fixes to C++ Support
762762
- Fixed a bug where bounds of partially expanded pack indexing expressions were checked too early. (#GH116105)
763763
- Fixed an assertion failure caused by using ``consteval`` in condition in consumed analyses. (#GH117385)
764764
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
765+
- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205)
765766

766767
Bug Fixes to AST Handling
767768
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,8 @@ static bool checkAliasedGlobal(
602602
// mangled name.
603603
for (const auto &[Decl, Name] : MangledDeclNames) {
604604
if (const auto *ND = dyn_cast<NamedDecl>(Decl.getDecl())) {
605-
if (ND->getName() == GV->getName()) {
605+
IdentifierInfo *II = ND->getIdentifier();
606+
if (II && II->getName() == GV->getName()) {
606607
Diags.Report(Location, diag::note_alias_mangled_name_alternative)
607608
<< Name
608609
<< FixItHint::CreateReplacement(

clang/test/CodeGen/alias.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ __attribute__((unused, alias("resolver"), deprecated("hahahaha, isn't C great?")
2626
void func();
2727
// expected-error@-2 {{alias must point to a defined variable or function}}
2828
// expected-note@-3 {{must refer to its mangled name}}
29+
30+
void *operator new(unsigned long) __attribute__((alias("A"))); // expected-error {{alias must point to a defined variable or function}} \
31+
// expected-note {{the function or variable specified in an alias must refer to its mangled name}}
2932
#endif
3033

3134
// CHECK: @_ZN4libc4log2Ed ={{.*}} alias double (double), ptr @log2

0 commit comments

Comments
 (0)