[PATCH] D96109: Refactor implementation of -funique-internal-linkage-names.
Aaron Ballman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 18 05:55:53 PST 2021
aaron.ballman added inline comments.
================
Comment at: clang/include/clang/Basic/Attr.td:2159
+def UniqueInternalLinkageSuffix : Attr {
+ // This attribute has no spellings as it is only ever created implicitly.
----------------
tmsriram wrote:
> aaron.ballman wrote:
> > Should this attribute be inherited by redeclarations?
> The attribute is added in EmitTopLevelDecl in CodeGenModule which happens after ActOnDeclarator in SemaDecl.cpp. I dont think this needs to be inherited but I am not sure. Is there an example I can use to check if this is fine?
I was thinking of something along these lines, where the initial declaration is explicitly marked static and the definition is not:
```
static int foo(void);
int foo(void) { return 12; }
int main() {
return foo();
}
```
However, I realize now that it shouldn't matter because the attribute isn't attached until codegen time. FWIW, this means the attribute won't appear in the AST, which means things like clang-tidy or third-parties that consume the AST won't have access to this information.
================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5561
+ // the mangler will not do the right thing without one.
+ if (D->getKind() == Decl::Function && !getLangOpts().CPlusPlus &&
+ cast<FunctionDecl>(D)->getType()->getAs<FunctionProtoType>() &&
----------------
It's a bit novel to add the attribute at codegen time rather than at sema -- is there a reason this attribute should not be added to the AST from within Sema?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96109/new/
https://reviews.llvm.org/D96109
More information about the llvm-commits
mailing list