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(RetType.getTypePtrOrNull()); + auto *Type = RetType.getTypePtrOrNull(); + if (auto *MacroQualified = dyn_cast_or_null(Type)) + Type = MacroQualified->desugar().getTypePtrOrNull(); + auto *Attr = dyn_cast_or_null(Type); if (!Attr) return WebKitAnnotation::None; auto *AnnotateType = dyn_cast_or_null(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(); }