llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Ryosuke Niwa (rniwa) <details> <summary>Changes</summary> This PR fixes typeAnnotationForReturnType to account for MacroQualifiedType. --- Full diff: https://github.com/llvm/llvm-project/pull/182777.diff 2 Files Affected: - (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp (+4-1) - (modified) clang/test/Analysis/Checkers/WebKit/nodelete-annotation.cpp (+7) ``````````diff 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(); } `````````` </details> https://github.com/llvm/llvm-project/pull/182777 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
