================
@@ -3374,10 +3379,93 @@ void CIRGenModule::release() {
emitLLVMUsed();
+ // Classic codegen calls `checkAliases` here to validate any alias
+ // definitions emitted during codegen.
+ assert(!cir::MissingFeatures::checkAliases());
+
// There's a lot of code that is not implemented yet.
assert(!cir::MissingFeatures::cgmRelease());
}
+void CIRGenModule::emitAliasDefinition(GlobalDecl gd) {
+ const auto *d = cast<ValueDecl>(gd.getDecl());
+ const AliasAttr *aa = d->getAttr<AliasAttr>();
+ assert(aa && "Not an alias?");
+
+ StringRef mangledName = getMangledName(gd);
+
+ if (aa->getAliasee() == mangledName) {
+ diags.Report(aa->getLocation(), diag::err_cyclic_alias) << 0;
+ return;
+ }
+
+ // If there is a definition in the module, then it wins over the alias.
+ // This is dubious, but allow it to be safe. Just ignore the alias.
+ mlir::Operation *entry = getGlobalValue(mangledName);
+ if (entry) {
+ auto entryGV = mlir::dyn_cast<cir::CIRGlobalValueInterface>(entry);
+ if (entryGV && !entryGV.isDeclaration())
+ return;
+ }
+
+ // Classic codegen pushes the alias onto an `Aliases` list at this point so
+ // that `checkAliases` can later validate the alias and recover on error.
+ assert(!cir::MissingFeatures::checkAliases());
+
+ mlir::Location loc = getLoc(d->getSourceRange());
+ const bool isFunction = isa<FunctionDecl>(d);
----------------
erichkeane wrote:
```suggestion
bool isFunction = isa<FunctionDecl>(d);
```
https://github.com/llvm/llvm-project/pull/195972
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits