From 97915e5a0224e77892b8eed732c341fa940aa700 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 19 Dec 2013 02:39:40 +0000 Subject: [PATCH] Replacing calls to getAttr with calls to hasAttr for clarity. No functional change intended -- this only replaces Boolean uses of getAttr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197648 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ARCMigrate/ObjCMT.cpp | 32 +++++++++---------- lib/ARCMigrate/TransUnbridgedCasts.cpp | 6 ++-- lib/ARCMigrate/Transforms.cpp | 2 +- lib/AST/Decl.cpp | 2 +- lib/AST/Expr.cpp | 6 ++-- lib/Analysis/ThreadSafety.cpp | 8 ++--- lib/CodeGen/CodeGenModule.cpp | 8 ++--- lib/CodeGen/TargetInfo.cpp | 2 +- lib/Sema/SemaDecl.cpp | 24 +++++++------- lib/Sema/SemaDeclAttr.cpp | 10 +++--- lib/Sema/SemaExpr.cpp | 2 +- lib/Sema/SemaObjCProperty.cpp | 4 +-- lib/Sema/SemaStmt.cpp | 8 ++--- .../Checkers/CheckObjCDealloc.cpp | 4 +-- .../Checkers/DeadStoresChecker.cpp | 4 +-- .../Checkers/NoReturnFunctionChecker.cpp | 2 +- .../Checkers/ObjCUnusedIVarsChecker.cpp | 4 +-- .../Checkers/RetainCountChecker.cpp | 28 ++++++++-------- .../Checkers/UndefCapturedBlockVarChecker.cpp | 2 +- lib/StaticAnalyzer/Core/MemRegion.cpp | 2 +- lib/StaticAnalyzer/Core/RegionStore.cpp | 2 +- 21 files changed, 80 insertions(+), 82 deletions(-) diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index e12df0582f..4a37a5441e 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -1374,13 +1374,13 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx, pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) { const ParmVarDecl *pd = *pi; ArgEffect AE = AEArgs[i]; - if (AE == DecRef && !pd->getAttr() && + if (AE == DecRef && !pd->hasAttr() && Ctx.Idents.get("CF_CONSUMED").hasMacroDefinition()) { edit::Commit commit(*Editor); commit.insertBefore(pd->getLocation(), "CF_CONSUMED "); Editor->commit(commit); } - else if (AE == DecRefMsg && !pd->getAttr() && + else if (AE == DecRefMsg && !pd->hasAttr() && Ctx.Idents.get("NS_CONSUMED").hasMacroDefinition()) { edit::Commit commit(*Editor); commit.insertBefore(pd->getLocation(), "NS_CONSUMED "); @@ -1398,11 +1398,11 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND return CF_BRIDGING_NONE; CallEffects CE = CallEffects::getEffect(FuncDecl); - bool FuncIsReturnAnnotated = (FuncDecl->getAttr() || - FuncDecl->getAttr() || - FuncDecl->getAttr() || - FuncDecl->getAttr() || - FuncDecl->getAttr()); + bool FuncIsReturnAnnotated = (FuncDecl->hasAttr() || + FuncDecl->hasAttr() || + FuncDecl->hasAttr() || + FuncDecl->hasAttr() || + FuncDecl->hasAttr()); // Trivial case of when funciton is annotated and has no argument. if (FuncIsReturnAnnotated && FuncDecl->getNumParams() == 0) @@ -1428,7 +1428,7 @@ ObjCMigrateASTConsumer::CF_BRIDGING_KIND const ParmVarDecl *pd = *pi; ArgEffect AE = AEArgs[i]; if (AE == DecRef /*CFConsumed annotated*/ || AE == IncRef) { - if (AE == DecRef && !pd->getAttr()) + if (AE == DecRef && !pd->hasAttr()) ArgCFAudited = true; else if (AE == IncRef) ArgCFAudited = true; @@ -1507,7 +1507,7 @@ void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx, pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) { const ParmVarDecl *pd = *pi; ArgEffect AE = AEArgs[i]; - if (AE == DecRef && !pd->getAttr() && + if (AE == DecRef && !pd->hasAttr() && Ctx.Idents.get("CF_CONSUMED").hasMacroDefinition()) { edit::Commit commit(*Editor); commit.insertBefore(pd->getLocation(), "CF_CONSUMED "); @@ -1523,14 +1523,14 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation( return; CallEffects CE = CallEffects::getEffect(MethodDecl); - bool MethodIsReturnAnnotated = (MethodDecl->getAttr() || - MethodDecl->getAttr() || - MethodDecl->getAttr() || - MethodDecl->getAttr() || - MethodDecl->getAttr()); + bool MethodIsReturnAnnotated = (MethodDecl->hasAttr() || + MethodDecl->hasAttr() || + MethodDecl->hasAttr() || + MethodDecl->hasAttr() || + MethodDecl->hasAttr()); if (CE.getReceiver() == DecRefMsg && - !MethodDecl->getAttr() && + !MethodDecl->hasAttr() && MethodDecl->getMethodFamily() != OMF_init && MethodDecl->getMethodFamily() != OMF_release && Ctx.Idents.get("NS_CONSUMES_SELF").hasMacroDefinition()) { @@ -1564,7 +1564,7 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation( pe = MethodDecl->param_end(); pi != pe; ++pi, ++i) { const ParmVarDecl *pd = *pi; ArgEffect AE = AEArgs[i]; - if ((AE == DecRef && !pd->getAttr()) || AE == IncRef || + if ((AE == DecRef && !pd->hasAttr()) || AE == IncRef || !AuditedType(pd->getType())) { AddCFAnnotations(Ctx, CE, MethodDecl, MethodIsReturnAnnotated); return; diff --git a/lib/ARCMigrate/TransUnbridgedCasts.cpp b/lib/ARCMigrate/TransUnbridgedCasts.cpp index 7b360c640c..76973dceca 100644 --- a/lib/ARCMigrate/TransUnbridgedCasts.cpp +++ b/lib/ARCMigrate/TransUnbridgedCasts.cpp @@ -133,11 +133,11 @@ private: Expr *inner = E->IgnoreParenCasts(); if (CallExpr *callE = dyn_cast(inner)) { if (FunctionDecl *FD = callE->getDirectCallee()) { - if (FD->getAttr()) { + if (FD->hasAttr()) { castToObjCObject(E, /*retained=*/true); return; } - if (FD->getAttr()) { + if (FD->hasAttr()) { castToObjCObject(E, /*retained=*/false); return; } @@ -439,7 +439,7 @@ private: } if (i < callE->getNumArgs() && i < FD->getNumParams()) { ParmVarDecl *PD = FD->getParamDecl(i); - if (PD->getAttr()) { + if (PD->hasAttr()) { isConsumed = true; return true; } diff --git a/lib/ARCMigrate/Transforms.cpp b/lib/ARCMigrate/Transforms.cpp index 679b924ba0..274c02507e 100644 --- a/lib/ARCMigrate/Transforms.cpp +++ b/lib/ARCMigrate/Transforms.cpp @@ -88,7 +88,7 @@ bool trans::isPlusOne(const Expr *E) { if (const CallExpr * callE = dyn_cast(E->IgnoreParenCasts())) { if (const FunctionDecl *FD = callE->getDirectCallee()) { - if (FD->getAttr()) + if (FD->hasAttr()) return true; if (FD->isGlobal() && diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 83f2c53a7c..ef8128295e 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -2486,7 +2486,7 @@ unsigned FunctionDecl::getBuiltinID() const { // If the function is marked "overloadable", it has a different mangled name // and is not the C library function. - if (getAttr()) + if (hasAttr()) return 0; if (!Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 6060f8bf2f..4f08655806 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -2083,8 +2083,8 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc, // // Note: If new cases are added here, DiagnoseUnusedExprResult should be // updated to match for QoI. - if (FD->getAttr() || - FD->getAttr() || FD->getAttr()) { + if (FD->hasAttr() || + FD->hasAttr() || FD->hasAttr()) { WarnE = this; Loc = CE->getCallee()->getLocStart(); R1 = CE->getCallee()->getSourceRange(); @@ -2129,7 +2129,7 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc, } const ObjCMethodDecl *MD = ME->getMethodDecl(); - if (MD && MD->getAttr()) { + if (MD && MD->hasAttr()) { WarnE = this; Loc = getExprLoc(); return true; diff --git a/lib/Analysis/ThreadSafety.cpp b/lib/Analysis/ThreadSafety.cpp index 2ab8fefd32..1d4d585332 100644 --- a/lib/Analysis/ThreadSafety.cpp +++ b/lib/Analysis/ThreadSafety.cpp @@ -1896,7 +1896,7 @@ void BuildLockset::checkAccess(const Expr *Exp, AccessKind AK) { if (!D || !D->hasAttrs()) return; - if (D->getAttr() && FSet.isEmpty()) + if (D->hasAttr() && FSet.isEmpty()) Analyzer->Handler.handleNoMutexHeld(D, POK_VarAccess, AK, Exp->getExprLoc()); @@ -1934,7 +1934,7 @@ void BuildLockset::checkPtAccess(const Expr *Exp, AccessKind AK) { if (!D || !D->hasAttrs()) return; - if (D->getAttr() && FSet.isEmpty()) + if (D->hasAttr() && FSet.isEmpty()) Analyzer->Handler.handleNoMutexHeld(D, POK_VarDereference, AK, Exp->getExprLoc()); @@ -2054,7 +2054,7 @@ void BuildLockset::handleCall(Expr *Exp, const NamedDecl *D, VarDecl *VD) { if (VD) { if (const CXXConstructorDecl *CD = dyn_cast(D)) { const CXXRecordDecl* PD = CD->getParent(); - if (PD && PD->getAttr()) + if (PD && PD->hasAttr()) isScopedVar = true; } } @@ -2342,7 +2342,7 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) { if (!D) return; // Ignore anonymous functions for now. - if (D->getAttr()) + if (D->hasAttr()) return; // FIXME: Do something a bit more intelligent inside constructor and // destructor code. Constructors and destructors must assume unique access diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 0d6ba33aad..e72abb10a4 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1941,11 +1941,11 @@ CodeGenModule::GetLLVMLinkageVarDefinition(const VarDecl *D, bool isConstant) { Linkage == GVA_ExplicitTemplateInstantiation) return llvm::GlobalVariable::WeakODRLinkage; else if (!getLangOpts().CPlusPlus && - ((!CodeGenOpts.NoCommon && !D->getAttr()) || - D->getAttr()) && + ((!CodeGenOpts.NoCommon && !D->hasAttr()) || + D->hasAttr()) && !D->hasExternalStorage() && !D->getInit() && - !D->getAttr() && !D->getTLSKind() && - !D->getAttr()) { + !D->hasAttr() && !D->getTLSKind() && + !D->hasAttr()) { // Thread local vars aren't considered common linkage. return llvm::GlobalVariable::CommonLinkage; } else if (D->getTLSKind() == VarDecl::TLS_Dynamic && diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index 6b756457e8..f5278c0345 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -4279,7 +4279,7 @@ SetTargetAttributes(const Decl *D, llvm::GlobalValue *GV, // CUDA __global__ functions get a kernel metadata entry. Since // __global__ functions cannot be called from the device, we do not // need to set the noinline attribute. - if (FD->getAttr()) + if (FD->hasAttr()) addKernelMetadata(F); } } diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 7d9c25ed2d..8cc489b3f6 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3035,9 +3035,9 @@ void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) { mergeDeclAttributes(New, Old); // Warn if an already-declared variable is made a weak_import in a subsequent // declaration - if (New->getAttr() && + if (New->hasAttr() && Old->getStorageClass() == SC_None && - !Old->getAttr()) { + !Old->hasAttr()) { Diag(New->getLocation(), diag::warn_weak_import) << New->getDeclName(); Diag(Old->getLocation(), diag::note_previous_definition); // Remove weak_import attribute on new declaration. @@ -9673,7 +9673,7 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) { // Checking attributes of current function definition // dllimport attribute. DLLImportAttr *DA = FD->getAttr(); - if (DA && (!FD->getAttr())) { + if (DA && (!FD->hasAttr())) { // dllimport attribute cannot be directly applied to definition. // Microsoft accepts dllimport for functions defined within class scope. if (!DA->isInherited() && @@ -10065,7 +10065,7 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { unsigned FormatIdx; bool HasVAListArg; if (Context.BuiltinInfo.isPrintfLike(BuiltinID, FormatIdx, HasVAListArg)) { - if (!FD->getAttr()) { + if (!FD->hasAttr()) { const char *fmt = "printf"; unsigned int NumParams = FD->getNumParams(); if (FormatIdx < NumParams && // NumParams may be 0 (e.g. vfprintf) @@ -10079,7 +10079,7 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { } if (Context.BuiltinInfo.isScanfLike(BuiltinID, FormatIdx, HasVAListArg)) { - if (!FD->getAttr()) + if (!FD->hasAttr()) FD->addAttr(::new (Context) FormatAttr(FD->getLocation(), Context, &Context.Idents.get("scanf"), FormatIdx+1, @@ -10091,16 +10091,16 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { // IRgen to use LLVM intrinsics for such functions. if (!getLangOpts().MathErrno && Context.BuiltinInfo.isConstWithoutErrno(BuiltinID)) { - if (!FD->getAttr()) + if (!FD->hasAttr()) FD->addAttr(::new (Context) ConstAttr(FD->getLocation(), Context)); } if (Context.BuiltinInfo.isReturnsTwice(BuiltinID) && - !FD->getAttr()) + !FD->hasAttr()) FD->addAttr(::new (Context) ReturnsTwiceAttr(FD->getLocation(), Context)); - if (Context.BuiltinInfo.isNoThrow(BuiltinID) && !FD->getAttr()) + if (Context.BuiltinInfo.isNoThrow(BuiltinID) && !FD->hasAttr()) FD->addAttr(::new (Context) NoThrowAttr(FD->getLocation(), Context)); - if (Context.BuiltinInfo.isConst(BuiltinID) && !FD->getAttr()) + if (Context.BuiltinInfo.isConst(BuiltinID) && !FD->hasAttr()) FD->addAttr(::new (Context) ConstAttr(FD->getLocation(), Context)); } @@ -10120,7 +10120,7 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { if (Name->isStr("asprintf") || Name->isStr("vasprintf")) { // FIXME: asprintf and vasprintf aren't C99 functions. Should they be // target-specific builtins, perhaps? - if (!FD->getAttr()) + if (!FD->hasAttr()) FD->addAttr(::new (Context) FormatAttr(FD->getLocation(), Context, &Context.Idents.get("printf"), 2, Name->isStr("vasprintf") ? 0 : 3)); @@ -10129,7 +10129,7 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { if (Name->isStr("__CFStringMakeConstantString")) { // We already have a __builtin___CFStringMakeConstantString, // but builds that use -fno-constant-cfstrings don't go through that. - if (!FD->getAttr()) + if (!FD->hasAttr()) FD->addAttr(::new (Context) FormatArgAttr(FD->getLocation(), Context, 1)); } } @@ -12784,7 +12784,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, // The C99 rule is modified by a gcc extension QualType BestPromotionType; - bool Packed = Enum->getAttr() ? true : false; + bool Packed = Enum->hasAttr(); // -fshort-enums is the equivalent to specifying the packed attribute on all // enum definitions. if (LangOpts.ShortEnums) diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 376d75ce6f..a6240368bf 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -421,9 +421,7 @@ static const RecordType *getRecordType(QualType QT) { static bool checkBaseClassIsLockableCallback(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, void *Unused) { const RecordType *RT = Specifier->getType()->getAs(); - if (RT->getDecl()->getAttr()) - return true; - return false; + return RT->getDecl()->hasAttr(); } @@ -451,7 +449,7 @@ static void checkForLockableRecord(Sema &S, Decl *D, const AttributeList &Attr, // Check if the type is lockable. RecordDecl *RD = RT->getDecl(); - if (RD->getAttr()) + if (RD->hasAttr()) return; // Else check if any base classes are lockable. @@ -602,7 +600,7 @@ static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, QualType QT = cast(D)->getType(); if (!QT->isDependentType()) { const RecordType *RT = getRecordType(QT); - if (!RT || !RT->getDecl()->getAttr()) { + if (!RT || !RT->getDecl()->hasAttr()) { S.Diag(Attr.getLoc(), diag::warn_thread_attribute_decl_not_lockable) << Attr.getName(); return false; @@ -1607,7 +1605,7 @@ static void handleVecReturnAttr(Sema &S, Decl *D, const AttributeList &Attr) { return result; // This will be returned in a register } */ - if (D->getAttr()) { + if (D->hasAttr()) { S.Diag(Attr.getLoc(), diag::err_repeat_attribute) << "vecreturn"; return; } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 3bc221fb7e..3ead6ec984 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -10363,7 +10363,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, if (!BSI->ReturnType.isNull()) RetTy = BSI->ReturnType; - bool NoReturn = BSI->TheDecl->getAttr(); + bool NoReturn = BSI->TheDecl->hasAttr(); QualType BlockTy; // Set the captured variables on the block. diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 61e58c4bef..a1d74273d7 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -2060,7 +2060,7 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl, if ((Attributes & (ObjCDeclSpec::DQ_PR_weak | ObjCDeclSpec::DQ_PR_copy | ObjCDeclSpec::DQ_PR_retain | ObjCDeclSpec::DQ_PR_strong)) && !PropertyTy->isObjCRetainableType() && - !PropertyDecl->getAttr()) { + !PropertyDecl->hasAttr()) { Diag(Loc, diag::err_objc_property_requires_object) << (Attributes & ObjCDeclSpec::DQ_PR_weak ? "weak" : Attributes & ObjCDeclSpec::DQ_PR_copy ? "copy" : "retain (or strong)"); @@ -2092,7 +2092,7 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl, << "assign" << "weak"; Attributes &= ~ObjCDeclSpec::DQ_PR_weak; } - if (PropertyDecl->getAttr()) + if (PropertyDecl->hasAttr()) Diag(Loc, diag::warn_iboutletcollection_property_assign); } else if (Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained) { if (Attributes & ObjCDeclSpec::DQ_PR_copy) { diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 1d2ebad788..e4fe9c324c 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -216,17 +216,17 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) { // is written in a macro body, only warn if it has the warn_unused_result // attribute. if (const Decl *FD = CE->getCalleeDecl()) { - if (FD->getAttr()) { + if (FD->hasAttr()) { Diag(Loc, diag::warn_unused_result) << R1 << R2; return; } if (ShouldSuppress) return; - if (FD->getAttr()) { + if (FD->hasAttr()) { Diag(Loc, diag::warn_unused_call) << R1 << R2 << "pure"; return; } - if (FD->getAttr()) { + if (FD->hasAttr()) { Diag(Loc, diag::warn_unused_call) << R1 << R2 << "const"; return; } @@ -240,7 +240,7 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) { return; } const ObjCMethodDecl *MD = ME->getMethodDecl(); - if (MD && MD->getAttr()) { + if (MD && MD->hasAttr()) { Diag(Loc, diag::warn_unused_result) << R1 << R2; return; } diff --git a/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp b/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp index 3f9b3cc7f8..0ea5717037 100644 --- a/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp +++ b/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp @@ -119,8 +119,8 @@ static void checkObjCDealloc(const ObjCImplementationDecl *D, QualType T = ID->getType(); if (!T->isObjCObjectPointerType() || - ID->getAttr() || // Skip IBOutlets. - ID->getAttr()) // Skip IBOutletCollections. + ID->hasAttr() || // Skip IBOutlets. + ID->hasAttr()) // Skip IBOutletCollections. continue; containsPointerIvar = true; diff --git a/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp b/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp index 9d855ce649..3468140c91 100644 --- a/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp @@ -214,7 +214,7 @@ public: return; if (!isLive(Live, VD) && - !(VD->getAttr() || VD->getAttr())) { + !(VD->hasAttr() || VD->hasAttr())) { PathDiagnosticLocation ExLoc = PathDiagnosticLocation::createBegin(Ex, BR.getSourceManager(), AC); @@ -340,7 +340,7 @@ public: // A dead initialization is a variable that is dead after it // is initialized. We don't flag warnings for those variables // marked 'unused'. - if (!isLive(Live, V) && V->getAttr() == 0) { + if (!isLive(Live, V) && !V->hasAttr()) { // Special case: check for initializations with constants. // // e.g. : int x = 0; diff --git a/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp b/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp index 33df6a37bc..f7c9bc2c17 100644 --- a/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp @@ -40,7 +40,7 @@ void NoReturnFunctionChecker::checkPostCall(const CallEvent &CE, bool BuildSinks = false; if (const FunctionDecl *FD = dyn_cast_or_null(CE.getDecl())) - BuildSinks = FD->getAttr() || FD->isNoReturn(); + BuildSinks = FD->hasAttr() || FD->isNoReturn(); const Expr *Callee = CE.getOriginExpr(); if (!BuildSinks && Callee) diff --git a/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp index c66c7d0193..99cbe4b345 100644 --- a/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp @@ -128,8 +128,8 @@ static void checkObjCUnusedIvar(const ObjCImplementationDecl *D, // (c) are iboutlets // (d) are unnamed bitfields if (ID->getAccessControl() != ObjCIvarDecl::Private || - ID->getAttr() || ID->getAttr() || - ID->getAttr() || + ID->hasAttr() || ID->hasAttr() || + ID->hasAttr() || ID->isUnnamedBitfield()) continue; diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index c474e78310..16d01d8e6f 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -1102,7 +1102,7 @@ RetainSummaryManager::getFunctionSummary(const FunctionDecl *FD) { break; } - if (FD->getAttr()) { + if (FD->hasAttr()) { S = getCFCreateGetRuleSummary(FD); break; } @@ -1214,21 +1214,21 @@ Optional RetainSummaryManager::getRetEffectFromAnnotations(QualType RetTy, const Decl *D) { if (cocoa::isCocoaObjectRef(RetTy)) { - if (D->getAttr()) + if (D->hasAttr()) return ObjCAllocRetE; - if (D->getAttr() || - D->getAttr()) + if (D->hasAttr() || + D->hasAttr()) return RetEffect::MakeNotOwned(RetEffect::ObjC); } else if (!RetTy->isPointerType()) { return None; } - if (D->getAttr()) + if (D->hasAttr()) return RetEffect::MakeOwned(RetEffect::CF, true); - if (D->getAttr()) + if (D->hasAttr()) return RetEffect::MakeNotOwned(RetEffect::CF); return None; @@ -1248,9 +1248,9 @@ RetainSummaryManager::updateSummaryFromAnnotations(const RetainSummary *&Summ, for (FunctionDecl::param_const_iterator pi = FD->param_begin(), pe = FD->param_end(); pi != pe; ++pi, ++parm_idx) { const ParmVarDecl *pd = *pi; - if (pd->getAttr()) + if (pd->hasAttr()) Template->addArg(AF, parm_idx, DecRefMsg); - else if (pd->getAttr()) + else if (pd->hasAttr()) Template->addArg(AF, parm_idx, DecRef); } @@ -1269,7 +1269,7 @@ RetainSummaryManager::updateSummaryFromAnnotations(const RetainSummary *&Summ, RetainSummaryTemplate Template(Summ, *this); // Effects on the receiver. - if (MD->getAttr()) + if (MD->hasAttr()) Template->setReceiverEffect(DecRefMsg); // Effects on the parameters. @@ -1278,9 +1278,9 @@ RetainSummaryManager::updateSummaryFromAnnotations(const RetainSummary *&Summ, pi=MD->param_begin(), pe=MD->param_end(); pi != pe; ++pi, ++parm_idx) { const ParmVarDecl *pd = *pi; - if (pd->getAttr()) + if (pd->hasAttr()) Template->addArg(AF, parm_idx, DecRefMsg); - else if (pd->getAttr()) { + else if (pd->hasAttr()) { Template->addArg(AF, parm_idx, DecRef); } } @@ -2212,9 +2212,9 @@ CFRefLeakReportVisitor::getEndPath(BugReporterContext &BRC, os << (isa(D) ? " is returned from a method " : " is returned from a function "); - if (D->getAttr()) + if (D->hasAttr()) os << "that is annotated as CF_RETURNS_NOT_RETAINED"; - else if (D->getAttr()) + else if (D->hasAttr()) os << "that is annotated as NS_RETURNS_NOT_RETAINED"; else { if (const ObjCMethodDecl *MD = dyn_cast(D)) { @@ -3375,7 +3375,7 @@ void RetainCountChecker::checkBind(SVal loc, SVal val, const Stmt *S, // false positives. if (const VarRegion *LVR = dyn_cast_or_null(loc.getAsRegion())) { const VarDecl *VD = LVR->getDecl(); - if (VD->getAttr()) { + if (VD->hasAttr()) { escapes = true; } } diff --git a/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp b/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp index 93812f7148..e746028cea 100644 --- a/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UndefCapturedBlockVarChecker.cpp @@ -71,7 +71,7 @@ UndefCapturedBlockVarChecker::checkPostStmt(const BlockExpr *BE, const VarRegion *VR = I.getCapturedRegion(); const VarDecl *VD = VR->getDecl(); - if (VD->getAttr() || !VD->hasLocalStorage()) + if (VD->hasAttr() || !VD->hasLocalStorage()) continue; // Get the VarRegion associated with VD in the local stack frame. diff --git a/lib/StaticAnalyzer/Core/MemRegion.cpp b/lib/StaticAnalyzer/Core/MemRegion.cpp index 162cd33264..fd96e2b324 100644 --- a/lib/StaticAnalyzer/Core/MemRegion.cpp +++ b/lib/StaticAnalyzer/Core/MemRegion.cpp @@ -1363,7 +1363,7 @@ BlockDataRegion::getCaptureRegions(const VarDecl *VD) { const VarRegion *VR = 0; const VarRegion *OriginalVR = 0; - if (!VD->getAttr() && VD->hasLocalStorage()) { + if (!VD->hasAttr() && VD->hasLocalStorage()) { VR = MemMgr.getVarRegion(VD, this); OriginalVR = MemMgr.getVarRegion(VD, LC); } diff --git a/lib/StaticAnalyzer/Core/RegionStore.cpp b/lib/StaticAnalyzer/Core/RegionStore.cpp index 0b519768aa..58f21214e1 100644 --- a/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1016,7 +1016,7 @@ void invalidateRegionsWorker::VisitCluster(const MemRegion *baseR, BI != BE; ++BI) { const VarRegion *VR = BI.getCapturedRegion(); const VarDecl *VD = VR->getDecl(); - if (VD->getAttr() || !VD->hasLocalStorage()) { + if (VD->hasAttr() || !VD->hasLocalStorage()) { AddToWorkList(VR); } else if (Loc::isLocType(VR->getValueType())) { -- 2.40.0