[clang] FunctionDecl::getFunctionTypeLoc: ignore function type attributes (PR #118420)
Robert Dazi via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 2 20:15:41 PST 2024
https://github.com/v01dXYZ created https://github.com/llvm/llvm-project/pull/118420
Related to #118290.
>From c7e93d177aef1214be6dea9e408e547b6d363e33 Mon Sep 17 00:00:00 2001
From: v01dxyz <v01dxyz at v01d.xyz>
Date: Tue, 3 Dec 2024 04:52:33 +0100
Subject: [PATCH] FunctionDecl::getFunctionTypeLoc: ignore function type
attributes
---
clang/lib/AST/Decl.cpp | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 741e908cf9bc56..2d1d94ebba755e 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3876,8 +3876,17 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
FunctionTypeLoc FunctionDecl::getFunctionTypeLoc() const {
const TypeSourceInfo *TSI = getTypeSourceInfo();
- return TSI ? TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>()
- : FunctionTypeLoc();
+
+ if(!TSI)
+ return FunctionTypeLoc();
+
+ TypeLoc TL = TSI->getTypeLoc().IgnoreParens();
+
+ // ignore function type attributes
+ while(auto ATL = TL.getAs<AttributedTypeLoc>())
+ TL = ATL.getModifiedLoc();
+
+ return TL.getAs<FunctionTypeLoc>();
}
SourceRange FunctionDecl::getReturnTypeSourceRange() const {
More information about the cfe-commits
mailing list