From: Richard Trieu Date: Fri, 31 May 2013 22:46:45 +0000 (+0000) Subject: Fix the indentation on the AST visitors used in -Wloop-analysis. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=923cadadd2662827ce9029f72d399cf22c443ff9;p=clang Fix the indentation on the AST visitors used in -Wloop-analysis. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183056 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 03af4f1f39..a6b98a2f6a 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -1220,75 +1220,75 @@ namespace { llvm::SmallPtrSet &Decls; SmallVector &Ranges; bool Simple; -public: - typedef EvaluatedExprVisitor Inherited; - - DeclExtractor(Sema &S, llvm::SmallPtrSet &Decls, - SmallVector &Ranges) : - Inherited(S.Context), - Decls(Decls), - Ranges(Ranges), - Simple(true) {} + public: + typedef EvaluatedExprVisitor Inherited; - bool isSimple() { return Simple; } + DeclExtractor(Sema &S, llvm::SmallPtrSet &Decls, + SmallVector &Ranges) : + Inherited(S.Context), + Decls(Decls), + Ranges(Ranges), + Simple(true) {} - // Replaces the method in EvaluatedExprVisitor. - void VisitMemberExpr(MemberExpr* E) { - Simple = false; - } + bool isSimple() { return Simple; } - // Any Stmt not whitelisted will cause the condition to be marked complex. - void VisitStmt(Stmt *S) { - Simple = false; - } + // Replaces the method in EvaluatedExprVisitor. + void VisitMemberExpr(MemberExpr* E) { + Simple = false; + } - void VisitBinaryOperator(BinaryOperator *E) { - Visit(E->getLHS()); - Visit(E->getRHS()); - } + // Any Stmt not whitelisted will cause the condition to be marked complex. + void VisitStmt(Stmt *S) { + Simple = false; + } - void VisitCastExpr(CastExpr *E) { - Visit(E->getSubExpr()); - } + void VisitBinaryOperator(BinaryOperator *E) { + Visit(E->getLHS()); + Visit(E->getRHS()); + } - void VisitUnaryOperator(UnaryOperator *E) { - // Skip checking conditionals with derefernces. - if (E->getOpcode() == UO_Deref) - Simple = false; - else + void VisitCastExpr(CastExpr *E) { Visit(E->getSubExpr()); - } + } - void VisitConditionalOperator(ConditionalOperator *E) { - Visit(E->getCond()); - Visit(E->getTrueExpr()); - Visit(E->getFalseExpr()); - } + void VisitUnaryOperator(UnaryOperator *E) { + // Skip checking conditionals with derefernces. + if (E->getOpcode() == UO_Deref) + Simple = false; + else + Visit(E->getSubExpr()); + } - void VisitParenExpr(ParenExpr *E) { - Visit(E->getSubExpr()); - } + void VisitConditionalOperator(ConditionalOperator *E) { + Visit(E->getCond()); + Visit(E->getTrueExpr()); + Visit(E->getFalseExpr()); + } - void VisitBinaryConditionalOperator(BinaryConditionalOperator *E) { - Visit(E->getOpaqueValue()->getSourceExpr()); - Visit(E->getFalseExpr()); - } + void VisitParenExpr(ParenExpr *E) { + Visit(E->getSubExpr()); + } - void VisitIntegerLiteral(IntegerLiteral *E) { } - void VisitFloatingLiteral(FloatingLiteral *E) { } - void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { } - void VisitCharacterLiteral(CharacterLiteral *E) { } - void VisitGNUNullExpr(GNUNullExpr *E) { } - void VisitImaginaryLiteral(ImaginaryLiteral *E) { } + void VisitBinaryConditionalOperator(BinaryConditionalOperator *E) { + Visit(E->getOpaqueValue()->getSourceExpr()); + Visit(E->getFalseExpr()); + } - void VisitDeclRefExpr(DeclRefExpr *E) { - VarDecl *VD = dyn_cast(E->getDecl()); - if (!VD) return; + void VisitIntegerLiteral(IntegerLiteral *E) { } + void VisitFloatingLiteral(FloatingLiteral *E) { } + void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { } + void VisitCharacterLiteral(CharacterLiteral *E) { } + void VisitGNUNullExpr(GNUNullExpr *E) { } + void VisitImaginaryLiteral(ImaginaryLiteral *E) { } - Ranges.push_back(E->getSourceRange()); + void VisitDeclRefExpr(DeclRefExpr *E) { + VarDecl *VD = dyn_cast(E->getDecl()); + if (!VD) return; - Decls.insert(VD); - } + Ranges.push_back(E->getSourceRange()); + + Decls.insert(VD); + } }; // end class DeclExtractor @@ -1298,66 +1298,67 @@ public: llvm::SmallPtrSet &Decls; bool FoundDecl; -public: - typedef EvaluatedExprVisitor Inherited; + public: + typedef EvaluatedExprVisitor Inherited; - DeclMatcher(Sema &S, llvm::SmallPtrSet &Decls, Stmt *Statement) : - Inherited(S.Context), Decls(Decls), FoundDecl(false) { - if (!Statement) return; + DeclMatcher(Sema &S, llvm::SmallPtrSet &Decls, + Stmt *Statement) : + Inherited(S.Context), Decls(Decls), FoundDecl(false) { + if (!Statement) return; - Visit(Statement); - } + Visit(Statement); + } - void VisitReturnStmt(ReturnStmt *S) { - FoundDecl = true; - } + void VisitReturnStmt(ReturnStmt *S) { + FoundDecl = true; + } - void VisitBreakStmt(BreakStmt *S) { - FoundDecl = true; - } + void VisitBreakStmt(BreakStmt *S) { + FoundDecl = true; + } - void VisitGotoStmt(GotoStmt *S) { - FoundDecl = true; - } + void VisitGotoStmt(GotoStmt *S) { + FoundDecl = true; + } - void VisitCastExpr(CastExpr *E) { - if (E->getCastKind() == CK_LValueToRValue) - CheckLValueToRValueCast(E->getSubExpr()); - else - Visit(E->getSubExpr()); - } + void VisitCastExpr(CastExpr *E) { + if (E->getCastKind() == CK_LValueToRValue) + CheckLValueToRValueCast(E->getSubExpr()); + else + Visit(E->getSubExpr()); + } - void CheckLValueToRValueCast(Expr *E) { - E = E->IgnoreParenImpCasts(); + void CheckLValueToRValueCast(Expr *E) { + E = E->IgnoreParenImpCasts(); - if (isa(E)) { - return; - } + if (isa(E)) { + return; + } - if (ConditionalOperator *CO = dyn_cast(E)) { - Visit(CO->getCond()); - CheckLValueToRValueCast(CO->getTrueExpr()); - CheckLValueToRValueCast(CO->getFalseExpr()); - return; - } + if (ConditionalOperator *CO = dyn_cast(E)) { + Visit(CO->getCond()); + CheckLValueToRValueCast(CO->getTrueExpr()); + CheckLValueToRValueCast(CO->getFalseExpr()); + return; + } - if (BinaryConditionalOperator *BCO = - dyn_cast(E)) { - CheckLValueToRValueCast(BCO->getOpaqueValue()->getSourceExpr()); - CheckLValueToRValueCast(BCO->getFalseExpr()); - return; - } + if (BinaryConditionalOperator *BCO = + dyn_cast(E)) { + CheckLValueToRValueCast(BCO->getOpaqueValue()->getSourceExpr()); + CheckLValueToRValueCast(BCO->getFalseExpr()); + return; + } - Visit(E); - } + Visit(E); + } - void VisitDeclRefExpr(DeclRefExpr *E) { - if (VarDecl *VD = dyn_cast(E->getDecl())) - if (Decls.count(VD)) - FoundDecl = true; - } + void VisitDeclRefExpr(DeclRefExpr *E) { + if (VarDecl *VD = dyn_cast(E->getDecl())) + if (Decls.count(VD)) + FoundDecl = true; + } - bool FoundDeclInUse() { return FoundDecl; } + bool FoundDeclInUse() { return FoundDecl; } }; // end class DeclMatcher