[clang] Thread Safety Analysis: Support attributes on function pointers (PR #191187)
Marco Elver via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 30 08:36:47 PDT 2026
================
@@ -674,15 +684,27 @@ 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 && IsAttributeArgsParsedInFunctionScope(*AttrName)) {
----------------
melver wrote:
No, removing D->isFunctionDeclarator() is deliberate. isFunctionDeclarator() only evaluates to true if the outermost declarator is a function.
For a function pointer, the outermost chunk is a pointer, causing isFunctionDeclarator() to return false. By dropping that check and iterating through the chunks, we can find the inner prototype.
https://github.com/llvm/llvm-project/pull/191187
More information about the cfe-commits
mailing list