[llvm] [clang] [Clang][IR] add TBAA metadata on pointer, union and array types. (PR #75177)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 20 14:16:00 PST 2023
================
@@ -105,13 +105,28 @@ static bool isValidBaseType(QualType QTy) {
if (RD->hasFlexibleArrayMember())
return false;
// RD can be struct, union, class, interface or enum.
- // For now, we only handle struct and class.
- if (RD->isStruct() || RD->isClass())
+ if (RD->isStruct() || RD->isClass() ||
+ (RD->isUnion() && CodeGenOpts.UnionTBAA))
return true;
}
return false;
}
+std::string CodeGenTBAA::getPointeeName(const Type *Ty) {
+ if (isa<BuiltinType>(Ty)) {
+ llvm::MDNode *ScalarMD = getTypeInfoHelper(Ty);
+ auto &Op = ScalarMD->getOperand(CodeGenOpts.NewStructPathTBAA ? 2 : 0);
+ assert(isa<llvm::MDString>(Op) && "Expected MDString operand");
+ return cast<llvm::MDString>(Op)->getString().str();
+ }
+
+ if (Ty->isIncompleteType())
+ return "<incomplete type>";
----------------
rjmccall wrote:
Why are incomplete types treated differently here?
https://github.com/llvm/llvm-project/pull/75177
More information about the cfe-commits
mailing list