[clang] Thread Safety Analysis: Support attributes on function pointers (PR #191187)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 27 06:19:12 PDT 2026
================
@@ -674,15 +674,28 @@ void Parser::ParseGNUAttributeArgs(
// These may refer to the function arguments, but need to be parsed early to
// participate in determining whether it's a redeclaration.
std::optional<ParseScope> PrototypeScope;
- if (normalizeAttrName(AttrName->getName()) == "enable_if" &&
- D && D->isFunctionDeclarator()) {
- const DeclaratorChunk::FunctionTypeInfo& FTI = D->getFunctionTypeInfo();
- PrototypeScope.emplace(this, Scope::FunctionPrototypeScope |
- Scope::FunctionDeclarationScope |
- Scope::DeclScope);
- for (unsigned i = 0; i != FTI.NumParams; ++i)
- Actions.ActOnReenterCXXMethodParameter(
- getCurScope(), dyn_cast_or_null<ParmVarDecl>(FTI.Params[i].Param));
+ if (D && (normalizeAttrName(AttrName->getName()) == "enable_if" ||
+ IsAttributeLateParsedStandard(*AttrName))) {
----------------
AaronBallman wrote:
>From Attr.td:
```
// Standard late attribute parsing
//
// This is language dependent. For example:
//
// * For C++ enables late parsing of a declaration attributes
// * For C does not enable late parsing of attributes
//
def LateAttrParseStandard : LateAttrParseKind<1>;
```
So these changes break that documentation, but I don't think you want the changes to only apply in C++ and not in C. I suspect you'll want these attributes to be using `LateAttrParseExperimentalExt` now instead, and be checking for that here. CC @rapidsna @hnrklssn for more opinions given this is tangential to bounds safety late parsing behavior.
https://github.com/llvm/llvm-project/pull/191187
More information about the cfe-commits
mailing list