Kaydet (Commit) 4c0198b0 authored tarafından Noel Grandin's avatar Noel Grandin

reformat some loplugin code

to match our more normal conventions.

Also drop the 'using std' and some other cruft

Change-Id: I02ef81c5427188bc03a20b157a57a900a9d7bf0d
üst 03ee9967
...@@ -29,7 +29,7 @@ class BodyNotInBlock ...@@ -29,7 +29,7 @@ class BodyNotInBlock
bool VisitForStmt( const ForStmt* stmt ); bool VisitForStmt( const ForStmt* stmt );
bool VisitCXXForRangeStmt( const CXXForRangeStmt* stmt ); bool VisitCXXForRangeStmt( const CXXForRangeStmt* stmt );
private: private:
typedef vector< const Stmt* > StmtParents; typedef std::vector< const Stmt* > StmtParents;
void checkBody( const Stmt* body, SourceLocation stmtLocation, int stmtType, bool dontGoUp = false ); void checkBody( const Stmt* body, SourceLocation stmtLocation, int stmtType, bool dontGoUp = false );
}; };
......
...@@ -48,7 +48,7 @@ class CheckConfigMacros ...@@ -48,7 +48,7 @@ class CheckConfigMacros
enum { isPPCallback = true }; enum { isPPCallback = true };
private: private:
void checkMacro( const Token& macroToken, SourceLocation location ); void checkMacro( const Token& macroToken, SourceLocation location );
std::set< string > configMacros; std::set< std::string > configMacros;
}; };
CheckConfigMacros::CheckConfigMacros( const InstantiationData& data ) CheckConfigMacros::CheckConfigMacros( const InstantiationData& data )
......
...@@ -77,8 +77,8 @@ public: ...@@ -77,8 +77,8 @@ public:
for (const MyCallSiteInfo & s : callSet) for (const MyCallSiteInfo & s : callSet)
output += s.returnType + "\t" + s.nameAndParams + "\t" + s.sourceLocation + "\t" output += s.returnType + "\t" + s.nameAndParams + "\t" + s.sourceLocation + "\t"
+ s.paramName + "\t" + s.paramType + "\t" + s.callValue + "\n"; + s.paramName + "\t" + s.paramType + "\t" + s.callValue + "\n";
ofstream myfile; std::ofstream myfile;
myfile.open( SRCDIR "/loplugin.constantparam.log", ios::app | ios::out); myfile.open( SRCDIR "/loplugin.constantparam.log", std::ios::app | std::ios::out);
myfile << output; myfile << output;
myfile.close(); myfile.close();
} }
......
...@@ -73,8 +73,8 @@ public: ...@@ -73,8 +73,8 @@ public:
output += "defn:\t" + s.access + "\t" + s.returnType + "\t" + s.nameAndParams + "\t" + s.sourceLocation + "\n"; output += "defn:\t" + s.access + "\t" + s.returnType + "\t" + s.nameAndParams + "\t" + s.sourceLocation + "\n";
for (const MyCallInfo & s : callSet) for (const MyCallInfo & s : callSet)
output += "call:\t" + s.returnType + "\t" + s.nameAndParams + "\t" + s.sourceLocationOfCall + "\n"; output += "call:\t" + s.returnType + "\t" + s.nameAndParams + "\t" + s.sourceLocationOfCall + "\n";
ofstream myfile; std::ofstream myfile;
myfile.open( SRCDIR "/loplugin.countusersofdefaultparams.log", ios::app | ios::out); myfile.open( SRCDIR "/loplugin.countusersofdefaultparams.log", std::ios::app | std::ios::out);
myfile << output; myfile << output;
myfile.close(); myfile.close();
} }
......
...@@ -80,8 +80,8 @@ public: ...@@ -80,8 +80,8 @@ public:
output += "large:\t" + s.returnType + "\t" + s.nameAndParams + "\n"; output += "large:\t" + s.returnType + "\t" + s.nameAndParams + "\n";
for (const MyFuncInfo & s : addressOfSet) for (const MyFuncInfo & s : addressOfSet)
output += "addrof:\t" + s.returnType + "\t" + s.nameAndParams + "\n"; output += "addrof:\t" + s.returnType + "\t" + s.nameAndParams + "\n";
ofstream myfile; std::ofstream myfile;
myfile.open( SRCDIR "/loplugin.expandablemethods.log", ios::app | ios::out); myfile.open( SRCDIR "/loplugin.expandablemethods.log", std::ios::app | std::ios::out);
myfile << output; myfile << output;
myfile.close(); myfile.close();
} }
......
...@@ -45,7 +45,7 @@ bool ExternAndNotDefined::VisitFunctionDecl(const FunctionDecl * functionDecl) { ...@@ -45,7 +45,7 @@ bool ExternAndNotDefined::VisitFunctionDecl(const FunctionDecl * functionDecl) {
return true; return true;
} }
// this is the bison/flex C API, it has to be defined this way // this is the bison/flex C API, it has to be defined this way
string functionName = functionDecl->getNameAsString(); std::string functionName = functionDecl->getNameAsString();
if (functionName == "yyerror" || functionName == "YYWarning" || functionName == "yyparse" || functionName == "yylex") { if (functionName == "yyerror" || functionName == "YYWarning" || functionName == "yyparse" || functionName == "yylex") {
return true; return true;
} }
......
...@@ -82,8 +82,8 @@ public: ...@@ -82,8 +82,8 @@ public:
output += "deletedInDestructor:\t" + s.parentClass + "\t" + s.fieldName + "\n"; output += "deletedInDestructor:\t" + s.parentClass + "\t" + s.fieldName + "\n";
for (const MyFieldInfo & s : newedInConstructorSet) for (const MyFieldInfo & s : newedInConstructorSet)
output += "newedInConstructor:\t" + s.parentClass + "\t" + s.fieldName + "\n"; output += "newedInConstructor:\t" + s.parentClass + "\t" + s.fieldName + "\n";
ofstream myfile; std::ofstream myfile;
myfile.open( SRCDIR "/loplugin.inlinefields.log", ios::app | ios::out); myfile.open( SRCDIR "/loplugin.inlinefields.log", std::ios::app | std::ios::out);
myfile << output; myfile << output;
myfile.close(); myfile.close();
} }
......
...@@ -101,7 +101,6 @@ bool MemoryVar::TraverseFunctionDecl(FunctionDecl * decl) ...@@ -101,7 +101,6 @@ bool MemoryVar::TraverseFunctionDecl(FunctionDecl * decl)
"delete called here", "delete called here",
maVarDeleteSourceRangeMap[varLoc].getBegin()) maVarDeleteSourceRangeMap[varLoc].getBegin())
<< maVarDeleteSourceRangeMap[varLoc]; << maVarDeleteSourceRangeMap[varLoc];
cout << "xxxx " << aFileName.str() << endl;
} }
return true; return true;
} }
......
...@@ -65,8 +65,8 @@ public: ...@@ -65,8 +65,8 @@ public:
output += "has-subclass:\t" + s.first + "\t" + s.second + "\n"; output += "has-subclass:\t" + s.first + "\t" + s.second + "\n";
for (const std::pair<std::string,std::string> & s : definitionMap) for (const std::pair<std::string,std::string> & s : definitionMap)
output += "definition:\t" + s.first + "\t" + s.second + "\n"; output += "definition:\t" + s.first + "\t" + s.second + "\n";
ofstream myfile; std::ofstream myfile;
myfile.open( SRCDIR "/loplugin.mergeclasses.log", ios::app | ios::out); myfile.open( SRCDIR "/loplugin.mergeclasses.log", std::ios::app | std::ios::out);
myfile << output; myfile << output;
myfile.close(); myfile.close();
} }
......
...@@ -28,45 +28,45 @@ namespace loplugin ...@@ -28,45 +28,45 @@ namespace loplugin
*/ */
class PluginHandler class PluginHandler
: public ASTConsumer : public ASTConsumer
{ {
public: public:
PluginHandler( CompilerInstance& compiler, const vector< string >& args ); PluginHandler( CompilerInstance& compiler, const std::vector< std::string >& args );
virtual ~PluginHandler(); virtual ~PluginHandler();
virtual void HandleTranslationUnit( ASTContext& context ) override; virtual void HandleTranslationUnit( ASTContext& context ) override;
static void registerPlugin( Plugin* (*create)( const Plugin::InstantiationData& ), const char* optionName, bool isPPCallback, bool byDefault ); static void registerPlugin( Plugin* (*create)( const Plugin::InstantiationData& ), const char* optionName, bool isPPCallback, bool byDefault );
DiagnosticBuilder report( DiagnosticsEngine::Level level, const char * plugin, StringRef message, DiagnosticBuilder report( DiagnosticsEngine::Level level, const char * plugin, StringRef message,
CompilerInstance& compiler, SourceLocation loc = SourceLocation()); CompilerInstance& compiler, SourceLocation loc = SourceLocation());
bool addRemoval( SourceLocation loc ); bool addRemoval( SourceLocation loc );
static bool isUnitTestMode(); static bool isUnitTestMode();
private: private:
void handleOption( const string& option ); void handleOption( const std::string& option );
void createPlugins( set< string > rewriters ); void createPlugins( std::set< std::string > rewriters );
DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation()); DiagnosticBuilder report( DiagnosticsEngine::Level level, StringRef message, SourceLocation loc = SourceLocation());
CompilerInstance& compiler; CompilerInstance& compiler;
Rewriter rewriter; Rewriter rewriter;
set< SourceLocation > removals; std::set< SourceLocation > removals;
string scope; std::string scope;
string warningsOnly; std::string warningsOnly;
bool warningsAsErrors; bool warningsAsErrors;
}; };
/** /**
The Clang plugin class, just forwards to PluginHandler. The Clang plugin class, just forwards to PluginHandler.
*/ */
class LibreOfficeAction class LibreOfficeAction
: public PluginASTAction : public PluginASTAction
{ {
public: public:
#if CLANG_VERSION >= 30600 #if CLANG_VERSION >= 30600
virtual std::unique_ptr<ASTConsumer> CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile ); virtual std::unique_ptr<ASTConsumer> CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
#else #else
virtual ASTConsumer* CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile ); virtual ASTConsumer* CreateASTConsumer( CompilerInstance& Compiler, StringRef InFile );
#endif #endif
virtual bool ParseArgs( const CompilerInstance& CI, const vector< string >& args ); virtual bool ParseArgs( const CompilerInstance& CI, const std::vector< std::string >& args );
private: private:
vector< string > _args; std::vector< std::string > _args;
}; };
} // namespace } // namespace
......
...@@ -202,18 +202,18 @@ bad: ...@@ -202,18 +202,18 @@ bad:
void SalLogAreas::readLogAreas() void SalLogAreas::readLogAreas()
{ {
ifstream is( SRCDIR "/include/sal/log-areas.dox" ); std::ifstream is( SRCDIR "/include/sal/log-areas.dox" );
while( is.good()) while( is.good())
{ {
string line; std::string line;
getline( is, line ); getline( is, line );
size_t pos = line.find( "@li @c " ); size_t pos = line.find( "@li @c " );
if( pos != string::npos ) if( pos != std::string::npos )
{ {
pos += strlen( "@li @c " ); pos += strlen( "@li @c " );
size_t end = line.find( ' ', pos ); size_t end = line.find( ' ', pos );
std::string area; std::string area;
if( end == string::npos ) if( end == std::string::npos )
area = line.substr( pos ); area = line.substr( pos );
else if( pos != end ) else if( pos != end )
area = line.substr( pos, end - pos ); area = line.substr( pos, end - pos );
......
...@@ -34,9 +34,9 @@ class SalLogAreas ...@@ -34,9 +34,9 @@ class SalLogAreas
void readLogAreas(); void readLogAreas();
const FunctionDecl* inFunction; const FunctionDecl* inFunction;
SourceLocation lastSalDetailLogStreamMacro; SourceLocation lastSalDetailLogStreamMacro;
set< string > logAreas; std::set< std::string > logAreas;
#if 0 #if 0
string firstSeenLogArea; std::string firstSeenLogArea;
SourceLocation firstSeenLocation; SourceLocation firstSeenLocation;
#endif #endif
}; };
......
...@@ -94,7 +94,7 @@ bool isDerivedFromSwMsgPoolItem(const CXXRecordDecl *decl) { ...@@ -94,7 +94,7 @@ bool isDerivedFromSwMsgPoolItem(const CXXRecordDecl *decl) {
return false; return false;
} }
bool endsWith(const string& a, const string& b) { bool endsWith(const std::string& a, const std::string& b) {
if (b.size() > a.size()) return false; if (b.size() > a.size()) return false;
return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin()); return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin());
} }
......
...@@ -84,8 +84,8 @@ public: ...@@ -84,8 +84,8 @@ public:
output += "asgn:\t" + s.parentClass + "\t" + s.fieldName + "\t" + s.value + "\n"; output += "asgn:\t" + s.parentClass + "\t" + s.fieldName + "\t" + s.value + "\n";
for (const MyFieldInfo & s : definitionSet) for (const MyFieldInfo & s : definitionSet)
output += "defn:\t" + s.parentClass + "\t" + s.fieldName + "\t" + s.sourceLocation + "\n"; output += "defn:\t" + s.parentClass + "\t" + s.fieldName + "\t" + s.sourceLocation + "\n";
ofstream myfile; std::ofstream myfile;
myfile.open( SRCDIR "/loplugin.singlevalfields.log", ios::app | ios::out); myfile.open( SRCDIR "/loplugin.singlevalfields.log", std::ios::app | std::ios::out);
myfile << output; myfile << output;
myfile.close(); myfile.close();
} }
......
...@@ -66,8 +66,8 @@ public: ...@@ -66,8 +66,8 @@ public:
output += "definition:\t" + s.name + "\t" + s.sourceLocation + "\n"; output += "definition:\t" + s.name + "\t" + s.sourceLocation + "\n";
for (const std::string & s : overridingSet) for (const std::string & s : overridingSet)
output += "overriding:\t" + s + "\n"; output += "overriding:\t" + s + "\n";
ofstream myfile; std::ofstream myfile;
myfile.open( SRCDIR "/loplugin.unnecessaryvirtual.log", ios::app | ios::out); myfile.open( SRCDIR "/loplugin.unnecessaryvirtual.log", std::ios::app | std::ios::out);
myfile << output; myfile << output;
myfile.close(); myfile.close();
} }
......
...@@ -77,8 +77,8 @@ public: ...@@ -77,8 +77,8 @@ public:
output += "write:\t" + s.parentClass + "\t" + s.fieldName + "\n"; output += "write:\t" + s.parentClass + "\t" + s.fieldName + "\n";
for (const MyFieldInfo & s : readSet) for (const MyFieldInfo & s : readSet)
output += "read:\t" + s.parentClass + "\t" + s.fieldName + "\n"; output += "read:\t" + s.parentClass + "\t" + s.fieldName + "\n";
ofstream myfile; std::ofstream myfile;
myfile.open( SRCDIR "/loplugin.unusedenumconstants.log", ios::app | ios::out); myfile.open( SRCDIR "/loplugin.unusedenumconstants.log", std::ios::app | std::ios::out);
myfile << output; myfile << output;
myfile.close(); myfile.close();
} }
......
...@@ -106,8 +106,8 @@ void UnusedFields::run() ...@@ -106,8 +106,8 @@ void UnusedFields::run()
{ {
output += "definition:\t" + s.access + "\t" + s.parentClass + "\t" + s.fieldName + "\t" + s.fieldType + "\t" + s.sourceLocation + "\n"; output += "definition:\t" + s.access + "\t" + s.parentClass + "\t" + s.fieldName + "\t" + s.fieldType + "\t" + s.sourceLocation + "\n";
} }
ofstream myfile; std::ofstream myfile;
myfile.open( SRCDIR "/loplugin.unusedfields.log", ios::app | ios::out); myfile.open( SRCDIR "/loplugin.unusedfields.log", std::ios::app | std::ios::out);
myfile << output; myfile << output;
myfile.close(); myfile.close();
} }
......
...@@ -72,11 +72,8 @@ UnusedFieldsRemove::~UnusedFieldsRemove() ...@@ -72,11 +72,8 @@ UnusedFieldsRemove::~UnusedFieldsRemove()
std::string niceName(const FieldDecl* fieldDecl) std::string niceName(const FieldDecl* fieldDecl)
{ {
std::string s = fieldDecl->getParent()->getQualifiedNameAsString() + " " + return fieldDecl->getParent()->getQualifiedNameAsString() + " " +
fieldDecl->getNameAsString(); fieldDecl->getNameAsString();
if (s.find("m_xExternalProgress") != std::string::npos)
cout << s << endl;
return s;
} }
bool UnusedFieldsRemove::VisitFieldDecl( const FieldDecl* fieldDecl ) bool UnusedFieldsRemove::VisitFieldDecl( const FieldDecl* fieldDecl )
......
...@@ -100,8 +100,8 @@ public: ...@@ -100,8 +100,8 @@ public:
// for the "method can be private" analysis // for the "method can be private" analysis
for (const MyFuncInfo & s : calledFromOutsideSet) for (const MyFuncInfo & s : calledFromOutsideSet)
output += "outside:\t" + s.returnType + "\t" + s.nameAndParams + "\n"; output += "outside:\t" + s.returnType + "\t" + s.nameAndParams + "\n";
ofstream myfile; std::ofstream myfile;
myfile.open( SRCDIR "/loplugin.unusedmethods.log", ios::app | ios::out); myfile.open( SRCDIR "/loplugin.unusedmethods.log", std::ios::app | std::ios::out);
myfile << output; myfile << output;
myfile.close(); myfile.close();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment