================
@@ -1980,6 +1981,23 @@ static void handleWeakRefAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
   D->addAttr(::new (S.Context) WeakRefAttr(S.Context, AL));
 }
 
+// Mark alias/ifunc target as used. For C++, we look up the demangled name
+// ignoring parameters. This should handle the majority of use cases while
+// leaveing false positives for namespace scope names and false negatives in
+// the presence of overloads.
+static void markUsedForAliasOrIfunc(Sema &S, Decl *D, const ParsedAttr &AL,
+                                    StringRef Str) {
+  char *Demangled = llvm::itaniumDemangle(Str, /*ParseParams=*/false);
----------------
AaronBallman wrote:

> I added a `S.getASTContext().getCXXABIKind() != TargetCXXABI::Microsoft` 
> check.
> 
> Note: while `alias` works for Windows, it is only checked in tests 
> CodeGenCXX/visibility-dllstorageclass.cpp/CodeGen/debug-info-alias-pointer.c 
> . I don't consider an internal linkage target used or cared by users.

I'm not certain why there's so much resistance to doing this when three people 
have pointed out the concern. It still works for Windows. e.g.,
```
F:\source\llvm-project>cat "C:\Users\aballman\OneDrive - Intel 
Corporation\Desktop\test.cpp"
namespace NS {
  extern "C" int puts(const char *);
  void f() { puts("I did the thing!"); }
}

void func() __attribute__((alias("?f@NS@@YAXXZ")));

int main() {
  func();
}

F:\source\llvm-project>llvm\out\build\x64-Debug\bin\clang.exe 
"C:\Users\aballman\OneDrive - Intel Corporation\Desktop\test.cpp"

F:\source\llvm-project>a.exe
I did the thing!
```
We should support it properly rather than only halfway, *especially considering 
the context of the bug report*.

https://github.com/llvm/llvm-project/pull/87130
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to