[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
Thu Apr 16 23:07:51 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)) {
----------------
igorkudrin wrote:
No, `GV` comes from `checkAliasedGlobal()`, which calls `getAliasedGlobal()` ➡️ `GlobalValue::getAliaseeObject()` ➡️ `findBaseObject()`, so we have the final alias target here.
The current condition directly reads as "one side is a function while the other is not", which is clear and fully corresponds to the intent. I could not find a similar phrase for `isa<FunctionDecl>(D) == isa<llvm::GlobalObject>(GV)`, so I chose the current variant for better readability. Not a strong preference, though.
https://github.com/llvm/llvm-project/pull/192397
More information about the cfe-commits
mailing list