[clang] [compiler-rt] [Clang][CodeGen] Report when an alias points to an incompatible target (PR #192397)

Igor Kudrin via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 18 00:57:09 PDT 2026


================
@@ -804,6 +804,48 @@ void CodeGenModule::checkAliases() {
       continue;
     }
 
+    if (!IsIFunc) {
+      // Function declarations can only alias functions (including IFUNCs).
+      // Similarly, variable declarations can only alias variables.
+      if (isa<FunctionDecl>(D) != isa<llvm::Function, llvm::GlobalIFunc>(GV)) {
+        GlobalDecl AliaseeGD = getMangledNameDecl(GV->getName());
+        assert(AliaseeGD);
+        Diags.Report(Location, diag::err_alias_between_function_and_variable)
+            << isa<FunctionDecl>(D);
+        Diags.Report(AliaseeGD.getDecl()->getLocation(),
+                     diag::note_aliasee_declaration);
+        Error = true;
+        continue;
+      }
+
+      auto shouldReportTypeMismatch = [&]() {
+        llvm::Type *AliasTy = Alias->getValueType();
+        llvm::Type *AliaseeTy = GV->getValueType();
----------------
igorkudrin wrote:

It looks like there is another method, `lookupRepresentativeDecl()`, which uses a (not perfect but good enough) mirror map `Manglings`. I've updated the patch. Thanks for the suggestion!

https://github.com/llvm/llvm-project/pull/192397


More information about the cfe-commits mailing list