add const
Change-Id: I71236b9ca6300372ba00c85401cf19f6c0e7ac99
This commit is contained in:
@@ -38,7 +38,7 @@ void BodyNotInBlock::run()
|
||||
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
|
||||
}
|
||||
|
||||
bool BodyNotInBlock::VisitFunctionDecl( FunctionDecl* declaration )
|
||||
bool BodyNotInBlock::VisitFunctionDecl( const FunctionDecl* declaration )
|
||||
{
|
||||
if( ignoreLocation( declaration ))
|
||||
return true;
|
||||
|
@@ -23,7 +23,7 @@ class BodyNotInBlock
|
||||
public:
|
||||
explicit BodyNotInBlock( CompilerInstance& compiler );
|
||||
virtual void run();
|
||||
bool VisitFunctionDecl( FunctionDecl* declaration );
|
||||
bool VisitFunctionDecl( const FunctionDecl* declaration );
|
||||
private:
|
||||
typedef vector< const Stmt* > StmtParents;
|
||||
void traverseStatement( const Stmt* stmt, StmtParents& parents );
|
||||
|
@@ -25,10 +25,10 @@ public:
|
||||
|
||||
virtual void run() { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
|
||||
|
||||
bool VisitCallExpr(CallExpr * expr);
|
||||
bool VisitCallExpr(const CallExpr * expr);
|
||||
};
|
||||
|
||||
bool LiteralAlternative::VisitCallExpr(CallExpr * expr) {
|
||||
bool LiteralAlternative::VisitCallExpr(const CallExpr * expr) {
|
||||
if (ignoreLocation(expr)) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ void PostfixIncrementFix::run()
|
||||
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
|
||||
}
|
||||
|
||||
bool PostfixIncrementFix::VisitFunctionDecl( FunctionDecl* declaration )
|
||||
bool PostfixIncrementFix::VisitFunctionDecl( const FunctionDecl* declaration )
|
||||
{
|
||||
if( ignoreLocation( declaration ))
|
||||
return true;
|
||||
|
@@ -23,7 +23,7 @@ class PostfixIncrementFix
|
||||
public:
|
||||
explicit PostfixIncrementFix( CompilerInstance& compiler, Rewriter& rewriter );
|
||||
virtual void run();
|
||||
bool VisitFunctionDecl( FunctionDecl* declaration );
|
||||
bool VisitFunctionDecl( const FunctionDecl* declaration );
|
||||
private:
|
||||
typedef std::vector< const Stmt* > StmtParents;
|
||||
void fixPostfixOperator( const CXXOperatorCallExpr* op, StmtParents& parents );
|
||||
|
@@ -37,17 +37,17 @@ void SalLogAreas::run()
|
||||
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
|
||||
}
|
||||
|
||||
bool SalLogAreas::VisitFunctionDecl( FunctionDecl* function )
|
||||
bool SalLogAreas::VisitFunctionDecl( const FunctionDecl* function )
|
||||
{
|
||||
inFunction = function;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SalLogAreas::VisitCallExpr( CallExpr* call )
|
||||
bool SalLogAreas::VisitCallExpr( const CallExpr* call )
|
||||
{
|
||||
if( ignoreLocation( call ))
|
||||
return true;
|
||||
if( FunctionDecl* func = call->getDirectCallee())
|
||||
if( const FunctionDecl* func = call->getDirectCallee())
|
||||
{
|
||||
// Optimize, getQualifiedNameAsString() is reportedly expensive.
|
||||
if( func->getNumParams() == 4 && func->getIdentifier() != NULL
|
||||
|
@@ -25,8 +25,8 @@ class SalLogAreas
|
||||
public:
|
||||
explicit SalLogAreas( CompilerInstance& compiler );
|
||||
virtual void run();
|
||||
bool VisitFunctionDecl( FunctionDecl* function );
|
||||
bool VisitCallExpr( CallExpr* call );
|
||||
bool VisitFunctionDecl( const FunctionDecl* function );
|
||||
bool VisitCallExpr( const CallExpr* call );
|
||||
private:
|
||||
void checkArea( StringRef area, SourceLocation location );
|
||||
void readLogAreas();
|
||||
|
@@ -29,7 +29,7 @@ void LclStaticFix::run()
|
||||
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
|
||||
}
|
||||
|
||||
bool LclStaticFix::VisitFunctionDecl( FunctionDecl* declaration )
|
||||
bool LclStaticFix::VisitFunctionDecl( const FunctionDecl* declaration )
|
||||
{
|
||||
if( ignoreLocation( declaration ))
|
||||
return true;
|
||||
|
@@ -23,7 +23,7 @@ class LclStaticFix
|
||||
public:
|
||||
explicit LclStaticFix( CompilerInstance& compiler, Rewriter& rewriter );
|
||||
virtual void run();
|
||||
bool VisitFunctionDecl( FunctionDecl* declaration );
|
||||
bool VisitFunctionDecl( const FunctionDecl* declaration );
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
@@ -29,7 +29,7 @@ void RemoveForwardStringDecl::run()
|
||||
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
|
||||
}
|
||||
|
||||
bool RemoveForwardStringDecl::VisitNamespaceDecl( NamespaceDecl* declaration )
|
||||
bool RemoveForwardStringDecl::VisitNamespaceDecl( const NamespaceDecl* declaration )
|
||||
{
|
||||
if( ignoreLocation( declaration ))
|
||||
return true;
|
||||
|
@@ -23,7 +23,7 @@ class RemoveForwardStringDecl
|
||||
public:
|
||||
explicit RemoveForwardStringDecl( CompilerInstance& compiler, Rewriter& rewriter );
|
||||
virtual void run();
|
||||
bool VisitNamespaceDecl( NamespaceDecl* declaration );
|
||||
bool VisitNamespaceDecl( const NamespaceDecl* declaration );
|
||||
private:
|
||||
bool tryRemoveStringForwardDecl( const Decl* decl );
|
||||
};
|
||||
|
@@ -35,7 +35,7 @@ void Tutorial1::run()
|
||||
|
||||
// This function is called for every return statement.
|
||||
// Returning true means to continue with examining the AST, false means to stop (just always return true).
|
||||
bool Tutorial1::VisitReturnStmt( ReturnStmt* returnstmt )
|
||||
bool Tutorial1::VisitReturnStmt( const ReturnStmt* returnstmt )
|
||||
{
|
||||
// Helper function from the LO base plugin class, call at the very beginning to ignore sources
|
||||
// that should not be processed (e.g. system headers).
|
||||
|
@@ -29,7 +29,7 @@ class Tutorial1
|
||||
// The function that will be called to perform the actual action.
|
||||
virtual void run();
|
||||
// Function from Clang, it will be called for every return statement in the source.
|
||||
bool VisitReturnStmt( ReturnStmt* returnstmt );
|
||||
bool VisitReturnStmt( const ReturnStmt* returnstmt );
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
@@ -33,7 +33,7 @@ void Tutorial2::run()
|
||||
}
|
||||
|
||||
// This function is called for every if statement.
|
||||
bool Tutorial2::VisitIfStmt( IfStmt* ifstmt )
|
||||
bool Tutorial2::VisitIfStmt( const IfStmt* ifstmt )
|
||||
{
|
||||
if( ignoreLocation( ifstmt ))
|
||||
return true;
|
||||
@@ -49,7 +49,7 @@ bool Tutorial2::VisitIfStmt( IfStmt* ifstmt )
|
||||
if( isReturnFalse( ifstmt->getThen()))
|
||||
warn = ifstmt->getThen();
|
||||
// Check if the sub-statement is '{ return false; }'
|
||||
else if( CompoundStmt* compound = dyn_cast< CompoundStmt >( ifstmt->getThen()))
|
||||
else if( const CompoundStmt* compound = dyn_cast< CompoundStmt >( ifstmt->getThen()))
|
||||
{
|
||||
if( compound->size() == 1 ) // one statement
|
||||
if( isReturnFalse( *compound->body_begin())) // check the one sub-statement
|
||||
|
@@ -25,7 +25,7 @@ class Tutorial2
|
||||
Tutorial2( CompilerInstance& compiler );
|
||||
virtual void run();
|
||||
// Will be called for every if statement.
|
||||
bool VisitIfStmt( IfStmt* ifstmt );
|
||||
bool VisitIfStmt( const IfStmt* ifstmt );
|
||||
private:
|
||||
// Helper function to check if the statement is 'return false;'.
|
||||
bool isReturnFalse( const Stmt* stmt );
|
||||
|
@@ -31,7 +31,7 @@ void Tutorial3::run()
|
||||
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
|
||||
}
|
||||
|
||||
bool Tutorial3::VisitIfStmt( IfStmt* ifstmt )
|
||||
bool Tutorial3::VisitIfStmt( const IfStmt* ifstmt )
|
||||
{
|
||||
if( ignoreLocation( ifstmt ))
|
||||
return true;
|
||||
@@ -42,7 +42,7 @@ bool Tutorial3::VisitIfStmt( IfStmt* ifstmt )
|
||||
// Modify the sub-statement if it is 'return false'.
|
||||
modifyReturnFalse( ifstmt->getThen());
|
||||
// Modify the sub-statement if it is '{ return false; }'.
|
||||
if( CompoundStmt* compound = dyn_cast< CompoundStmt >( ifstmt->getThen()))
|
||||
if( const CompoundStmt* compound = dyn_cast< CompoundStmt >( ifstmt->getThen()))
|
||||
{
|
||||
if( compound->size() == 1 ) // one statement
|
||||
modifyReturnFalse( *compound->body_begin());
|
||||
|
@@ -26,7 +26,7 @@ class Tutorial3
|
||||
Tutorial3( CompilerInstance& compiler, Rewriter& rewriter );
|
||||
virtual void run();
|
||||
// Will be called for every if statement.
|
||||
bool VisitIfStmt( IfStmt* ifstmt );
|
||||
bool VisitIfStmt( const IfStmt* ifstmt );
|
||||
private:
|
||||
// Helper function to check if the statement is 'return false;' and
|
||||
// modify it if yes.
|
||||
|
@@ -30,7 +30,7 @@ class UnusedCode
|
||||
public:
|
||||
explicit UnusedCode( CompilerInstance& compiler, Rewriter& rewriter );
|
||||
virtual void run();
|
||||
bool VisitFunctionDecl( FunctionDecl* declaration );
|
||||
bool VisitFunctionDecl( const FunctionDecl* declaration );
|
||||
};
|
||||
|
||||
UnusedCode::UnusedCode( CompilerInstance& compiler, Rewriter& rewriter )
|
||||
@@ -43,12 +43,12 @@ void UnusedCode::run()
|
||||
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
|
||||
}
|
||||
|
||||
bool UnusedCode::VisitFunctionDecl( FunctionDecl* declaration )
|
||||
bool UnusedCode::VisitFunctionDecl( const FunctionDecl* declaration )
|
||||
{
|
||||
if( ignoreLocation( declaration ))
|
||||
return true;
|
||||
bool isUsed = declaration->isUsed();
|
||||
if( CXXMethodDecl* cxxmethod = dyn_cast< CXXMethodDecl >( declaration ))
|
||||
if( const CXXMethodDecl* cxxmethod = dyn_cast< CXXMethodDecl >( declaration ))
|
||||
{
|
||||
if( !isUsed && cxxmethod->isVirtual())
|
||||
{ // Virtual methods are used also if a method they override is used.
|
||||
|
@@ -40,7 +40,7 @@ void UnusedVariableCheck::run()
|
||||
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
|
||||
}
|
||||
|
||||
bool UnusedVariableCheck::VisitVarDecl( VarDecl* var )
|
||||
bool UnusedVariableCheck::VisitVarDecl( const VarDecl* var )
|
||||
{
|
||||
if( ignoreLocation( var ))
|
||||
return true;
|
||||
|
@@ -23,7 +23,7 @@ class UnusedVariableCheck
|
||||
public:
|
||||
explicit UnusedVariableCheck( CompilerInstance& compiler );
|
||||
virtual void run();
|
||||
bool VisitVarDecl( VarDecl* var );
|
||||
bool VisitVarDecl( const VarDecl* var );
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user