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
12 changes: 6 additions & 6 deletions clang/lib/StaticAnalyzer/Checkers/WebKit/ForwardDeclChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,16 @@ class ForwardDeclChecker : public Checker<check::ASTDecl<TranslationUnitDecl>> {
RTC.visitTypedef(TD);
auto QT = TD->getUnderlyingType().getCanonicalType();
if (BR->getSourceManager().isInSystemHeader(TD->getBeginLoc())) {
if (auto *Type = QT.getTypePtrOrNull(); Type && QT->isPointerType())
if (auto *Type = QT.getTypePtrOrNull())
SystemTypes.insert(Type);
}
}

bool isUnknownType(QualType QT) const {
auto *Type = QT.getTypePtrOrNull();
if (!Type)
return false;
auto *CanonicalType = QT.getCanonicalType().getTypePtrOrNull();
auto PointeeQT = Type->getPointeeType();
if (!CanonicalType)
return false;
auto PointeeQT = CanonicalType->getPointeeType();
auto *PointeeType = PointeeQT.getTypePtrOrNull();
if (!PointeeType)
return false;
Expand All @@ -128,7 +127,8 @@ class ForwardDeclChecker : public Checker<check::ASTDecl<TranslationUnitDecl>> {
auto Name = R->getName();
return !R->hasDefinition() && !RTC.isUnretained(QT) &&
!SystemTypes.contains(CanonicalType) &&
!Name.starts_with("Opaque") && Name != "_NSZone";
!SystemTypes.contains(PointeeType) && !Name.starts_with("Opaque") &&
Name != "_NSZone";
}

void visitRecordDecl(const RecordDecl *RD, const Decl *DeclWithIssue) const {
Expand Down
4 changes: 4 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/forward-decl-checker.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

Obj* provide_obj_ptr();
void receive_obj_ptr(Obj* p = nullptr);
sqlite3* open_db();
void close_db(sqlite3*);

Obj* ptr(Obj* arg) {
receive_obj_ptr(provide_obj_ptr());
Expand All @@ -34,6 +36,8 @@
receive_obj_ptr(arg);
receive_obj_ptr(nullptr);
receive_obj_ptr();
auto* db = open_db();
close_db(db);
return obj;
}

Expand Down
2 changes: 2 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/mock-system-header.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct MemberVariable {
T* obj { nullptr };
};

typedef struct sqlite3 sqlite3;

typedef unsigned char uint8_t;

enum os_log_type_t : uint8_t {
Expand Down