================
@@ -1347,8 +1347,40 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr
*ArrayExpr,
IndexInst);
}
+static SmallString<64> getAllocTokenFunctionName(const Decl *D,
+ const ASTContext &Ctx) {
+ SmallString<64> Name;
+ const auto *ND = dyn_cast_if_present<NamedDecl>(D);
+ if (!ND)
+ return Name;
+ PrintingPolicy Policy(Ctx.getLangOpts());
+ // Do not use name lookup to decide whether to print inline namespaces.
+ Policy.SuppressInlineNamespace =
+ llvm::to_underlying(PrintingPolicy::SuppressInlineNamespaceMode::All);
+ // Do not print file paths for unnamed types, e.g. in template arguments.
+ Policy.AnonymousTagNameStyle =
+ llvm::to_underlying(PrintingPolicy::AnonymousTagMode::Plain);
+ llvm::raw_svector_ostream OS(Name);
+ ND->printQualifiedName(OS, Policy);
+ return Name;
+}
+
llvm::MDNode *CodeGenFunction::buildAllocToken(QualType AllocType) {
- auto ATMD = infer_alloc::getAllocTokenMetadata(AllocType, getContext());
+ std::optional<llvm::AllocTokenMetadata> ATMD;
+ if (!AllocType.isNull())
+ ATMD = infer_alloc::getAllocTokenMetadata(AllocType, getContext());
+
+ const llvm::AllocTokenMode Mode =
+ getLangOpts().AllocTokenMode.value_or(llvm::DefaultAllocTokenMode);
+ if (Mode == llvm::AllocTokenMode::TypeFuncHash ||
+ Mode == llvm::AllocTokenMode::TypeFuncHashPointerSplit) {
+ if (!ATMD)
+ ATMD = llvm::AllocTokenMetadata{{}, false};
----------------
melver wrote:
Can you document this in the PR commit message or perhaps as a code comment
here? It's easy to forget such design decisions.
https://github.com/llvm/llvm-project/pull/228492
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits