https://github.com/rniwa created https://github.com/llvm/llvm-project/pull/182777
This PR fixes typeAnnotationForReturnType to account for MacroQualifiedType. >From 1ba7cc2f5eb3bd2f4d20189e3f14977bd1fac8ac Mon Sep 17 00:00:00 2001 From: Ryosuke Niwa <[email protected]> Date: Sun, 22 Feb 2026 14:08:02 -0800 Subject: [PATCH] [alpha.webkit.NoDeleteChecker] Account for MacroQualifiedType This PR fixes typeAnnotationForReturnType to account for MacroQualifiedType. --- .../StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp | 5 ++++- .../test/Analysis/Checkers/WebKit/nodelete-annotation.cpp | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp index 8cd64c12b7a73..caf76396fcbfc 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp @@ -414,7 +414,10 @@ enum class WebKitAnnotation : uint8_t { static WebKitAnnotation typeAnnotationForReturnType(const FunctionDecl *FD) { auto RetType = FD->getReturnType(); - auto *Attr = dyn_cast_or_null<AttributedType>(RetType.getTypePtrOrNull()); + auto *Type = RetType.getTypePtrOrNull(); + if (auto *MacroQualified = dyn_cast_or_null<MacroQualifiedType>(Type)) + Type = MacroQualified->desugar().getTypePtrOrNull(); + auto *Attr = dyn_cast_or_null<AttributedType>(Type); if (!Attr) return WebKitAnnotation::None; auto *AnnotateType = dyn_cast_or_null<AnnotateTypeAttr>(Attr->getAttr()); diff --git a/clang/test/Analysis/Checkers/WebKit/nodelete-annotation.cpp b/clang/test/Analysis/Checkers/WebKit/nodelete-annotation.cpp index 98f4017e5e3fd..9fdff51b42d33 100644 --- a/clang/test/Analysis/Checkers/WebKit/nodelete-annotation.cpp +++ b/clang/test/Analysis/Checkers/WebKit/nodelete-annotation.cpp @@ -14,6 +14,13 @@ void [[clang::annotate_type("webkit.nodelete")]] callsUnsafe() { someFunction(); } +#define EXPORT_IMPORT __attribute__((visibility("default"))) +EXPORT_IMPORT unsigned [[clang::annotate_type("webkit.nodelete")]] safeFunctionWithAttr(); + +void [[clang::annotate_type("webkit.nodelete")]] callsSafeWithAttribute() { + unsigned r = safeFunctionWithAttr(); +} + void [[clang::annotate_type("webkit.nodelete")]] callsSafe() { safeFunction(); } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
