github-actions[bot] wrote: <!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning: <details> <summary> You can test this locally with the following command: </summary> ``````````bash git-clang-format --diff b06954a5d02a41a38b72f7914c791428ccd95318 5abb2493cfc67f2bd1dcdd946ed9ecbef8929d2b --extensions h,cpp -- clang/test/Analysis/Checkers/WebKit/unchecked-members.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h clang/test/Analysis/Checkers/WebKit/mock-types.h clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp `````````` </details> <details> <summary> View the diff from clang-format here. </summary> ``````````diff diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp index 0929810299..7084a09a03 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp @@ -55,8 +55,7 @@ hasPublicMethodInBase(const CXXBaseSpecifier *Base, const char *NameToMatch) { std::optional<bool> isSmartPtrCompatible(const CXXRecordDecl *R, const char *IncMethodName, - const char *DecMethodName) -{ + const char *DecMethodName) { assert(R); R = R->getDefinition(); @@ -72,15 +71,15 @@ std::optional<bool> isSmartPtrCompatible(const CXXRecordDecl *R, Paths.setOrigin(const_cast<CXXRecordDecl *>(R)); bool AnyInconclusiveBase = false; - const auto hasPublicRefInBase = - [&](const CXXBaseSpecifier *Base, CXXBasePath &) { - auto hasRefInBase = clang::hasPublicMethodInBase(Base, IncMethodName); - if (!hasRefInBase) { - AnyInconclusiveBase = true; - return false; - } - return (*hasRefInBase) != nullptr; - }; + const auto hasPublicRefInBase = [&](const CXXBaseSpecifier *Base, + CXXBasePath &) { + auto hasRefInBase = clang::hasPublicMethodInBase(Base, IncMethodName); + if (!hasRefInBase) { + AnyInconclusiveBase = true; + return false; + } + return (*hasRefInBase) != nullptr; + }; hasRef = hasRef || R->lookupInBases(hasPublicRefInBase, Paths, /*LookupInDependent =*/true); @@ -88,15 +87,15 @@ std::optional<bool> isSmartPtrCompatible(const CXXRecordDecl *R, return std::nullopt; Paths.clear(); - const auto hasPublicDerefInBase = - [&](const CXXBaseSpecifier *Base, CXXBasePath &) { - auto hasDerefInBase = clang::hasPublicMethodInBase(Base, DecMethodName); - if (!hasDerefInBase) { - AnyInconclusiveBase = true; - return false; - } - return (*hasDerefInBase) != nullptr; - }; + const auto hasPublicDerefInBase = [&](const CXXBaseSpecifier *Base, + CXXBasePath &) { + auto hasDerefInBase = clang::hasPublicMethodInBase(Base, DecMethodName); + if (!hasDerefInBase) { + AnyInconclusiveBase = true; + return false; + } + return (*hasDerefInBase) != nullptr; + }; hasDeref = hasDeref || R->lookupInBases(hasPublicDerefInBase, Paths, /*LookupInDependent =*/true); if (AnyInconclusiveBase) diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h index 08f9be4997..d58e54d448 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h @@ -42,7 +42,7 @@ std::optional<bool> isRefCountable(const clang::CXXRecordDecl* Class); /// \returns true if \p Class is checked-pointer compatible, false if not, /// std::nullopt if inconclusive. -std::optional<bool> isCheckedPtrCapable(const clang::CXXRecordDecl* Class); +std::optional<bool> isCheckedPtrCapable(const clang::CXXRecordDecl *Class); /// \returns true if \p Class is ref-counted, false if not. bool isRefCounted(const clang::CXXRecordDecl *Class); diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp index 9ea0abbee9..54d89e29a5 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp @@ -35,10 +35,11 @@ public: RawPtrRefMemberChecker(const char *description) : Bug(this, description, "WebKit coding guidelines") {} - virtual std::optional<bool> isPtrCompatible(const clang::CXXRecordDecl *) const = 0; + virtual std::optional<bool> + isPtrCompatible(const clang::CXXRecordDecl *) const = 0; virtual bool isPtrCls(const clang::CXXRecordDecl *) const = 0; - virtual const char* typeName() const = 0; - virtual const char* invariantName() const = 0; + virtual const char *typeName() const = 0; + virtual const char *invariantName() const = 0; void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager &MGR, BugReporter &BRArg) const { @@ -79,9 +80,9 @@ public: if (auto *MemberCXXRD = MemberType->getPointeeCXXRecordDecl()) { // If we don't see the definition we just don't know. if (MemberCXXRD->hasDefinition()) { - std::optional<bool> isRCAble = isPtrCompatible(MemberCXXRD); - if (isRCAble && *isRCAble) - reportBug(Member, MemberType, MemberCXXRD, RD); + std::optional<bool> isRCAble = isPtrCompatible(MemberCXXRD); + if (isRCAble && *isRCAble) + reportBug(Member, MemberType, MemberCXXRD, RD); } } } @@ -136,14 +137,10 @@ public: Os << " in "; printQuotedQualifiedName(Os, ClassCXXRD); Os << " is a " - << (isa<PointerType>(MemberType) ? "raw pointer" : "reference") - << " to " - << typeName() - << " "; + << (isa<PointerType>(MemberType) ? "raw pointer" : "reference") << " to " + << typeName() << " "; printQuotedQualifiedName(Os, MemberCXXRD); - Os << "; " - << invariantName() - << "."; + Os << "; " << invariantName() << "."; PathDiagnosticLocation BSLoc(Member->getSourceRange().getBegin(), BR->getSourceManager()); @@ -159,7 +156,8 @@ public: : RawPtrRefMemberChecker("Member variable is a raw-pointer/reference to " "reference-countable type") {} - std::optional<bool> isPtrCompatible(const clang::CXXRecordDecl *R) const final { + std::optional<bool> + isPtrCompatible(const clang::CXXRecordDecl *R) const final { return isRefCountable(R); } @@ -167,11 +165,9 @@ public: return isRefCounted(R); } - const char* typeName() const final { - return "ref-countable type"; - } + const char *typeName() const final { return "ref-countable type"; } - const char* invariantName() const final { + const char *invariantName() const final { return "member variables must be Ref, RefPtr, WeakRef, or WeakPtr"; } }; @@ -182,7 +178,8 @@ public: : RawPtrRefMemberChecker("Member variable is a raw-pointer/reference to " "checked-pointer capable type") {} - std::optional<bool> isPtrCompatible(const clang::CXXRecordDecl *R) const final { + std::optional<bool> + isPtrCompatible(const clang::CXXRecordDecl *R) const final { return isCheckedPtrCapable(R); } @@ -190,12 +187,11 @@ public: return isCheckedPtr(R); } - const char* typeName() const final { - return "CheckedPtr capable type"; - } + const char *typeName() const final { return "CheckedPtr capable type"; } - const char* invariantName() const final { - return "member variables must be a CheckedPtr, CheckedRef, WeakRef, or WeakPtr"; + const char *invariantName() const final { + return "member variables must be a CheckedPtr, CheckedRef, WeakRef, or " + "WeakPtr"; } }; @@ -205,8 +201,7 @@ void ento::registerNoUncountedMemberChecker(CheckerManager &Mgr) { Mgr.registerChecker<NoUncountedMemberChecker>(); } -bool ento::shouldRegisterNoUncountedMemberChecker( - const CheckerManager &Mgr) { +bool ento::shouldRegisterNoUncountedMemberChecker(const CheckerManager &Mgr) { return true; } `````````` </details> https://github.com/llvm/llvm-project/pull/108352 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits