diff options
author | Alexandros Lamprineas <alexandros.lamprineas@arm.com> | 2024-05-23 10:09:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-23 10:09:22 +0100 |
commit | 8930ba98e01bc66949e482b396f8389d64388359 (patch) | |
tree | 3e8919c50e88ea76663ae05f0bf2b2733eabc3aa /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | bf4d99e16789dd711eb61b36ce92b8519f450dd5 (diff) | |
download | llvm-8930ba98e01bc66949e482b396f8389d64388359.zip llvm-8930ba98e01bc66949e482b396f8389d64388359.tar.gz llvm-8930ba98e01bc66949e482b396f8389d64388359.tar.bz2 |
[clang][FMV] Allow declaration of function versions in namespaces. (#93044)
Fixes the following bug:
namespace Name {
int __attribute((target_version("default"))) foo() { return 0; }
}
namespace Name {
int __attribute((target_version("sve"))) foo() { return 1; }
}
int bar() { return Name::foo(); }
error: redefinition of 'foo'
int __attribute((target_version("sve"))) foo() { return 1; }
note: previous definition is here
int __attribute((target_version("default"))) foo() { return 0; }
While fixing this I also found that in the absence of default version
declaration, the one we implicitly create has incorrect mangling if
we are in a namespace:
namespace OtherName {
int __attribute((target_version("sve"))) foo() { return 2; }
}
int baz() { return OtherName::foo(); }
In this example instead of creating a declaration for the symbol
@_ZN9OtherName3fooEv.default we are creating one for the symbol
@_Z3foov.default (the namespace mangling prefix is omitted).
This has now been fixed.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 60ef28a..e4774a5 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4150,7 +4150,7 @@ llvm::GlobalValue::LinkageTypes getMultiversionLinkage(CodeGenModule &CGM, } static FunctionDecl *createDefaultTargetVersionFrom(const FunctionDecl *FD) { - DeclContext *DeclCtx = FD->getASTContext().getTranslationUnitDecl(); + auto *DeclCtx = const_cast<DeclContext *>(FD->getDeclContext()); TypeSourceInfo *TInfo = FD->getTypeSourceInfo(); StorageClass SC = FD->getStorageClass(); DeclarationName Name = FD->getNameInfo().getName(); |