Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions clang/lib/StaticAnalyzer/Checkers/WebKit/ForwardDeclChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,18 @@ class ForwardDeclChecker : public Checker<check::ASTDecl<TranslationUnitDecl>> {
if (!R) // Forward declaration of a Objective-C interface is safe.
return false;
auto Name = R->getName();
return !R->hasDefinition() && !RTC.isUnretained(QT) &&
!SystemTypes.contains(CanonicalType) &&
if (R->hasDefinition())
return false;
// Find a definition amongst template declarations.
if (auto *Specialization = dyn_cast<ClassTemplateSpecializationDecl>(R)) {
if (auto *S = Specialization->getSpecializedTemplate()) {
for (S = S->getMostRecentDecl(); S; S = S->getPreviousDecl()) {
if (S->isThisDeclarationADefinition())
return false;
}
}
}
return !RTC.isUnretained(QT) && !SystemTypes.contains(CanonicalType) &&
!SystemTypes.contains(PointeeType) && !Name.starts_with("Opaque") &&
Name != "_NSZone";
}
Expand Down
17 changes: 17 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/forward-decl-checker.mm
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,20 @@ - (void)doMoreWork:(ObjCObj *)obj {
}

@end

namespace template_forward_declare {

template<typename> class HashSet;

template<typename T>
using SingleThreadHashSet = HashSet<T>;

template<typename> class HashSet { };

struct Font { };

struct ComplexTextController {
SingleThreadHashSet<const Font>* fallbackFonts { nullptr };
};

}
Loading