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