================ @@ -7941,6 +7942,32 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr, return true; } + if (attr.getKind() == ParsedAttr::AT_CFISalt) { + if (attr.getNumArgs() == 0) + return true; + + // Delay if this is not a function type. + StringRef Argument; + if (!S.checkStringLiteralArgumentAttr(attr, 0, Argument)) + return false; + + // Delay if this is not a function type. + if (!unwrapped.isFunctionType()) + return false; + + const auto *FnTy = unwrapped.get()->getAs<FunctionProtoType>(); + if (!FnTy) ---------------- AaronBallman wrote:
I think what's being asked for is a test case like: ``` // RUN: %clang_cc1 -std=c89 -fsyntax-only -fsanitize=kcfi -verify %s // K&R C function without a prototype void func() __attribute__((cfi_salt("pepper"))); // expected-error {{attribute only applies to function types with a prototype}} void (*fp)() __attribute__((cfi_salt("pepper"))); // expected-error {{attribute only applies to function pointer types with a prototype}} ``` (or something along those lines). As it stands, it looks like this code will silently drop the attribute because `getAs` will return null and we'll early return here. https://github.com/llvm/llvm-project/pull/141846 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits