-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang] ensure mangled names are valid identifiers before being suggested in ifunc/alias attributes notes #118170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…sted in ifunc/alias attributes notes
@llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Oleksandr T. (a-tarasyuk) ChangesFixes #112205 Commit that introduced this feature - 9306ef9 Full diff: https://github.com/llvm/llvm-project/pull/118170.diff 3 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e44aefa90ab386..5c24471bbf7c93 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -763,6 +763,7 @@ Bug Fixes to C++ Support
- Fixed a bug where bounds of partially expanded pack indexing expressions were checked too early. (#GH116105)
- Fixed an assertion failure caused by using ``consteval`` in condition in consumed analyses. (#GH117385)
- Fix a crash caused by incorrect argument position in merging deduced template arguments. (#GH113659)
+- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205)
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 7189a4689e8156..d3d5c0743a520b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -602,7 +602,8 @@ static bool checkAliasedGlobal(
// mangled name.
for (const auto &[Decl, Name] : MangledDeclNames) {
if (const auto *ND = dyn_cast<NamedDecl>(Decl.getDecl())) {
- if (ND->getName() == GV->getName()) {
+ IdentifierInfo *II = ND->getIdentifier();
+ if (II && II->getName() == GV->getName()) {
Diags.Report(Location, diag::note_alias_mangled_name_alternative)
<< Name
<< FixItHint::CreateReplacement(
diff --git a/clang/test/CodeGen/alias.cpp b/clang/test/CodeGen/alias.cpp
index a468c31d369ed0..43be6b99ce8491 100644
--- a/clang/test/CodeGen/alias.cpp
+++ b/clang/test/CodeGen/alias.cpp
@@ -26,6 +26,9 @@ __attribute__((unused, alias("resolver"), deprecated("hahahaha, isn't C great?")
void func();
// expected-error@-2 {{alias must point to a defined variable or function}}
// expected-note@-3 {{must refer to its mangled name}}
+
+void *operator new(unsigned long) __attribute__((alias("A"))); // expected-error {{alias must point to a defined variable or function}} \
+ // expected-note {{the function or variable specified in an alias must refer to its mangled name}}
#endif
// CHECK: @_ZN4libc4log2Ed ={{.*}} alias double (double), ptr @log2
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/46/builds/8786 Here is the relevant piece of the build log for the reference
|
Fixes #112205
Commit that introduced this feature - 9306ef9