r256498 - Refactor: Simplify boolean conditional return statements in tools/libclang

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 28 07:24:08 PST 2015


Author: alexfh
Date: Mon Dec 28 09:24:08 2015
New Revision: 256498

URL: http://llvm.org/viewvc/llvm-project?rev=256498&view=rev
Log:
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

Modified:
    cfe/trunk/tools/libclang/CIndex.cpp
    cfe/trunk/tools/libclang/Indexing.cpp
    cfe/trunk/tools/libclang/IndexingContext.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=256498&r1=256497&r2=256498&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Dec 28 09:24:08 2015
@@ -717,11 +717,8 @@ bool CursorVisitor::VisitClassTemplateSp
           return true;
     }
   }
-  
-  if (ShouldVisitBody && VisitCXXRecordDecl(D))
-    return true;
-  
-  return false;
+
+  return ShouldVisitBody && VisitCXXRecordDecl(D);
 }
 
 bool CursorVisitor::VisitClassTemplatePartialSpecializationDecl(
@@ -946,11 +943,8 @@ bool CursorVisitor::VisitObjCMethodDecl(
       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 <typename DeclIt>
@@ -6239,10 +6233,7 @@ static bool lexNext(Lexer &Lex, Token &T
 
   ++NextIdx;
   Lex.LexFromRawLexer(Tok);
-  if (Tok.is(tok::eof))
-    return true;
-
-  return false;
+  return Tok.is(tok::eof);
 }
 
 static void annotatePreprocessorTokens(CXTranslationUnit TU,

Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=256498&r1=256497&r2=256498&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Mon Dec 28 09:24:08 2015
@@ -681,9 +681,7 @@ static void indexPreprocessingRecord(AST
 static bool topLevelDeclVisitor(void *context, const Decl *D) {
   IndexingContext &IdxCtx = *static_cast<IndexingContext*>(context);
   IdxCtx.indexTopLevelDecl(D);
-  if (IdxCtx.shouldAbort())
-    return false;
-  return true;
+  return !IdxCtx.shouldAbort();
 }
 
 static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IdxCtx) {

Modified: cfe/trunk/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.cpp?rev=256498&r1=256497&r2=256498&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.cpp (original)
+++ cfe/trunk/tools/libclang/IndexingContext.cpp Mon Dec 28 09:24:08 2015
@@ -804,10 +804,7 @@ bool IndexingContext::markEntityOccurren
   RefFileOccurrence RefOccur(FE, D);
   std::pair<llvm::DenseSet<RefFileOccurrence>::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 {




More information about the cfe-commits mailing list