diff options
| author | Mandeep Singh Grang <mgrang@codeaurora.org> | 2016-11-08 07:50:19 +0000 |
|---|---|---|
| committer | Mandeep Singh Grang <mgrang@codeaurora.org> | 2016-11-08 07:50:19 +0000 |
| commit | 7c7ea7d0ae4041e92a4d510874e78da9f5e3bc1c (patch) | |
| tree | 58745ba1b5123ed61711bbf23879bf5350c74e81 /clang-tools-extra/clang-tidy/readability | |
| parent | d700c357d4689abb48121f61690a4080e39c326d (diff) | |
| download | bcm5719-llvm-7c7ea7d0ae4041e92a4d510874e78da9f5e3bc1c.tar.gz bcm5719-llvm-7c7ea7d0ae4041e92a4d510874e78da9f5e3bc1c.zip | |
[clang-tools-extra] Format sources with clang-format. NFC.
Summary:
Ran clang-format on all .c/.cpp/.h files in clang-tools-extra.
Excluded the test, unittests, clang-reorder-fields, include-fixer, modularize and pptrace directories.
Reviewers: klimek, alexfh
Subscribers: nemanjai
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D26329
llvm-svn: 286221
Diffstat (limited to 'clang-tools-extra/clang-tidy/readability')
15 files changed, 72 insertions, 81 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp index ca2411cfa51..70329e83baa 100644 --- a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp +++ b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp @@ -8,10 +8,10 @@ //===----------------------------------------------------------------------===// #include "AvoidConstParamsInDecls.h" -#include "llvm/ADT/Optional.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/ASTMatchers/ASTMatchers.h" #include "clang/Lex/Lexer.h" +#include "llvm/ADT/Optional.h" using namespace clang::ast_matchers; diff --git a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp index 5186c0b1f61..4dea41dfb4a 100644 --- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp @@ -117,8 +117,8 @@ BracesAroundStatementsCheck::BracesAroundStatementsCheck( // Always add braces by default. ShortStatementLines(Options.get("ShortStatementLines", 0U)) {} -void -BracesAroundStatementsCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { +void BracesAroundStatementsCheck::storeOptions( + ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "ShortStatementLines", ShortStatementLines); } @@ -130,8 +130,8 @@ void BracesAroundStatementsCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher(cxxForRangeStmt().bind("for-range"), this); } -void -BracesAroundStatementsCheck::check(const MatchFinder::MatchResult &Result) { +void BracesAroundStatementsCheck::check( + const MatchFinder::MatchResult &Result) { const SourceManager &SM = *Result.SourceManager; const ASTContext *Context = Result.Context; diff --git a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.h b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.h index 12d7b37a652..919ca4633a0 100644 --- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.h +++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.h @@ -58,7 +58,7 @@ private: const ASTContext *Context); private: - std::set<const Stmt*> ForceBracesStmts; + std::set<const Stmt *> ForceBracesStmts; const unsigned ShortStatementLines; }; diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index f3b29302ee5..f73bc37e09d 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -9,13 +9,13 @@ #include "IdentifierNamingCheck.h" -#include "llvm/ADT/DenseMapInfo.h" -#include "llvm/Support/Debug.h" -#include "llvm/Support/Format.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Preprocessor.h" +#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/Format.h" #define DEBUG_TYPE "clang-tidy" @@ -662,7 +662,8 @@ static void addUsage(IdentifierNamingCheck::NamingCheckFailureMap &Failures, /// Convenience method when the usage to be added is a NamedDecl static void addUsage(IdentifierNamingCheck::NamingCheckFailureMap &Failures, - const NamedDecl *Decl, SourceRange Range, SourceManager *SourceMgr = nullptr) { + const NamedDecl *Decl, SourceRange Range, + SourceManager *SourceMgr = nullptr) { return addUsage(Failures, IdentifierNamingCheck::NamingCheckId( Decl->getLocation(), Decl->getNameAsString()), Range, SourceMgr); @@ -752,7 +753,8 @@ void IdentifierNamingCheck::check(const MatchFinder::MatchResult &Result) { if (const auto *DeclRef = Result.Nodes.getNodeAs<DeclRefExpr>("declRef")) { SourceRange Range = DeclRef->getNameInfo().getSourceRange(); - addUsage(NamingCheckFailures, DeclRef->getDecl(), Range, Result.SourceManager); + addUsage(NamingCheckFailures, DeclRef->getDecl(), Range, + Result.SourceManager); return; } diff --git a/clang-tools-extra/clang-tidy/readability/ImplicitBoolCastCheck.cpp b/clang-tools-extra/clang-tidy/readability/ImplicitBoolCastCheck.cpp index 38e4098fb9c..a8fc5d135ec 100644 --- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolCastCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolCastCheck.cpp @@ -307,8 +307,7 @@ ImplicitBoolCastCheck::ImplicitBoolCastCheck(StringRef Name, AllowConditionalPointerCasts( Options.get("AllowConditionalPointerCasts", false)) {} -void ImplicitBoolCastCheck::storeOptions( - ClangTidyOptions::OptionMap &Opts) { +void ImplicitBoolCastCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "AllowConditionalIntegerCasts", AllowConditionalIntegerCasts); Options.store(Opts, "AllowConditionalPointerCasts", diff --git a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp index e3e82d717d5..d20416e8086 100644 --- a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp @@ -110,7 +110,8 @@ findDifferingParamsInDeclaration(const FunctionDecl *ParameterSourceDeclaration, SourceParamName != OtherParamName) { SourceRange OtherParamNameRange = DeclarationNameInfo((*OtherParamIt)->getDeclName(), - (*OtherParamIt)->getLocation()).getSourceRange(); + (*OtherParamIt)->getLocation()) + .getSourceRange(); bool GenerateFixItHint = checkIfFixItHintIsApplicable( ParameterSourceDeclaration, *SourceParamIt, OriginalDeclaration); @@ -202,13 +203,15 @@ std::string joinParameterNames( } void formatDifferingParamsDiagnostic( - InconsistentDeclarationParameterNameCheck *Check, - SourceLocation Location, StringRef OtherDeclarationDescription, + InconsistentDeclarationParameterNameCheck *Check, SourceLocation Location, + StringRef OtherDeclarationDescription, const DifferingParamsContainer &DifferingParams) { - auto ChooseOtherName = - [](const DifferingParamInfo &ParamInfo) { return ParamInfo.OtherName; }; - auto ChooseSourceName = - [](const DifferingParamInfo &ParamInfo) { return ParamInfo.SourceName; }; + auto ChooseOtherName = [](const DifferingParamInfo &ParamInfo) { + return ParamInfo.OtherName; + }; + auto ChooseSourceName = [](const DifferingParamInfo &ParamInfo) { + return ParamInfo.SourceName; + }; auto ParamDiag = Check->diag(Location, diff --git a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp index 402bf510d23..b7a218ae055 100644 --- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp @@ -114,7 +114,8 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) { Message = (llvm::Twine( "%0 ends with a comment that refers to a wrong namespace '") + - NamespaceNameInComment + "'").str(); + NamespaceNameInComment + "'") + .str(); } else if (Comment.startswith("//")) { // Assume that this is an unrecognized form of a namespace closing line // comment. Replace it. diff --git a/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp index 4f8f8d175c9..0788c42e7b6 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantControlFlowCheck.cpp @@ -33,9 +33,10 @@ bool isLocationInMacroExpansion(const SourceManager &SM, SourceLocation Loc) { void RedundantControlFlowCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( - functionDecl(isDefinition(), returns(voidType()), - has(compoundStmt(hasAnySubstatement(returnStmt( - unless(has(expr()))))).bind("return"))), + functionDecl( + isDefinition(), returns(voidType()), + has(compoundStmt(hasAnySubstatement(returnStmt(unless(has(expr()))))) + .bind("return"))), this); auto CompoundContinue = has(compoundStmt(hasAnySubstatement(continueStmt())).bind("continue")); diff --git a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp index 44aa7a5a18e..ea7d8168ad4 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp @@ -19,7 +19,8 @@ namespace tidy { namespace readability { void RedundantDeclarationCheck::registerMatchers(MatchFinder *Finder) { - Finder->addMatcher(namedDecl(anyOf(varDecl(), functionDecl())).bind("Decl"), this); + Finder->addMatcher(namedDecl(anyOf(varDecl(), functionDecl())).bind("Decl"), + this); } void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) { @@ -33,8 +34,8 @@ void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) { const SourceManager &SM = *Result.SourceManager; const bool DifferentHeaders = - !SM.isInMainFile(D->getLocation()) && - !SM.isWrittenInSameFile(Prev->getLocation(), D->getLocation()); + !SM.isInMainFile(D->getLocation()) && + !SM.isWrittenInSameFile(Prev->getLocation(), D->getLocation()); bool MultiVar = false; if (const auto *VD = dyn_cast<VarDecl>(D)) { @@ -57,8 +58,7 @@ void RedundantDeclarationCheck::check(const MatchFinder::MatchResult &Result) { SourceLocation EndLoc = Lexer::getLocForEndOfToken( D->getSourceRange().getEnd(), 0, SM, Result.Context->getLangOpts()); { - auto Diag = diag(D->getLocation(), "redundant %0 declaration") - << D; + auto Diag = diag(D->getLocation(), "redundant %0 declaration") << D; if (!MultiVar && !DifferentHeaders) Diag << FixItHint::CreateRemoval( SourceRange(D->getSourceRange().getBegin(), EndLoc)); diff --git a/clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp index 0259c342a8d..26003e6cf44 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp @@ -8,10 +8,10 @@ //===----------------------------------------------------------------------===// #include "RedundantMemberInitCheck.h" +#include "../utils/Matchers.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Lex/Lexer.h" -#include "../utils/Matchers.h" #include <algorithm> using namespace clang::ast_matchers; diff --git a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp index 5b0e4ca265e..8f086b87858 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp @@ -77,17 +77,14 @@ void RedundantStringCStrCheck::registerMatchers( return; // Match expressions of type 'string' or 'string*'. - const auto StringDecl = - cxxRecordDecl(hasName("::std::basic_string")); + const auto StringDecl = cxxRecordDecl(hasName("::std::basic_string")); const auto StringExpr = - expr(anyOf(hasType(StringDecl), - hasType(qualType(pointsTo(StringDecl))))); + expr(anyOf(hasType(StringDecl), hasType(qualType(pointsTo(StringDecl))))); // Match string constructor. const auto StringConstructorExpr = expr(anyOf( - cxxConstructExpr( - argumentCountIs(1), - hasDeclaration(cxxMethodDecl(hasName("basic_string")))), + cxxConstructExpr(argumentCountIs(1), + hasDeclaration(cxxMethodDecl(hasName("basic_string")))), cxxConstructExpr( argumentCountIs(2), hasDeclaration(cxxMethodDecl(hasName("basic_string"))), @@ -103,21 +100,18 @@ void RedundantStringCStrCheck::registerMatchers( .bind("call"); // Detect redundant 'c_str()' calls through a string constructor. - Finder->addMatcher( - cxxConstructExpr(StringConstructorExpr, - hasArgument(0, StringCStrCallExpr)), - this); + Finder->addMatcher(cxxConstructExpr(StringConstructorExpr, + hasArgument(0, StringCStrCallExpr)), + this); // Detect: 's == str.c_str()' -> 's == str' Finder->addMatcher( cxxOperatorCallExpr( - anyOf(hasOverloadedOperatorName("<"), - hasOverloadedOperatorName(">"), - hasOverloadedOperatorName(">="), - hasOverloadedOperatorName("<="), - hasOverloadedOperatorName("!="), - hasOverloadedOperatorName("=="), - hasOverloadedOperatorName("+")), + anyOf( + hasOverloadedOperatorName("<"), hasOverloadedOperatorName(">"), + hasOverloadedOperatorName(">="), hasOverloadedOperatorName("<="), + hasOverloadedOperatorName("!="), hasOverloadedOperatorName("=="), + hasOverloadedOperatorName("+")), anyOf(allOf(hasArgument(0, StringExpr), hasArgument(1, StringCStrCallExpr)), allOf(hasArgument(0, StringCStrCallExpr), @@ -126,47 +120,41 @@ void RedundantStringCStrCheck::registerMatchers( // Detect: 'dst += str.c_str()' -> 'dst += str' // Detect: 's = str.c_str()' -> 's = str' - Finder->addMatcher( - cxxOperatorCallExpr( - anyOf(hasOverloadedOperatorName("="), - hasOverloadedOperatorName("+=")), - hasArgument(0, StringExpr), - hasArgument(1, StringCStrCallExpr)), - this); + Finder->addMatcher(cxxOperatorCallExpr(anyOf(hasOverloadedOperatorName("="), + hasOverloadedOperatorName("+=")), + hasArgument(0, StringExpr), + hasArgument(1, StringCStrCallExpr)), + this); // Detect: 'dst.append(str.c_str())' -> 'dst.append(str)' Finder->addMatcher( - cxxMemberCallExpr(on(StringExpr), - callee(decl(cxxMethodDecl( - hasAnyName("append", "assign", "compare")))), - argumentCountIs(1), - hasArgument(0, StringCStrCallExpr)), + cxxMemberCallExpr(on(StringExpr), callee(decl(cxxMethodDecl(hasAnyName( + "append", "assign", "compare")))), + argumentCountIs(1), hasArgument(0, StringCStrCallExpr)), this); // Detect: 'dst.compare(p, n, str.c_str())' -> 'dst.compare(p, n, str)' Finder->addMatcher( cxxMemberCallExpr(on(StringExpr), - callee(decl(cxxMethodDecl(hasName("compare")))), - argumentCountIs(3), - hasArgument(2, StringCStrCallExpr)), + callee(decl(cxxMethodDecl(hasName("compare")))), + argumentCountIs(3), hasArgument(2, StringCStrCallExpr)), this); // Detect: 'dst.find(str.c_str())' -> 'dst.find(str)' Finder->addMatcher( cxxMemberCallExpr(on(StringExpr), - callee(decl(cxxMethodDecl( - hasAnyName("find", "find_first_not_of", "find_first_of", - "find_last_not_of", "find_last_of", "rfind")))), - anyOf(argumentCountIs(1), argumentCountIs(2)), - hasArgument(0, StringCStrCallExpr)), + callee(decl(cxxMethodDecl(hasAnyName( + "find", "find_first_not_of", "find_first_of", + "find_last_not_of", "find_last_of", "rfind")))), + anyOf(argumentCountIs(1), argumentCountIs(2)), + hasArgument(0, StringCStrCallExpr)), this); // Detect: 'dst.insert(pos, str.c_str())' -> 'dst.insert(pos, str)' Finder->addMatcher( cxxMemberCallExpr(on(StringExpr), - callee(decl(cxxMethodDecl(hasName("insert")))), - argumentCountIs(2), - hasArgument(1, StringCStrCallExpr)), + callee(decl(cxxMethodDecl(hasName("insert")))), + argumentCountIs(2), hasArgument(1, StringCStrCallExpr)), this); // Detect redundant 'c_str()' calls through a StringRef constructor. @@ -176,9 +164,8 @@ void RedundantStringCStrCheck::registerMatchers( // wrt. string types and they internally make a StringRef // referring to the argument. Passing a string directly to // them is preferred to passing a char pointer. - hasDeclaration( - cxxMethodDecl(hasAnyName("::llvm::StringRef::StringRef", - "::llvm::Twine::Twine"))), + hasDeclaration(cxxMethodDecl(hasAnyName( + "::llvm::StringRef::StringRef", "::llvm::Twine::Twine"))), argumentCountIs(1), // The only argument must have the form x.c_str() or p->c_str() // where the method is string::c_str(). StringRef also has diff --git a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp index 7ca8323b7dc..b881e226e9c 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp @@ -33,10 +33,9 @@ void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) { hasArgument(1, cxxDefaultArgExpr())))); // Match a string constructor expression with an empty string literal. - const auto EmptyStringCtorExpr = - cxxConstructExpr(StringConstructorExpr, - hasArgument(0, ignoringParenImpCasts( - stringLiteral(hasSize(0))))); + const auto EmptyStringCtorExpr = cxxConstructExpr( + StringConstructorExpr, + hasArgument(0, ignoringParenImpCasts(stringLiteral(hasSize(0))))); const auto EmptyStringCtorExprWithTemporaries = cxxConstructExpr(StringConstructorExpr, diff --git a/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.h b/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.h index eeaec6a1257..03e99fd0e87 100644 --- a/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.h +++ b/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.h @@ -22,7 +22,8 @@ namespace readability { /// http://clang.llvm.org/extra/clang-tidy/checks/readability-static-definition-in-anonymous-namespace.html class StaticDefinitionInAnonymousNamespaceCheck : public ClangTidyCheck { public: - StaticDefinitionInAnonymousNamespaceCheck(StringRef Name, ClangTidyContext *Context) + StaticDefinitionInAnonymousNamespaceCheck(StringRef Name, + ClangTidyContext *Context) : ClangTidyCheck(Name, Context) {} void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; diff --git a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp index e159bc97d23..3ad346cdd9d 100644 --- a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp @@ -67,4 +67,3 @@ void UniqueptrDeleteReleaseCheck::check( } // namespace readability } // namespace tidy } // namespace clang - diff --git a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h index 43ca22d822b..fd86bdb9f52 100644 --- a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h +++ b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.h @@ -34,4 +34,3 @@ public: } // namespace clang #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_UNIQUEPTR_DELETE_RELEASE_H - |

