Skip to content

Commit

Permalink
Clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsbuild committed May 15, 2019
1 parent 4985c11 commit f49614b
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 94 deletions.
2 changes: 1 addition & 1 deletion IOMC/RandomEngine/src/RandomNumberGeneratorService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace edm {

if(pset.exists("restoreStateTag")) {
restoreStateTag_ = pset.getUntrackedParameter<edm::InputTag>("restoreStateTag");
if(restoreStateTag_.process() == "") {
if(restoreStateTag_.process().empty()) {
restoreStateTag_ = edm::InputTag(restoreStateTag_.label(), "", edm::InputTag::kSkipCurrentProcess);
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions Utilities/StaticAnalyzers/src/CatchAll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ const clang::Stmt* CatchAll::process(const clang::Stmt* S) const
return S;
clang::Stmt::const_child_iterator b=S->child_begin ();
clang::Stmt::const_child_iterator e=S->child_end ();
const clang::Stmt* catchAll = 0;
const clang::Stmt* catchAll = nullptr;
while(b!=e)
{
if (*b)
{
catchAll = process(*b);
if (catchAll!=0) break;
if (catchAll!=nullptr) break;
}
b++;
}
Expand Down
20 changes: 10 additions & 10 deletions Utilities/StaticAnalyzers/src/ClassChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class WalkAST : public clang::StmtVisitor<WalkAST> {
BR(br),
AC(ac),
AD(fd),
visitingCallExpr(0),sfile(file) {}
visitingCallExpr(nullptr),sfile(file) {}

bool hasWork() const { return !WList.empty(); }

Expand Down Expand Up @@ -118,7 +118,7 @@ class WalkAST : public clang::StmtVisitor<WalkAST> {

const clang::Stmt * ParentStmt(const Stmt *S) {
const Stmt * P = AC->getParentMap().getParentIgnoreParens(S);
if (!P) return 0;
if (!P) return nullptr;
return P;
}

Expand All @@ -129,7 +129,7 @@ class WalkAST : public clang::StmtVisitor<WalkAST> {
if (!WList.empty()) {
for (llvm::SmallVectorImpl<const clang::CXXMemberCallExpr *>::iterator
I = WList.begin(), E = WList.end(); I != E; I++) {
(*I)->printPretty(os, 0 , Policy);
(*I)->printPretty(os, nullptr , Policy);
os <<" ";
}
}
Expand Down Expand Up @@ -339,7 +339,7 @@ void WalkAST::ReportDeclRef( const clang::DeclRefExpr * DRE) {
std::string buf;
llvm::raw_string_ostream os(buf);
os << "Non-const variable '" << support::getQualifiedName(*D) << "' is static local and accessed in statement '";
PS->printPretty(os,0,Policy);
PS->printPretty(os,nullptr,Policy);
os << "'.\n";
std::string pname = support::getQualifiedName(*(AD->getParent()));
support::fixAnonNS(pname,sfile);
Expand All @@ -358,7 +358,7 @@ void WalkAST::ReportDeclRef( const clang::DeclRefExpr * DRE) {
std::string buf;
llvm::raw_string_ostream os(buf);
os << "Non-const variable '" << support::getQualifiedName(*D) << "' is static member data and accessed in statement '";
PS->printPretty(os,0,Policy);
PS->printPretty(os,nullptr,Policy);
os << "'.\n";
std::string pname = support::getQualifiedName(*(AD->getParent()));
support::fixAnonNS(pname,sfile);
Expand All @@ -382,7 +382,7 @@ void WalkAST::ReportDeclRef( const clang::DeclRefExpr * DRE) {
std::string buf;
llvm::raw_string_ostream os(buf);
os << "Non-const variable '" << support::getQualifiedName(*D) << "' is global static and accessed in statement '";
PS->printPretty(os,0,Policy);
PS->printPretty(os,nullptr,Policy);
os << "'.\n";
std::string pname = support::getQualifiedName(*(AD->getParent()));
support::fixAnonNS(pname,sfile);
Expand Down Expand Up @@ -480,7 +480,7 @@ void WalkAST::ReportMember(const clang::MemberExpr *ME) {
R = ME->getSourceRange();

os << "Member data '";
ME->printPretty(os,0,Policy);
ME->printPretty(os,nullptr,Policy);
os << "' is directly or indirectly modified in const function\n";
std::string pname = support::getQualifiedName(*(AD->getParent()));
support::fixAnonNS(pname,sfile);
Expand All @@ -503,9 +503,9 @@ void WalkAST::ReportCall(const clang::CXXMemberCallExpr *CE) {
LangOpts.CPlusPlus = true;
clang::PrintingPolicy Policy(LangOpts);
os << "call expr '";
CE->printPretty(os,0,Policy);
CE->printPretty(os,nullptr,Policy);
os << "' with implicit object argument '";
CE->getImplicitObjectArgument()->IgnoreParenCasts()->printPretty(os,0,Policy);
CE->getImplicitObjectArgument()->IgnoreParenCasts()->printPretty(os,nullptr,Policy);
os << "'";
os<<"' is a non-const member function '"<<support::getQualifiedName(*MD);
os<<"' that could modify member data object of type '"<<support::getQualifiedName(*RD)<<"'\n";
Expand Down Expand Up @@ -593,7 +593,7 @@ void WalkAST::ReportCallReturn(const clang::ReturnStmt * RS) {
os << "Returns a pointer or reference to a non-const member data object ";
os << " or a const std::vector<*> or const std::vector<*>& ";
os << "in const function in statement '";
RS->printPretty(os,0,Policy);
RS->printPretty(os,nullptr,Policy);
os << "\n";
const clang::CXXMethodDecl * MD = llvm::cast<clang::CXXMethodDecl>(AD);
clang::ento::PathDiagnosticLocation CELoc =
Expand Down
4 changes: 2 additions & 2 deletions Utilities/StaticAnalyzers/src/ClassDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void ClassDumper::checkASTDecl(const clang::CXXRecordDecl *RD,clang::ento::Analy
if (SD) {
std::string buf;
llvm::raw_string_ostream os(buf);
SD->getNameForDiagnostic(os,Policy,1);
SD->getNameForDiagnostic(os,Policy,true);
crname = crname+os.str()+"'";
support::writeLog(crname, tname);
for (unsigned J = 0, F = SD->getTemplateArgs().size(); J!=F; ++J) {
Expand Down Expand Up @@ -79,7 +79,7 @@ void ClassDumper::checkASTDecl(const clang::CXXRecordDecl *RD,clang::ento::Analy
if (SD) {
std::string buf;
llvm::raw_string_ostream os(buf);
SD->getNameForDiagnostic(os,Policy,1);
SD->getNameForDiagnostic(os,Policy,true);
std::string cfname ="member data class '"+os.str()+"'";
support::writeLog(crname+" "+cfname,tname);
// Recurse the template args
Expand Down
2 changes: 1 addition & 1 deletion Utilities/StaticAnalyzers/src/ConstCastAwayChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void ConstCastAwayChecker::checkPreStmt(const clang::ExplicitCastExpr *CE,
if ( ! m_exception.reportConstCastAway( *R, C ) )
return;
C.emitReport(std::move(R));
if (cname == "")
if (cname.empty())
return;
std::string tname ="constcastaway-checker.txt.unsorted";
std::string tolog ="flagged class '"+cname+"' const qualifier cast away";
Expand Down
2 changes: 1 addition & 1 deletion Utilities/StaticAnalyzers/src/ConstCastChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void ConstCastChecker::checkPreStmt(const clang::CXXConstCastExpr *CE,
if ( ! m_exception.reportConstCast( *R, C ) )
return;
C.emitReport(std::move(R));
if (cname == "")
if (cname.empty())
return;
std::string tname = "constcast-checker.txt.unsorted";
std::string tolog = "flagged class '"+cname+"' const_cast used ";
Expand Down
2 changes: 1 addition & 1 deletion Utilities/StaticAnalyzers/src/UsingNamespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void UsingNamespace::checkASTDecl (const clang::UsingDecl *D, clang::ento::Analy

bool UsingNamespace::isDeclOK (const clang::NamedDecl *D, clang::ento::BugReporter &BR) const
{
if (D->getDeclContext ()->getParent()!=0) return true;
if (D->getDeclContext ()->getParent()!=nullptr) return true;
const char *sfile=BR.getSourceManager().getPresumedLoc(D->getLocation ()).getFilename();
if (!support::isCmsLocalFile(sfile)) return true;
size_t flen = strlen(sfile);
Expand Down
24 changes: 12 additions & 12 deletions Utilities/StaticAnalyzers/src/getParamDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void getParamDumper::analyzerEval(const clang::CallExpr *CE, clang::ento::Checke
os << "' with args '";
for ( unsigned I=0, E=CE->getNumArgs(); I != E; ++I) {
if (I) os <<", ";
CE->getArg(I)->printPretty(os,0,Policy);
CE->getArg(I)->printPretty(os,nullptr,Policy);
}
os << "' with implicit object '";
const Expr * E = IOA->IgnoreParenNoopCasts(C.getASTContext());
Expand All @@ -91,19 +91,19 @@ void getParamDumper::analyzerEval(const clang::CallExpr *CE, clang::ento::Checke
os << dyn_cast<DeclRefExpr>(E)->getDecl()->getQualifiedNameAsString();
break;
case Stmt::CXXOperatorCallExprClass:
dyn_cast<CXXOperatorCallExpr>(E)->printPretty(os,0,Policy);
dyn_cast<CXXOperatorCallExpr>(E)->printPretty(os,nullptr,Policy);
break;
case Stmt::CXXBindTemporaryExprClass:
dyn_cast<CXXBindTemporaryExpr>(E)->printPretty(os,0,Policy);
dyn_cast<CXXBindTemporaryExpr>(E)->printPretty(os,nullptr,Policy);
break;
case Stmt::CXXMemberCallExprClass:
dyn_cast<CXXMemberCallExpr>(E)->printPretty(os,0,Policy);
dyn_cast<CXXMemberCallExpr>(E)->printPretty(os,nullptr,Policy);
break;
case Stmt::UnaryOperatorClass:
dyn_cast<UnaryOperator>(E)->printPretty(os,0,Policy);
dyn_cast<UnaryOperator>(E)->printPretty(os,nullptr,Policy);
break;
default:
E->printPretty(os,0,Policy);
E->printPretty(os,nullptr,Policy);
os << " unhandled expr class " <<E->getStmtClassName();
}
os<<"'\n";
Expand Down Expand Up @@ -192,7 +192,7 @@ void gpWalkAST::VisitCXXMemberCallExpr( clang::CXXMemberCallExpr *CE ) {
for ( unsigned I=0, E=CE->getNumArgs(); I != E; ++I) {
if (I) os <<", ";
os << CE->getType().getCanonicalType().getAsString()<<" ";
CE->getArg(I)->printPretty(os,0,Policy);
CE->getArg(I)->printPretty(os,nullptr,Policy);
}
os << "' with implicit object '";
const Expr * E = IOA->IgnoreParenCasts();
Expand All @@ -206,19 +206,19 @@ void gpWalkAST::VisitCXXMemberCallExpr( clang::CXXMemberCallExpr *CE ) {
os << dyn_cast<DeclRefExpr>(E)->getDecl()->getQualifiedNameAsString();
break;
case Stmt::CXXOperatorCallExprClass:
dyn_cast<CXXOperatorCallExpr>(E)->printPretty(os,0,Policy);
dyn_cast<CXXOperatorCallExpr>(E)->printPretty(os,nullptr,Policy);
break;
case Stmt::CXXBindTemporaryExprClass:
dyn_cast<CXXBindTemporaryExpr>(E)->printPretty(os,0,Policy);
dyn_cast<CXXBindTemporaryExpr>(E)->printPretty(os,nullptr,Policy);
break;
case Stmt::CXXMemberCallExprClass:
dyn_cast<CXXMemberCallExpr>(E)->printPretty(os,0,Policy);
dyn_cast<CXXMemberCallExpr>(E)->printPretty(os,nullptr,Policy);
break;
case Stmt::UnaryOperatorClass:
dyn_cast<UnaryOperator>(E)->printPretty(os,0,Policy);
dyn_cast<UnaryOperator>(E)->printPretty(os,nullptr,Policy);
break;
default:
E->printPretty(os,0,Policy);
E->printPretty(os,nullptr,Policy);
os << " unhandled expr class " <<E->getStmtClassName();
}
os<<"'\n";
Expand Down
4 changes: 2 additions & 2 deletions Utilities/StorageFactory/bin/anycp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class OutputDropBox

bool ret = true;
// if error in previous write return....
if (ce == "")
if (ce.empty())
{
outbuf.swap(ibuf);
nout = n;
Expand Down Expand Up @@ -138,7 +138,7 @@ class InputDropBox

IOSize ret = 0;
// if error in previous write return....
if (ce == "")
if (ce.empty())
{
inbuf.swap(ibuf);
ret = nin;
Expand Down
28 changes: 14 additions & 14 deletions Utilities/StorageFactory/interface/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class File : public IOChannel, public Storage
File (IOFD fd, bool autoclose = true);
File (const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
File (const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
~File (void);
~File (void) override;
// implicit copy constructor
// implicit assignment operator

Expand All @@ -39,22 +39,22 @@ class File : public IOChannel, public Storage
using Storage::writev;
using Storage::position;

virtual bool prefetch (const IOPosBuffer *what, IOSize n);
virtual IOSize read (void *into, IOSize n);
virtual IOSize read (void *into, IOSize n, IOOffset pos);
virtual IOSize readv (IOBuffer *into, IOSize length);
bool prefetch (const IOPosBuffer *what, IOSize n) override;
IOSize read (void *into, IOSize n) override;
IOSize read (void *into, IOSize n, IOOffset pos) override;
IOSize readv (IOBuffer *into, IOSize length) override;

virtual IOSize write (const void *from, IOSize n);
virtual IOSize write (const void *from, IOSize n, IOOffset pos);
virtual IOSize writev (const IOBuffer *from, IOSize length);
IOSize write (const void *from, IOSize n) override;
IOSize write (const void *from, IOSize n, IOOffset pos) override;
IOSize writev (const IOBuffer *from, IOSize length) override;

virtual IOOffset size (void) const;
virtual IOOffset position (IOOffset offset, Relative whence = SET);
IOOffset size (void) const override;
IOOffset position (IOOffset offset, Relative whence = SET) override;

virtual void resize (IOOffset size);
void resize (IOOffset size) override;

virtual void flush (void);
virtual void close (void);
void flush (void) override;
void close (void) override;
virtual void abort (void);

virtual void setAutoClose (bool closeit);
Expand All @@ -69,7 +69,7 @@ class File : public IOChannel, public Storage
static IOFD sysduplicate (IOFD fd);
static void sysopen (const char *name, int flags, int perms,
IOFD &newfd, unsigned &newflags);
static bool sysclose (IOFD fd, int *error = 0);
static bool sysclose (IOFD fd, int *error = nullptr);

unsigned m_flags;
};
Expand Down
12 changes: 6 additions & 6 deletions Utilities/StorageFactory/interface/IOChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ class IOChannel : public virtual IOInput, public virtual IOOutput
{
public:
IOChannel (IOFD fd = EDM_IOFD_INVALID);
virtual ~IOChannel (void);
~IOChannel (void) override;
// implicit copy constructor
// implicit assignment operator

using IOInput::read;
using IOOutput::write;

virtual IOSize read (void *into, IOSize n);
virtual IOSize readv (IOBuffer *into, IOSize buffers);
IOSize read (void *into, IOSize n) override;
IOSize readv (IOBuffer *into, IOSize buffers) override;

virtual IOSize write (const void *from, IOSize n);
virtual IOSize writev (const IOBuffer *from, IOSize buffers);
IOSize write (const void *from, IOSize n) override;
IOSize writev (const IOBuffer *from, IOSize buffers) override;

virtual IOFD fd (void) const;
virtual void fd (IOFD value); // FIXME: dangerous?
Expand All @@ -33,7 +33,7 @@ class IOChannel : public virtual IOInput, public virtual IOOutput

protected:
// System implementation
bool sysclose (IOFD fd, int *error = 0);
bool sysclose (IOFD fd, int *error = nullptr);

private:
IOFD m_fd; /*< System file descriptor. */
Expand Down
30 changes: 15 additions & 15 deletions Utilities/StorageFactory/interface/LocalCacheFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ class LocalCacheFile : public Storage
{
public:
LocalCacheFile (std::unique_ptr<Storage> base, const std::string &tmpdir = "");
~LocalCacheFile (void);
~LocalCacheFile (void) override;

using Storage::read;
using Storage::write;

virtual bool prefetch (const IOPosBuffer *what, IOSize n);
virtual IOSize read (void *into, IOSize n);
virtual IOSize read (void *into, IOSize n, IOOffset pos);
virtual IOSize readv (IOBuffer *into, IOSize n);
virtual IOSize readv (IOPosBuffer *into, IOSize n);
virtual IOSize write (const void *from, IOSize n);
virtual IOSize write (const void *from, IOSize n, IOOffset pos);
virtual IOSize writev (const IOBuffer *from, IOSize n);
virtual IOSize writev (const IOPosBuffer *from, IOSize n);

virtual IOOffset position (IOOffset offset, Relative whence = SET);
virtual void resize (IOOffset size);
virtual void flush (void);
virtual void close (void);
bool prefetch (const IOPosBuffer *what, IOSize n) override;
IOSize read (void *into, IOSize n) override;
IOSize read (void *into, IOSize n, IOOffset pos) override;
IOSize readv (IOBuffer *into, IOSize n) override;
IOSize readv (IOPosBuffer *into, IOSize n) override;
IOSize write (const void *from, IOSize n) override;
IOSize write (const void *from, IOSize n, IOOffset pos) override;
IOSize writev (const IOBuffer *from, IOSize n) override;
IOSize writev (const IOPosBuffer *from, IOSize n) override;

IOOffset position (IOOffset offset, Relative whence = SET) override;
void resize (IOOffset size) override;
void flush (void) override;
void close (void) override;

private:
void cache (IOOffset start, IOOffset end);
Expand Down
4 changes: 2 additions & 2 deletions Utilities/StorageFactory/interface/Storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class Storage : public virtual IOInput, public virtual IOOutput

private:
// undefined, no semantics
Storage (const Storage &);
Storage &operator= (const Storage &);
Storage (const Storage &) = delete;
Storage &operator= (const Storage &) = delete;
};

#endif // STORAGE_FACTORY_STORAGE_H
Loading

0 comments on commit f49614b

Please sign in to comment.