Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions clang-tools-extra/clang-tidy/ClangTidy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ ClangTidyASTConsumerFactory::createASTConsumer(

std::unique_ptr<ClangTidyProfiling> Profiling;
if (Context.getEnableProfiling()) {
Profiling = std::make_unique<ClangTidyProfiling>(
Context.getProfileStorageParams());
Profiling =
std::make_unique<ClangTidyProfiling>(Context.getProfileStorageParams());
FinderOptions.CheckProfiling.emplace(Profiling->Records);
}

Expand All @@ -432,8 +432,8 @@ ClangTidyASTConsumerFactory::createASTConsumer(

if (Context.canEnableModuleHeadersParsing() &&
Context.getLangOpts().Modules && OverlayFS != nullptr) {
auto ModuleExpander = std::make_unique<ExpandModularHeadersPPCallbacks>(
&Compiler, OverlayFS);
auto ModuleExpander =
std::make_unique<ExpandModularHeadersPPCallbacks>(&Compiler, OverlayFS);
ModuleExpanderPP = ModuleExpander->getPreprocessor();
PP->addPPCallbacks(std::move(ModuleExpander));
}
Expand Down Expand Up @@ -497,7 +497,7 @@ getCheckNames(const ClangTidyOptions &Options,
bool AllowEnablingAnalyzerAlphaCheckers) {
clang::tidy::ClangTidyContext Context(
std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
Options),
Options),
AllowEnablingAnalyzerAlphaCheckers);
ClangTidyASTConsumerFactory Factory(Context);
return Factory.getCheckNames();
Expand All @@ -508,7 +508,7 @@ getCheckOptions(const ClangTidyOptions &Options,
bool AllowEnablingAnalyzerAlphaCheckers) {
clang::tidy::ClangTidyContext Context(
std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
Options),
Options),
AllowEnablingAnalyzerAlphaCheckers);
ClangTidyDiagnosticConsumer DiagConsumer(Context);
auto DiagOpts = std::make_unique<DiagnosticOptions>();
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/ClangTidyCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ void ClangTidyCheck::OptionsView::store<bool>(
ClangTidyOptions::OptionMap &Options, StringRef LocalName,
bool Value) const;


} // namespace tidy
} // namespace clang

Expand Down
9 changes: 4 additions & 5 deletions clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,10 @@ class ClangTidyContext {
using DiagLevelAndFormatString = std::pair<DiagnosticIDs::Level, std::string>;
DiagLevelAndFormatString getDiagLevelAndFormatString(unsigned DiagnosticID,
SourceLocation Loc) {
return {
static_cast<DiagnosticIDs::Level>(
DiagEngine->getDiagnosticLevel(DiagnosticID, Loc)),
std::string(
DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID))};
return {static_cast<DiagnosticIDs::Level>(
DiagEngine->getDiagnosticLevel(DiagnosticID, Loc)),
std::string(
DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID))};
}

void setOptionsCollector(llvm::StringSet<> *Collector) {
Expand Down
3 changes: 2 additions & 1 deletion clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ struct NOptionMap {
NOptionMap(IO &, const ClangTidyOptions::OptionMap &OptionMap) {
Options.reserve(OptionMap.size());
for (const auto &KeyValue : OptionMap)
Options.emplace_back(std::string(KeyValue.getKey()), KeyValue.getValue().Value);
Options.emplace_back(std::string(KeyValue.getKey()),
KeyValue.getValue().Value);
}
ClangTidyOptions::OptionMap denormalize(IO &) {
ClangTidyOptions::OptionMap Map;
Expand Down
4 changes: 3 additions & 1 deletion clang-tools-extra/clang-tidy/ClangTidyOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ class FileOptionsBaseProvider : public DefaultOptionsProvider {
protected:
// A pair of configuration file base name and a function parsing
// configuration from text in the corresponding format.
using ConfigFileHandler = std::pair<std::string, std::function<llvm::ErrorOr<ClangTidyOptions> (llvm::MemoryBufferRef)>>;
using ConfigFileHandler =
std::pair<std::string, std::function<llvm::ErrorOr<ClangTidyOptions>(
llvm::MemoryBufferRef)>>;

/// Configuration file handlers listed in the order of priority.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class ExpandModularHeadersPPCallbacks::FileRecorder {
FilesToRecord.erase(File);
}

/// Makes sure we have contents for all the files we were interested in. Ideally
/// `FilesToRecord` should be empty.
/// Makes sure we have contents for all the files we were interested in.
/// Ideally `FilesToRecord` should be empty.
void checkAllFilesRecorded() {
LLVM_DEBUG({
for (auto FileEntry : FilesToRecord)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ namespace tooling {
/// including the contents of the modular headers and all their transitive
/// includes.
///
/// This allows existing tools based on PPCallbacks to retain their functionality
/// when running with C++ modules enabled. This only works in the backwards
/// compatible modules mode, i.e. when code can still be parsed in non-modular
/// way.
/// This allows existing tools based on PPCallbacks to retain their
/// functionality when running with C++ modules enabled. This only works in the
/// backwards compatible modules mode, i.e. when code can still be parsed in
/// non-modular way.
class ExpandModularHeadersPPCallbacks : public PPCallbacks {
public:
ExpandModularHeadersPPCallbacks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class ConcurrencyModule : public ClangTidyModule {

} // namespace concurrency

// Register the ConcurrencyTidyModule using this statically initialized variable.
// Register the ConcurrencyTidyModule using this statically initialized
// variable.
static ClangTidyModuleRegistry::Add<concurrency::ConcurrencyModule>
X("concurrency-module", "Adds concurrency checks.");

Expand Down
3 changes: 2 additions & 1 deletion clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

namespace clang::tidy::hicpp {

/// Check for thrown exceptions and enforce they are all derived from std::exception.
/// Check for thrown exceptions and enforce they are all derived from
/// std::exception.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/hicpp/exception-baseclass.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void MultiwayPathsCoveredCheck::check(const MatchFinder::MatchResult &Result) {
}
// Warns for degenerated 'switch' statements that neither define a case nor
// a default label.
// FIXME: Evaluate, if emitting a fix-it to simplify that statement is
// FIXME: Evaluate, if emitting a fix-it to simplify that statement is
// reasonable.
if (!SwitchHasDefault && SwitchCaseCount == 0) {
diag(Switch->getBeginLoc(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ void MustCheckErrsCheck::registerMatchers(MatchFinder *Finder) {
"ERR_CAST", "PTR_ERR_OR_ZERO"));
auto NonCheckingStmts = stmt(anyOf(compoundStmt(), labelStmt()));
Finder->addMatcher(
callExpr(callee(ErrFn), hasParent(NonCheckingStmts)).bind("call"),
this);
callExpr(callee(ErrFn), hasParent(NonCheckingStmts)).bind("call"), this);

auto ReturnToCheck = returnStmt(hasReturnValue(callExpr(callee(ErrFn))));
auto ReturnsErrFn = functionDecl(hasDescendant(ReturnToCheck));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ namespace clang::tidy::llvm_check {

/// Looks at conditionals and finds and replaces cases of ``cast<>``, which will
/// assert rather than return a null pointer, and ``dyn_cast<>`` where
/// the return value is not captured. Additionally, finds and replaces cases that match the
/// pattern ``var && isa<X>(var)``, where ``var`` is evaluated twice.
/// the return value is not captured. Additionally, finds and replaces cases
/// that match the pattern ``var && isa<X>(var)``, where ``var`` is evaluated
/// twice.
///
/// Finds cases like these:
/// \code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace clang::tidy::misc {

///checks for locations that do not throw by value
/// Checks for locations that do not throw by value
// or catch by reference.
// The check is C++ only. It checks that all throw locations
// throw by value and not by pointer. Additionally it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace clang::tidy::modernize {

/// This check warns the uses of the deprecated member types of ``std::ios_base``
/// and replaces those that have a non-deprecated equivalent.
/// This check warns the uses of the deprecated member types of
/// ``std::ios_base`` and replaces those that have a non-deprecated equivalent.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/modernize/deprecated-ios-base-aliases.html
Expand Down
5 changes: 2 additions & 3 deletions clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,8 @@ bool ForLoopIndexUseVisitor::TraverseArraySubscriptExpr(ArraySubscriptExpr *E) {
if (!isIndexInSubscriptExpr(E->getIdx(), IndexVar))
return VisitorBase::TraverseArraySubscriptExpr(E);

if ((ContainerExpr &&
!areSameExpr(Context, Arr->IgnoreParenImpCasts(),
ContainerExpr->IgnoreParenImpCasts())) ||
if ((ContainerExpr && !areSameExpr(Context, Arr->IgnoreParenImpCasts(),
ContainerExpr->IgnoreParenImpCasts())) ||
!arrayMatchesBoundExpr(Context, Arr->IgnoreImpCasts()->getType(),
ArrayBoundExpr)) {
// If we have already discovered the array being indexed and this isn't it
Expand Down
17 changes: 8 additions & 9 deletions clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ class MacroToEnumCallbacks : public PPCallbacks {
checkName(MacroNameTok);
}
void Elifdef(SourceLocation Loc, SourceRange ConditionRange,
SourceLocation IfLoc) override {
SourceLocation IfLoc) override {
PPCallbacks::Elifdef(Loc, ConditionRange, IfLoc);
}
void Elifndef(SourceLocation Loc, const Token &MacroNameTok,
const MacroDefinition &MD) override {
checkName(MacroNameTok);
}
void Elifndef(SourceLocation Loc, SourceRange ConditionRange,
SourceLocation IfLoc) override {
SourceLocation IfLoc) override {
PPCallbacks::Elifndef(Loc, ConditionRange, IfLoc);
}
void Endif(SourceLocation Loc, SourceLocation IfLoc) override;
Expand Down Expand Up @@ -316,8 +316,7 @@ void MacroToEnumCallbacks::FileChanged(SourceLocation Loc,
CurrentFile = &Files.back();
}

bool MacroToEnumCallbacks::isInitializer(ArrayRef<Token> MacroTokens)
{
bool MacroToEnumCallbacks::isInitializer(ArrayRef<Token> MacroTokens) {
IntegralLiteralExpressionMatcher Matcher(MacroTokens, LangOpts.C99 == 0);
bool Matched = Matcher.match();
bool IsC = !LangOpts.CPlusPlus;
Expand All @@ -328,7 +327,6 @@ bool MacroToEnumCallbacks::isInitializer(ArrayRef<Token> MacroTokens)
return Matched;
}


// Any defined but rejected macro is scanned for identifiers that
// are to be excluded as enums.
void MacroToEnumCallbacks::MacroDefined(const Token &MacroNameTok,
Expand Down Expand Up @@ -444,8 +442,8 @@ void MacroToEnumCallbacks::invalidateExpressionNames() {
}

void MacroToEnumCallbacks::EndOfMainFile() {
invalidateExpressionNames();
issueDiagnostics();
invalidateExpressionNames();
issueDiagnostics();
}

void MacroToEnumCallbacks::invalidateRange(SourceRange Range) {
Expand Down Expand Up @@ -517,7 +515,8 @@ void MacroToEnumCallbacks::fixEnumMacro(const MacroList &MacroList) const {
void MacroToEnumCheck::registerPPCallbacks(const SourceManager &SM,
Preprocessor *PP,
Preprocessor *ModuleExpanderPP) {
auto Callback = std::make_unique<MacroToEnumCallbacks>(this, getLangOpts(), SM);
auto Callback =
std::make_unique<MacroToEnumCallbacks>(this, getLangOpts(), SM);
PPCallback = Callback.get();
PP->addPPCallbacks(std::move(Callback));
}
Expand All @@ -540,7 +539,7 @@ void MacroToEnumCheck::check(
const ast_matchers::MatchFinder::MatchResult &Result) {
auto *TLDecl = Result.Nodes.getNodeAs<Decl>("top");
if (TLDecl == nullptr)
return;
return;

SourceRange Range = TLDecl->getSourceRange();
if (auto *TemplateFn = Result.Nodes.getNodeAs<FunctionTemplateDecl>("top")) {
Expand Down
3 changes: 1 addition & 2 deletions clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
Diag << FixItHint::CreateRemoval(
SourceRange(NewStart, InitRange.getBegin()));
Diag << FixItHint::CreateRemoval(SourceRange(InitRange.getEnd(), NewEnd));
}
else {
} else {
// New array expression with default/value initialization:
// smart_ptr<Foo[]>(new int[5]());
// smart_ptr<Foo[]>(new Foo[5]());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ class ModernizeModule : public ClangTidyModule {
CheckFactories.registerCheck<UseDefaultMemberInitCheck>(
"modernize-use-default-member-init");
CheckFactories.registerCheck<UseEmplaceCheck>("modernize-use-emplace");
CheckFactories.registerCheck<UseEqualsDefaultCheck>("modernize-use-equals-default");
CheckFactories.registerCheck<UseEqualsDefaultCheck>(
"modernize-use-equals-default");
CheckFactories.registerCheck<UseEqualsDeleteCheck>(
"modernize-use-equals-delete");
CheckFactories.registerCheck<UseNodiscardCheck>(
"modernize-use-nodiscard");
CheckFactories.registerCheck<UseNodiscardCheck>("modernize-use-nodiscard");
CheckFactories.registerCheck<UseNoexceptCheck>("modernize-use-noexcept");
CheckFactories.registerCheck<UseNullptrCheck>("modernize-use-nullptr");
CheckFactories.registerCheck<UseOverrideCheck>("modernize-use-override");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ void ReplaceAutoPtrCheck::check(const MatchFinder::MatchResult &Result) {
"auto_ptr")
return;

SourceLocation EndLoc =
AutoPtrLoc.getLocWithOffset(strlen("auto_ptr") - 1);
SourceLocation EndLoc = AutoPtrLoc.getLocWithOffset(strlen("auto_ptr") - 1);
diag(AutoPtrLoc, "auto_ptr is deprecated, use unique_ptr instead")
<< FixItHint::CreateReplacement(SourceRange(AutoPtrLoc, EndLoc),
"unique_ptr");
Expand Down
19 changes: 9 additions & 10 deletions clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ size_t getTypeNameLength(bool RemoveStars, StringRef Text) {
else if (C == '>')
--TemplateTypenameCntr;
const CharType NextChar =
isAlphanumeric(C)
? Alpha
: (isWhitespace(C) ||
(!RemoveStars && TemplateTypenameCntr == 0 && C == '*'))
? Space
: Punctuation;
isAlphanumeric(C) ? Alpha
: (isWhitespace(C) ||
(!RemoveStars && TemplateTypenameCntr == 0 && C == '*'))
? Space
: Punctuation;
if (NextChar != Space) {
++NumChars; // Count the non-space character.
if (LastChar == Space && NextChar == Alpha && BeforeSpace == Alpha)
Expand Down Expand Up @@ -444,10 +443,10 @@ void UseAutoCheck::check(const MatchFinder::MatchResult &Result) {
replaceIterators(Decl, Result.Context);
} else if (const auto *Decl =
Result.Nodes.getNodeAs<DeclStmt>(DeclWithNewId)) {
replaceExpr(Decl, Result.Context,
[](const Expr *Expr) { return Expr->getType(); },
"use auto when initializing with new to avoid "
"duplicating the type name");
replaceExpr(
Decl, Result.Context, [](const Expr *Expr) { return Expr->getType(); },
"use auto when initializing with new to avoid "
"duplicating the type name");
} else if (const auto *Decl =
Result.Nodes.getNodeAs<DeclStmt>(DeclWithCastId)) {
replaceExpr(
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ auto hasWantedType(llvm::ArrayRef<StringRef> TypeNames) {

// Matches member call expressions of the named method on the listed container
// types.
auto cxxMemberCallExprOnContainer(
StringRef MethodName, llvm::ArrayRef<StringRef> ContainerNames) {
auto cxxMemberCallExprOnContainer(StringRef MethodName,
llvm::ArrayRef<StringRef> ContainerNames) {
return cxxMemberCallExpr(
hasDeclaration(functionDecl(hasName(MethodName))),
on(hasTypeOrPointeeType(hasWantedType(ContainerNames))));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===--- UseEqualsDefaultCheck.h - clang-tidy--------------------------*- C++ -*-===//
//===--- UseEqualsDefaultCheck.h - clang-tidy---------------------*- C++-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===--- UseEqualsDeleteCheck.h - clang-tidy---------------------------*- C++ -*-===//
//===--- UseEqualsDeleteCheck.h - clang-tidy----------------------*- C++-*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class CastSequenceVisitor : public RecursiveASTVisitor<CastSequenceVisitor> {
return true;
}

auto* CastSubExpr = C->getSubExpr()->IgnoreParens();
auto *CastSubExpr = C->getSubExpr()->IgnoreParens();
// Ignore cast expressions which cast nullptr literal.
if (isa<CXXNullPtrLiteralExpr>(CastSubExpr)) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ findReturnTypeAndCVSourceRange(const FunctionDecl &F, const TypeLoc &ReturnLoc,
return {};
}


// If the return type has no local qualifiers, it's source range is accurate.
if (!hasAnyNestedLocalQualifiers(F.getReturnType()))
return ReturnTypeRange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class UseTransparentFunctorsCheck : public ClangTidyCheck {
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;

private:
const bool SafeMode;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ void UseUncaughtExceptionsCheck::registerMatchers(MatchFinder *Finder) {
this);
// CallExpr in initialisation list: warning, fix-it with avoiding narrowing
// conversions.
Finder->addMatcher(callExpr(DirectCallToUncaughtException,
hasAncestor(initListExpr()))
.bind("init_call_expr"),
this);
Finder->addMatcher(
callExpr(DirectCallToUncaughtException, hasAncestor(initListExpr()))
.bind("init_call_expr"),
this);
}

void UseUncaughtExceptionsCheck::check(const MatchFinder::MatchResult &Result) {
Expand Down
Loading
Loading