aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Padlewski <piotr.padlewski@gmail.com>2016-12-14 15:29:23 +0000
committerPiotr Padlewski <piotr.padlewski@gmail.com>2016-12-14 15:29:23 +0000
commit2cd835ee5bcd6c4944d7e30826668ec38db40b38 (patch)
tree2bc808fbc178d42948b8ae138e1ee3d696ec6c8b
parent0d8381bb69ca54a450b730ff3ee59133ecd0d09a (diff)
downloadclang-tools-extra-2cd835ee5bcd6c4944d7e30826668ec38db40b38.tar.gz
modernize-use-auto NFC fixes
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@289656 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--change-namespace/ChangeNamespace.cpp2
-rw-r--r--clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp7
-rw-r--r--clang-query/Query.cpp9
-rw-r--r--clang-query/QueryParser.cpp4
-rw-r--r--clang-query/tool/ClangQuery.cpp8
-rw-r--r--clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp4
-rw-r--r--clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp3
-rw-r--r--clang-tidy/google/ExplicitConstructorCheck.cpp3
-rw-r--r--clang-tidy/google/NonConstReferences.cpp2
-rw-r--r--clang-tidy/llvm/TwineLocalCheck.cpp2
-rw-r--r--clang-tidy/misc/ArgumentCommentCheck.cpp2
-rw-r--r--clang-tidy/misc/MoveForwardingReferenceCheck.cpp3
-rw-r--r--clang-tidy/misc/MultipleStatementMacroCheck.cpp2
-rw-r--r--clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp6
-rw-r--r--clang-tidy/modernize/UseNullptrCheck.cpp4
-rw-r--r--clang-tidy/modernize/UseOverrideCheck.cpp2
-rw-r--r--clang-tidy/mpi/TypeMismatchCheck.cpp2
-rw-r--r--clang-tidy/readability/ImplicitBoolCastCheck.cpp2
-rw-r--r--clang-tidy/readability/NamespaceCommentCheck.cpp2
-rw-r--r--clang-tidy/readability/RedundantDeclarationCheck.cpp2
-rw-r--r--clang-tidy/readability/RedundantSmartptrGetCheck.cpp4
-rw-r--r--include-fixer/find-all-symbols/FindAllSymbols.cpp2
-rw-r--r--modularize/CoverageChecker.cpp5
-rw-r--r--modularize/Modularize.cpp4
-rw-r--r--modularize/ModularizeUtilities.cpp7
-rw-r--r--modularize/ModuleAssistant.cpp15
-rw-r--r--modularize/PreprocessorTracker.cpp70
-rw-r--r--pp-trace/PPTrace.cpp3
-rw-r--r--unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp2
-rw-r--r--unittests/clang-tidy/NamespaceAliaserTest.cpp3
-rw-r--r--unittests/clang-tidy/UsingInserterTest.cpp3
31 files changed, 72 insertions, 117 deletions
diff --git a/change-namespace/ChangeNamespace.cpp b/change-namespace/ChangeNamespace.cpp
index 2dca1a98..4806f1ef 100644
--- a/change-namespace/ChangeNamespace.cpp
+++ b/change-namespace/ChangeNamespace.cpp
@@ -709,7 +709,7 @@ void ChangeNamespaceTool::fixTypeLoc(
return;
}
- const Decl *DeclCtx = Result.Nodes.getNodeAs<Decl>("dc");
+ const auto *DeclCtx = Result.Nodes.getNodeAs<Decl>("dc");
assert(DeclCtx && "Empty decl context.");
replaceQualifiedSymbolInDeclContext(Result, DeclCtx->getDeclContext(), Start,
End, FromDecl);
diff --git a/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp b/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
index 3fb21c5d..d2607b06 100644
--- a/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ b/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -124,9 +124,7 @@ static void reportConflict(
bool applyAllReplacements(const std::vector<tooling::Replacement> &Replaces,
Rewriter &Rewrite) {
bool Result = true;
- for (std::vector<tooling::Replacement>::const_iterator I = Replaces.begin(),
- E = Replaces.end();
- I != E; ++I) {
+ for (auto I = Replaces.begin(), E = Replaces.end(); I != E; ++I) {
if (I->isApplicable()) {
Result = I->apply(Rewrite) && Result;
} else {
@@ -293,8 +291,7 @@ RangeVector calculateChangedRanges(
bool writeFiles(const clang::Rewriter &Rewrites) {
- for (Rewriter::const_buffer_iterator BufferI = Rewrites.buffer_begin(),
- BufferE = Rewrites.buffer_end();
+ for (auto BufferI = Rewrites.buffer_begin(), BufferE = Rewrites.buffer_end();
BufferI != BufferE; ++BufferI) {
StringRef FileName =
Rewrites.getSourceMgr().getFileEntryForID(BufferI->first)->getName();
diff --git a/clang-query/Query.cpp b/clang-query/Query.cpp
index ed27c211..b3344dad 100644
--- a/clang-query/Query.cpp
+++ b/clang-query/Query.cpp
@@ -86,14 +86,11 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
}
Finder.matchAST(AST->getASTContext());
- for (std::vector<BoundNodes>::iterator MI = Matches.begin(),
- ME = Matches.end();
- MI != ME; ++MI) {
+ for (auto MI = Matches.begin(), ME = Matches.end(); MI != ME; ++MI) {
OS << "\nMatch #" << ++MatchCount << ":\n\n";
- for (BoundNodes::IDToNodeMap::const_iterator BI = MI->getMap().begin(),
- BE = MI->getMap().end();
- BI != BE; ++BI) {
+ for (auto BI = MI->getMap().begin(), BE = MI->getMap().end(); BI != BE;
+ ++BI) {
switch (QS.OutKind) {
case OK_Diag: {
clang::SourceRange R = BI->second.getSourceRange();
diff --git a/clang-query/QueryParser.cpp b/clang-query/QueryParser.cpp
index 15d6bbc1..c64d810a 100644
--- a/clang-query/QueryParser.cpp
+++ b/clang-query/QueryParser.cpp
@@ -158,9 +158,7 @@ QueryRef QueryParser::completeMatcherExpression() {
std::vector<MatcherCompletion> Comps = Parser::completeExpression(
StringRef(Begin, End - Begin), CompletionPos - Begin, nullptr,
&QS.NamedValues);
- for (std::vector<MatcherCompletion>::iterator I = Comps.begin(),
- E = Comps.end();
- I != E; ++I) {
+ for (auto I = Comps.begin(), E = Comps.end(); I != E; ++I) {
Completions.push_back(LineEditor::Completion(I->TypedText, I->MatcherDecl));
}
return QueryRef();
diff --git a/clang-query/tool/ClangQuery.cpp b/clang-query/tool/ClangQuery.cpp
index 990b82b3..669dc40e 100644
--- a/clang-query/tool/ClangQuery.cpp
+++ b/clang-query/tool/ClangQuery.cpp
@@ -77,17 +77,13 @@ int main(int argc, const char **argv) {
QuerySession QS(ASTs);
if (!Commands.empty()) {
- for (cl::list<std::string>::iterator I = Commands.begin(),
- E = Commands.end();
- I != E; ++I) {
+ for (auto I = Commands.begin(), E = Commands.end(); I != E; ++I) {
QueryRef Q = QueryParser::parse(*I, QS);
if (!Q->run(llvm::outs(), QS))
return 1;
}
} else if (!CommandFiles.empty()) {
- for (cl::list<std::string>::iterator I = CommandFiles.begin(),
- E = CommandFiles.end();
- I != E; ++I) {
+ for (auto I = CommandFiles.begin(), E = CommandFiles.end(); I != E; ++I) {
std::ifstream Input(I->c_str());
if (!Input.is_open()) {
llvm::errs() << argv[0] << ": cannot open " << *I << "\n";
diff --git a/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
index e64d36a6..804b2b05 100644
--- a/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ b/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -196,7 +196,7 @@ computeInsertions(const CXXConstructorDecl::init_const_range &Inits,
// Add all fields between current field up until the next intializer.
for (; Decl != std::end(OrderedDecls) && *Decl != InitDecl; ++Decl) {
- if (const T *D = dyn_cast<T>(*Decl)) {
+ if (const auto *D = dyn_cast<T>(*Decl)) {
if (DeclsToInit.count(D) > 0)
Insertions.back().Initializers.emplace_back(getName(D));
}
@@ -208,7 +208,7 @@ computeInsertions(const CXXConstructorDecl::init_const_range &Inits,
// Add remaining decls that require initialization.
for (; Decl != std::end(OrderedDecls); ++Decl) {
- if (const T *D = dyn_cast<T>(*Decl)) {
+ if (const auto *D = dyn_cast<T>(*Decl)) {
if (DeclsToInit.count(D) > 0)
Insertions.back().Initializers.emplace_back(getName(D));
}
diff --git a/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp b/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
index 62f791e6..e1f3d022 100644
--- a/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
+++ b/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
@@ -82,8 +82,7 @@ join(ArrayRef<SpecialMemberFunctionsCheck::SpecialMemberFunctionKind> SMFS,
void SpecialMemberFunctionsCheck::check(
const MatchFinder::MatchResult &Result) {
- const CXXRecordDecl *MatchedDecl =
- Result.Nodes.getNodeAs<CXXRecordDecl>("class-def");
+ const auto *MatchedDecl = Result.Nodes.getNodeAs<CXXRecordDecl>("class-def");
if (!MatchedDecl)
return;
diff --git a/clang-tidy/google/ExplicitConstructorCheck.cpp b/clang-tidy/google/ExplicitConstructorCheck.cpp
index e7900179..72a65b0d 100644
--- a/clang-tidy/google/ExplicitConstructorCheck.cpp
+++ b/clang-tidy/google/ExplicitConstructorCheck.cpp
@@ -75,8 +75,7 @@ static bool isStdInitializerList(QualType Type) {
}
void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) {
- const CXXConstructorDecl *Ctor =
- Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
+ const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
// Do not be confused: isExplicit means 'explicit' keyword is present,
// isImplicit means that it's a compiler-generated constructor.
if (Ctor->isOutOfLine() || Ctor->isImplicit() || Ctor->isDeleted() ||
diff --git a/clang-tidy/google/NonConstReferences.cpp b/clang-tidy/google/NonConstReferences.cpp
index 5cfdc10c..856bc5bc 100644
--- a/clang-tidy/google/NonConstReferences.cpp
+++ b/clang-tidy/google/NonConstReferences.cpp
@@ -56,7 +56,7 @@ void NonConstReferences::check(const MatchFinder::MatchResult &Result) {
if (!Function->isCanonicalDecl())
return;
- if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Function)) {
+ if (const auto *Method = dyn_cast<CXXMethodDecl>(Function)) {
// Don't warn on implementations of an interface using references.
if (Method->begin_overridden_methods() != Method->end_overridden_methods())
return;
diff --git a/clang-tidy/llvm/TwineLocalCheck.cpp b/clang-tidy/llvm/TwineLocalCheck.cpp
index 64444dbd..3fb5f5d9 100644
--- a/clang-tidy/llvm/TwineLocalCheck.cpp
+++ b/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -25,7 +25,7 @@ void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
}
void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {
- const VarDecl *VD = Result.Nodes.getNodeAs<VarDecl>("variable");
+ const auto *VD = Result.Nodes.getNodeAs<VarDecl>("variable");
auto Diag = diag(VD->getLocation(),
"twine variables are prone to use-after-free bugs");
diff --git a/clang-tidy/misc/ArgumentCommentCheck.cpp b/clang-tidy/misc/ArgumentCommentCheck.cpp
index 20069b94..f80b9850 100644
--- a/clang-tidy/misc/ArgumentCommentCheck.cpp
+++ b/clang-tidy/misc/ArgumentCommentCheck.cpp
@@ -177,7 +177,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
}
void ArgumentCommentCheck::check(const MatchFinder::MatchResult &Result) {
- const Expr *E = Result.Nodes.getNodeAs<Expr>("expr");
+ const auto *E = Result.Nodes.getNodeAs<Expr>("expr");
if (const auto *Call = dyn_cast<CallExpr>(E)) {
const FunctionDecl *Callee = Call->getDirectCallee();
if (!Callee)
diff --git a/clang-tidy/misc/MoveForwardingReferenceCheck.cpp b/clang-tidy/misc/MoveForwardingReferenceCheck.cpp
index 986edeac..12c19dd9 100644
--- a/clang-tidy/misc/MoveForwardingReferenceCheck.cpp
+++ b/clang-tidy/misc/MoveForwardingReferenceCheck.cpp
@@ -104,8 +104,7 @@ void MoveForwardingReferenceCheck::check(
// Get the FunctionDecl and FunctionTemplateDecl containing the function
// parameter.
- const FunctionDecl *FuncForParam =
- dyn_cast<FunctionDecl>(ParmVar->getDeclContext());
+ const auto *FuncForParam = dyn_cast<FunctionDecl>(ParmVar->getDeclContext());
if (!FuncForParam)
return;
const FunctionTemplateDecl *FuncTemplate =
diff --git a/clang-tidy/misc/MultipleStatementMacroCheck.cpp b/clang-tidy/misc/MultipleStatementMacroCheck.cpp
index a8a220bf..9d485fd2 100644
--- a/clang-tidy/misc/MultipleStatementMacroCheck.cpp
+++ b/clang-tidy/misc/MultipleStatementMacroCheck.cpp
@@ -26,7 +26,7 @@ const Stmt *nextStmt(const MatchFinder::MatchResult &Result, const Stmt *S) {
auto Parents = Result.Context->getParents(*S);
if (Parents.empty())
return nullptr;
- const Stmt *Parent = Parents[0].get<Stmt>();
+ const auto *Parent = Parents[0].get<Stmt>();
if (!Parent)
return nullptr;
const Stmt *Prev = nullptr;
diff --git a/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp b/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
index e6177ba8..00befd2e 100644
--- a/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
+++ b/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
@@ -100,10 +100,8 @@ void ThrowByValueCatchByReferenceCheck::diagnoseThrowLocations(
if (CheckAnonymousTemporaries) {
bool emit = false;
auto *currentSubExpr = subExpr->IgnoreImpCasts();
- const DeclRefExpr *variableReference =
- dyn_cast<DeclRefExpr>(currentSubExpr);
- const CXXConstructExpr *constructorCall =
- dyn_cast<CXXConstructExpr>(currentSubExpr);
+ const auto *variableReference = dyn_cast<DeclRefExpr>(currentSubExpr);
+ const auto *constructorCall = dyn_cast<CXXConstructExpr>(currentSubExpr);
// If we have a DeclRefExpr, we flag for emitting a diagnosis message in
// case the referenced variable is neither a function parameter nor a
// variable declared in the catch statement.
diff --git a/clang-tidy/modernize/UseNullptrCheck.cpp b/clang-tidy/modernize/UseNullptrCheck.cpp
index 16b6f20d..50c2f890 100644
--- a/clang-tidy/modernize/UseNullptrCheck.cpp
+++ b/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -26,7 +26,7 @@ const char CastSequence[] = "sequence";
AST_MATCHER(Type, sugaredNullptrType) {
const Type *DesugaredType = Node.getUnqualifiedDesugaredType();
- if (const BuiltinType *BT = dyn_cast<BuiltinType>(DesugaredType))
+ if (const auto *BT = dyn_cast<BuiltinType>(DesugaredType))
return BT->getKind() == BuiltinType::NullPtr;
return false;
}
@@ -188,7 +188,7 @@ public:
// Only VisitStmt is overridden as we shouldn't find other base AST types
// within a cast expression.
bool VisitStmt(Stmt *S) {
- CastExpr *C = dyn_cast<CastExpr>(S);
+ auto *C = dyn_cast<CastExpr>(S);
// Catch the castExpr inside cxxDefaultArgExpr.
if (auto *E = dyn_cast<CXXDefaultArgExpr>(S))
C = dyn_cast<CastExpr>(E->getExpr());
diff --git a/clang-tidy/modernize/UseOverrideCheck.cpp b/clang-tidy/modernize/UseOverrideCheck.cpp
index 574d1a77..be01d215 100644
--- a/clang-tidy/modernize/UseOverrideCheck.cpp
+++ b/clang-tidy/modernize/UseOverrideCheck.cpp
@@ -60,7 +60,7 @@ static StringRef GetText(const Token &Tok, const SourceManager &Sources) {
}
void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
- const FunctionDecl *Method = Result.Nodes.getNodeAs<FunctionDecl>("method");
+ const auto *Method = Result.Nodes.getNodeAs<FunctionDecl>("method");
const SourceManager &Sources = *Result.SourceManager;
assert(Method != nullptr);
diff --git a/clang-tidy/mpi/TypeMismatchCheck.cpp b/clang-tidy/mpi/TypeMismatchCheck.cpp
index efe4aee5..a1f92b8f 100644
--- a/clang-tidy/mpi/TypeMismatchCheck.cpp
+++ b/clang-tidy/mpi/TypeMismatchCheck.cpp
@@ -243,7 +243,7 @@ void TypeMismatchCheck::registerMatchers(MatchFinder *Finder) {
void TypeMismatchCheck::check(const MatchFinder::MatchResult &Result) {
static ento::mpi::MPIFunctionClassifier FuncClassifier(*Result.Context);
- const CallExpr *const CE = Result.Nodes.getNodeAs<CallExpr>("CE");
+ const auto *const CE = Result.Nodes.getNodeAs<CallExpr>("CE");
if (!CE->getDirectCallee())
return;
diff --git a/clang-tidy/readability/ImplicitBoolCastCheck.cpp b/clang-tidy/readability/ImplicitBoolCastCheck.cpp
index a8fc5d13..3322cbf1 100644
--- a/clang-tidy/readability/ImplicitBoolCastCheck.cpp
+++ b/clang-tidy/readability/ImplicitBoolCastCheck.cpp
@@ -102,7 +102,7 @@ bool areParensNeededForOverloadedOperator(OverloadedOperatorKind OperatorKind) {
}
bool areParensNeededForStatement(const Stmt *Statement) {
- if (const CXXOperatorCallExpr *OverloadedOperatorCall =
+ if (const auto *OverloadedOperatorCall =
llvm::dyn_cast<CXXOperatorCallExpr>(Statement)) {
return areParensNeededForOverloadedOperator(
OverloadedOperatorCall->getOperator());
diff --git a/clang-tidy/readability/NamespaceCommentCheck.cpp b/clang-tidy/readability/NamespaceCommentCheck.cpp
index b7a218ae..d9e71127 100644
--- a/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ b/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -57,7 +57,7 @@ static std::string getNamespaceComment(const NamespaceDecl *ND,
}
void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
- const NamespaceDecl *ND = Result.Nodes.getNodeAs<NamespaceDecl>("namespace");
+ const auto *ND = Result.Nodes.getNodeAs<NamespaceDecl>("namespace");
const SourceManager &Sources = *Result.SourceManager;
if (!locationsInSameFile(Sources, ND->getLocStart(), ND->getRBraceLoc()))
diff --git a/clang-tidy/readability/RedundantDeclarationCheck.cpp b/clang-tidy/readability/RedundantDeclarationCheck.cpp
index 10ba1229..672cda65 100644
--- a/clang-tidy/readability/RedundantDeclarationCheck.cpp
+++ b/clang-tidy/readability/RedundantDeclarationCheck.cpp
@@ -24,7 +24,7 @@ void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) {
}
void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) {
- const NamedDecl *D = Result.Nodes.getNodeAs<NamedDecl>("Decl");
+ const auto *D = Result.Nodes.getNodeAs<NamedDecl>("Decl");
const auto *Prev = D->getPreviousDecl();
if (!Prev)
return;
diff --git a/clang-tidy/readability/RedundantSmartptrGetCheck.cpp b/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
index 5aad5b52..dd6866f5 100644
--- a/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
+++ b/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
@@ -116,8 +116,8 @@ void RedundantSmartptrGetCheck::check(const MatchFinder::MatchResult &Result) {
bool IsPtrToPtr = Result.Nodes.getNodeAs<Decl>("ptr_to_ptr") != nullptr;
bool IsMemberExpr = Result.Nodes.getNodeAs<Expr>("memberExpr") != nullptr;
- const Expr *GetCall = Result.Nodes.getNodeAs<Expr>("redundant_get");
- const Expr *Smartptr = Result.Nodes.getNodeAs<Expr>("smart_pointer");
+ const auto *GetCall = Result.Nodes.getNodeAs<Expr>("redundant_get");
+ const auto *Smartptr = Result.Nodes.getNodeAs<Expr>("smart_pointer");
if (IsPtrToPtr && IsMemberExpr) {
// Ignore this case (eg. Foo->get()->DoSomething());
diff --git a/include-fixer/find-all-symbols/FindAllSymbols.cpp b/include-fixer/find-all-symbols/FindAllSymbols.cpp
index 60c0615c..d37918fe 100644
--- a/include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ b/include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -211,7 +211,7 @@ void FindAllSymbols::run(const MatchFinder::MatchResult &Result) {
return;
}
- const NamedDecl *ND = Result.Nodes.getNodeAs<NamedDecl>("decl");
+ const auto *ND = Result.Nodes.getNodeAs<NamedDecl>("decl");
assert(ND && "Matched declaration must be a NamedDecl!");
const SourceManager *SM = Result.SourceManager;
diff --git a/modularize/CoverageChecker.cpp b/modularize/CoverageChecker.cpp
index b3aa3c9b..630ab558 100644
--- a/modularize/CoverageChecker.cpp
+++ b/modularize/CoverageChecker.cpp
@@ -225,9 +225,8 @@ bool CoverageChecker::collectModuleHeaders(const Module &Mod) {
ModuleMapHeadersSet.insert(ModularizeUtilities::getCanonicalPath(
Header.Entry->getName()));
- for (Module::submodule_const_iterator MI = Mod.submodule_begin(),
- MIEnd = Mod.submodule_end();
- MI != MIEnd; ++MI)
+ for (auto MI = Mod.submodule_begin(), MIEnd = Mod.submodule_end();
+ MI != MIEnd; ++MI)
collectModuleHeaders(**MI);
return true;
diff --git a/modularize/Modularize.cpp b/modularize/Modularize.cpp
index 284e3299..83f23402 100644
--- a/modularize/Modularize.cpp
+++ b/modularize/Modularize.cpp
@@ -341,9 +341,7 @@ static std::string findInputFile(const CommandLineArguments &CLArgs) {
const unsigned IncludedFlagsBitmask = options::CC1Option;
unsigned MissingArgIndex, MissingArgCount;
SmallVector<const char *, 256> Argv;
- for (CommandLineArguments::const_iterator I = CLArgs.begin(),
- E = CLArgs.end();
- I != E; ++I)
+ for (auto I = CLArgs.begin(), E = CLArgs.end(); I != E; ++I)
Argv.push_back(I->c_str());
InputArgList Args = Opts->ParseArgs(Argv, MissingArgIndex, MissingArgCount,
IncludedFlagsBitmask);
diff --git a/modularize/ModularizeUtilities.cpp b/modularize/ModularizeUtilities.cpp
index 9a268950..f20f4f6b 100644
--- a/modularize/ModularizeUtilities.cpp
+++ b/modularize/ModularizeUtilities.cpp
@@ -77,7 +77,7 @@ ModularizeUtilities *ModularizeUtilities::createModularizeUtilities(
std::error_code ModularizeUtilities::loadAllHeaderListsAndDependencies() {
typedef std::vector<std::string>::iterator Iter;
// For each input file.
- for (Iter I = InputFilePaths.begin(), E = InputFilePaths.end(); I != E; ++I) {
+ for (auto I = InputFilePaths.begin(), E = InputFilePaths.end(); I != E; ++I) {
llvm::StringRef InputPath = *I;
// If it's a module map.
if (InputPath.endswith(".modulemap")) {
@@ -345,9 +345,8 @@ bool ModularizeUtilities::collectModuleHeaders(const clang::Module &Mod) {
DependentsVector UmbrellaDependents;
// Recursively do submodules.
- for (clang::Module::submodule_const_iterator MI = Mod.submodule_begin(),
- MIEnd = Mod.submodule_end();
- MI != MIEnd; ++MI)
+ for (auto MI = Mod.submodule_begin(), MIEnd = Mod.submodule_end();
+ MI != MIEnd; ++MI)
collectModuleHeaders(**MI);
if (const FileEntry *UmbrellaHeader = Mod.getUmbrellaHeader().Entry) {
diff --git a/modularize/ModuleAssistant.cpp b/modularize/ModuleAssistant.cpp
index e1c32dfa..26c59254 100644
--- a/modularize/ModuleAssistant.cpp
+++ b/modularize/ModuleAssistant.cpp
@@ -87,17 +87,14 @@ bool Module::output(llvm::raw_fd_ostream &OS, int Indent) {
}
// Output submodules.
- for (std::vector<Module *>::iterator I = SubModules.begin(),
- E = SubModules.end();
- I != E; ++I) {
+ for (auto I = SubModules.begin(), E = SubModules.end(); I != E; ++I) {
if (!(*I)->output(OS, Indent))
return false;
}
// Output header files.
- for (std::vector<std::string>::iterator I = HeaderFileNames.begin(),
- E = HeaderFileNames.end();
- I != E; ++I) {
+ for (auto I = HeaderFileNames.begin(), E = HeaderFileNames.end(); I != E;
+ ++I) {
OS.indent(Indent);
if (IsProblem || strstr((*I).c_str(), ".inl"))
OS << "exclude header \"" << *I << "\"\n";
@@ -123,9 +120,7 @@ bool Module::output(llvm::raw_fd_ostream &OS, int Indent) {
// Lookup a sub-module.
Module *Module::findSubModule(llvm::StringRef SubName) {
- for (std::vector<Module *>::iterator I = SubModules.begin(),
- E = SubModules.end();
- I != E; ++I) {
+ for (auto I = SubModules.begin(), E = SubModules.end(); I != E; ++I) {
if ((*I)->Name == SubName)
return *I;
}
@@ -227,7 +222,7 @@ static Module *loadModuleDescriptions(
DependencyMap &Dependencies, llvm::StringRef HeaderPrefix) {
// Create root module.
- Module *RootModule = new Module(RootModuleName, false);
+ auto *RootModule = new Module(RootModuleName, false);
llvm::SmallString<256> CurrentDirectory;
llvm::sys::fs::current_path(CurrentDirectory);
diff --git a/modularize/PreprocessorTracker.cpp b/modularize/PreprocessorTracker.cpp
index f594cd5a..31935689 100644
--- a/modularize/PreprocessorTracker.cpp
+++ b/modularize/PreprocessorTracker.cpp
@@ -558,9 +558,7 @@ public:
// Check for the presence of a header inclusion path handle entry.
// Return false if not found.
bool haveInclusionPathHandle(InclusionPathHandle H) {
- for (std::vector<InclusionPathHandle>::iterator
- I = InclusionPathHandles.begin(),
- E = InclusionPathHandles.end();
+ for (auto I = InclusionPathHandles.begin(), E = InclusionPathHandles.end();
I != E; ++I) {
if (*I == H)
return true;
@@ -608,9 +606,8 @@ public:
MacroExpansionInstance *
findMacroExpansionInstance(StringHandle MacroExpanded,
PPItemKey &DefinitionLocation) {
- for (std::vector<MacroExpansionInstance>::iterator
- I = MacroExpansionInstances.begin(),
- E = MacroExpansionInstances.end();
+ for (auto I = MacroExpansionInstances.begin(),
+ E = MacroExpansionInstances.end();
I != E; ++I) {
if ((I->MacroExpanded == MacroExpanded) &&
(I->DefinitionLocation == DefinitionLocation)) {
@@ -659,9 +656,7 @@ public:
// Check for the presence of a header inclusion path handle entry.
// Return false if not found.
bool haveInclusionPathHandle(InclusionPathHandle H) {
- for (std::vector<InclusionPathHandle>::iterator
- I = InclusionPathHandles.begin(),
- E = InclusionPathHandles.end();
+ for (auto I = InclusionPathHandles.begin(), E = InclusionPathHandles.end();
I != E; ++I) {
if (*I == H)
return true;
@@ -701,9 +696,8 @@ public:
// Find a matching condition expansion instance.
ConditionalExpansionInstance *
findConditionalExpansionInstance(clang::PPCallbacks::ConditionValueKind ConditionValue) {
- for (std::vector<ConditionalExpansionInstance>::iterator
- I = ConditionalExpansionInstances.begin(),
- E = ConditionalExpansionInstances.end();
+ for (auto I = ConditionalExpansionInstances.begin(),
+ E = ConditionalExpansionInstances.end();
I != E; ++I) {
if (I->ConditionValue == ConditionValue) {
return &*I; // Found.
@@ -954,9 +948,8 @@ public:
HeaderHandle findHeaderHandle(llvm::StringRef HeaderPath) const {
std::string CanonicalPath = getCanonicalPath(HeaderPath);
HeaderHandle H = 0;
- for (std::vector<StringHandle>::const_iterator I = HeaderPaths.begin(),
- E = HeaderPaths.end();
- I != E; ++I, ++H) {
+ for (auto I = HeaderPaths.begin(), E = HeaderPaths.end(); I != E;
+ ++I, ++H) {
if (**I == CanonicalPath)
return H;
}
@@ -1004,9 +997,7 @@ public:
// Check for presence of header handle in the header stack.
bool isHeaderHandleInStack(HeaderHandle H) const {
- for (std::vector<HeaderHandle>::const_iterator I = HeaderStack.begin(),
- E = HeaderStack.end();
- I != E; ++I) {
+ for (auto I = HeaderStack.begin(), E = HeaderStack.end(); I != E; ++I) {
if (*I == H)
return true;
}
@@ -1018,10 +1009,8 @@ public:
InclusionPathHandle
findInclusionPathHandle(const std::vector<HeaderHandle> &Path) const {
InclusionPathHandle H = 0;
- for (std::vector<HeaderInclusionPath>::const_iterator
- I = InclusionPaths.begin(),
- E = InclusionPaths.end();
- I != E; ++I, ++H) {
+ for (auto I = InclusionPaths.begin(), E = InclusionPaths.end(); I != E;
+ ++I, ++H) {
if (I->Path == Path)
return H;
}
@@ -1065,7 +1054,7 @@ public:
StringHandle MacroName = addString(II->getName());
PPItemKey InstanceKey(PP, MacroName, H, InstanceLoc);
PPItemKey DefinitionKey(PP, MacroName, H, DefinitionLoc);
- MacroExpansionMapIter I = MacroExpansions.find(InstanceKey);
+ auto I = MacroExpansions.find(InstanceKey);
// If existing instance of expansion not found, add one.
if (I == MacroExpansions.end()) {
std::string InstanceSourceLine =
@@ -1113,7 +1102,7 @@ public:
return;
StringHandle ConditionUnexpandedHandle(addString(ConditionUnexpanded));
PPItemKey InstanceKey(PP, ConditionUnexpandedHandle, H, InstanceLoc);
- ConditionalExpansionMapIter I = ConditionalExpansions.find(InstanceKey);
+ auto I = ConditionalExpansions.find(InstanceKey);
// If existing instance of condition not found, add one.
if (I == ConditionalExpansions.end()) {
std::string InstanceSourceLine =
@@ -1144,9 +1133,8 @@ public:
bool reportInconsistentMacros(llvm::raw_ostream &OS) override {
bool ReturnValue = false;
// Walk all the macro expansion trackers in the map.
- for (MacroExpansionMapIter I = MacroExpansions.begin(),
- E = MacroExpansions.end();
- I != E; ++I) {
+ for (auto I = MacroExpansions.begin(), E = MacroExpansions.end(); I != E;
+ ++I) {
const PPItemKey &ItemKey = I->first;
MacroExpansionTracker &MacroExpTracker = I->second;
// If no mismatch (only one instance value) continue.
@@ -1162,21 +1150,19 @@ public:
<< "' has different values in this header, depending on how it was "
"included.\n";
// Walk all the instances.
- for (std::vector<MacroExpansionInstance>::iterator
- IMT = MacroExpTracker.MacroExpansionInstances.begin(),
- EMT = MacroExpTracker.MacroExpansionInstances.end();
+ for (auto IMT = MacroExpTracker.MacroExpansionInstances.begin(),
+ EMT = MacroExpTracker.MacroExpansionInstances.end();
IMT != EMT; ++IMT) {
MacroExpansionInstance &MacroInfo = *IMT;
OS << " '" << *MacroExpTracker.MacroUnexpanded << "' expanded to: '"
<< *MacroInfo.MacroExpanded
<< "' with respect to these inclusion paths:\n";
// Walk all the inclusion path hierarchies.
- for (std::vector<InclusionPathHandle>::iterator
- IIP = MacroInfo.InclusionPathHandles.begin(),
- EIP = MacroInfo.InclusionPathHandles.end();
+ for (auto IIP = MacroInfo.InclusionPathHandles.begin(),
+ EIP = MacroInfo.InclusionPathHandles.end();
IIP != EIP; ++IIP) {
const std::vector<HeaderHandle> &ip = getInclusionPath(*IIP);
- int Count = (int)ip.size();
+ auto Count = (int)ip.size();
for (int Index = 0; Index < Count; ++Index) {
HeaderHandle H = ip[Index];
OS << std::string((Index * 2) + 4, ' ') << *getHeaderFilePath(H)
@@ -1205,8 +1191,8 @@ public:
bool reportInconsistentConditionals(llvm::raw_ostream &OS) override {
bool ReturnValue = false;
// Walk all the conditional trackers in the map.
- for (ConditionalExpansionMapIter I = ConditionalExpansions.begin(),
- E = ConditionalExpansions.end();
+ for (auto I = ConditionalExpansions.begin(),
+ E = ConditionalExpansions.end();
I != E; ++I) {
const PPItemKey &ItemKey = I->first;
ConditionalTracker &CondTracker = I->second;
@@ -1225,21 +1211,19 @@ public:
<< "' has different values in this header, depending on how it was "
"included.\n";
// Walk all the instances.
- for (std::vector<ConditionalExpansionInstance>::iterator
- IMT = CondTracker.ConditionalExpansionInstances.begin(),
- EMT = CondTracker.ConditionalExpansionInstances.end();
+ for (auto IMT = CondTracker.ConditionalExpansionInstances.begin(),
+ EMT = CondTracker.ConditionalExpansionInstances.end();
IMT != EMT; ++IMT) {
ConditionalExpansionInstance &MacroInfo = *IMT;
OS << " '" << *CondTracker.ConditionUnexpanded << "' expanded to: '"
<< ConditionValueKindStrings[MacroInfo.ConditionValue]
<< "' with respect to these inclusion paths:\n";
// Walk all the inclusion path hierarchies.
- for (std::vector<InclusionPathHandle>::iterator
- IIP = MacroInfo.InclusionPathHandles.begin(),
- EIP = MacroInfo.InclusionPathHandles.end();
+ for (auto IIP = MacroInfo.InclusionPathHandles.begin(),
+ EIP = MacroInfo.InclusionPathHandles.end();
IIP != EIP; ++IIP) {
const std::vector<HeaderHandle> &ip = getInclusionPath(*IIP);
- int Count = (int)ip.size();
+ auto Count = (int)ip.size();
for (int Index = 0; Index < Count; ++Index) {
HeaderHandle H = ip[Index];
OS << std::string((Index * 2) + 4, ' ') << *getHeaderFilePath(H)
diff --git a/pp-trace/PPTrace.cpp b/pp-trace/PPTrace.cpp
index 51c844cc..0a507926 100644
--- a/pp-trace/PPTrace.cpp
+++ b/pp-trace/PPTrace.cpp
@@ -161,8 +161,7 @@ static int outputPPTrace(std::vector<CallbackCall> &CallbackCalls,
const CallbackCall &Callback = *I;
OS << "- Callback: " << Callback.Name << "\n";
- for (std::vector<Argument>::const_iterator AI = Callback.Arguments.begin(),
- AE = Callback.Arguments.end();
+ for (auto AI = Callback.Arguments.begin(), AE = Callback.Arguments.end();
AI != AE; ++AI) {
const Argument &Arg = *AI;
OS << " " << Arg.Name << ": " << Arg.Value << "\n";
diff --git a/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp b/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
index 621dc5e8..5ceda0ff 100644
--- a/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ b/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -14,7 +14,7 @@ public:
Finder->addMatcher(ast_matchers::varDecl().bind("var"), this);
}
void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
- const VarDecl *Var = Result.Nodes.getNodeAs<VarDecl>("var");
+ const auto *Var = Result.Nodes.getNodeAs<VarDecl>("var");
// Add diagnostics in the wrong order.
diag(Var->getLocation(), "variable");
diag(Var->getTypeSpecStartLoc(), "type specifier");
diff --git a/unittests/clang-tidy/NamespaceAliaserTest.cpp b/unittests/clang-tidy/NamespaceAliaserTest.cpp
index 7369e947..71286e29 100644
--- a/unittests/clang-tidy/NamespaceAliaserTest.cpp
+++ b/unittests/clang-tidy/NamespaceAliaserTest.cpp
@@ -31,8 +31,7 @@ public:
if (!Aliaser)
Aliaser.reset(new NamespaceAliaser(*Result.SourceManager));
- const CallExpr *Call =
- Result.Nodes.getNodeAs<CallExpr>("foo");
+ const auto *Call = Result.Nodes.getNodeAs<CallExpr>("foo");
assert(Call != nullptr && "Did not find node \"foo\"");
auto Hint = Aliaser->createAlias(*Result.Context, *Call, "::foo::bar",
{"b", "some_alias"});
diff --git a/unittests/clang-tidy/UsingInserterTest.cpp b/unittests/clang-tidy/UsingInserterTest.cpp
index bee4f673..9e465a0c 100644
--- a/unittests/clang-tidy/UsingInserterTest.cpp
+++ b/unittests/clang-tidy/UsingInserterTest.cpp
@@ -33,8 +33,7 @@ public:
if (!Inserter)
Inserter.reset(new UsingInserter(*Result.SourceManager));
- const clang::CallExpr *Call =
- Result.Nodes.getNodeAs<clang::CallExpr>("foo");
+ const auto *Call = Result.Nodes.getNodeAs<clang::CallExpr>("foo");
assert(Call != nullptr && "Did not find node \"foo\"");
auto Hint =
Inserter->createUsingDeclaration(*Result.Context, *Call, "::foo::func");