From: Alexander Kornienko Date: Mon, 28 Dec 2015 15:24:08 +0000 (+0000) Subject: Refactor: Simplify boolean conditional return statements in tools/libclang X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dfd3c7281b3615853877bec1a588b1fbf928426f;p=clang Refactor: Simplify boolean conditional return statements in tools/libclang Summary: Use clang-tidy to simplify boolean conditional return statements. Reviewers: alexfh Subscribers: alexfh, chfast, cfe-commits Patch by Richard Thomson! Differential Revision: http://reviews.llvm.org/D10024 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256498 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 11cd7bc25d..477bf0902b 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -717,11 +717,8 @@ bool CursorVisitor::VisitClassTemplateSpecializationDecl( return true; } } - - if (ShouldVisitBody && VisitCXXRecordDecl(D)) - return true; - - return false; + + return ShouldVisitBody && VisitCXXRecordDecl(D); } bool CursorVisitor::VisitClassTemplatePartialSpecializationDecl( @@ -946,11 +943,8 @@ bool CursorVisitor::VisitObjCMethodDecl(ObjCMethodDecl *ND) { return true; } - if (ND->isThisDeclarationADefinition() && - Visit(MakeCXCursor(ND->getBody(), StmtParent, TU, RegionOfInterest))) - return true; - - return false; + return ND->isThisDeclarationADefinition() && + Visit(MakeCXCursor(ND->getBody(), StmtParent, TU, RegionOfInterest)); } template @@ -6239,10 +6233,7 @@ static bool lexNext(Lexer &Lex, Token &Tok, ++NextIdx; Lex.LexFromRawLexer(Tok); - if (Tok.is(tok::eof)) - return true; - - return false; + return Tok.is(tok::eof); } static void annotatePreprocessorTokens(CXTranslationUnit TU, diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp index 5bfc4245ea..d6e35b0019 100644 --- a/tools/libclang/Indexing.cpp +++ b/tools/libclang/Indexing.cpp @@ -681,9 +681,7 @@ static void indexPreprocessingRecord(ASTUnit &Unit, IndexingContext &IdxCtx) { static bool topLevelDeclVisitor(void *context, const Decl *D) { IndexingContext &IdxCtx = *static_cast(context); IdxCtx.indexTopLevelDecl(D); - if (IdxCtx.shouldAbort()) - return false; - return true; + return !IdxCtx.shouldAbort(); } static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IdxCtx) { diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp index bf6e172fc0..f7640c63e0 100644 --- a/tools/libclang/IndexingContext.cpp +++ b/tools/libclang/IndexingContext.cpp @@ -804,10 +804,7 @@ bool IndexingContext::markEntityOccurrenceInFile(const NamedDecl *D, RefFileOccurrence RefOccur(FE, D); std::pair::iterator, bool> res = RefFileOccurrences.insert(RefOccur); - if (!res.second) - return true; // already in map. - - return false; + return !res.second; // already in map } const NamedDecl *IndexingContext::getEntityDecl(const NamedDecl *D) const {