forked from OSchip/llvm-project
[clang-tidy] remove trailing whitespaces and retab
llvm-svn: 277340
This commit is contained in:
parent
d10be62383
commit
11cea45cce
|
@ -7,7 +7,7 @@ additions:
|
|||
Any file referencing a CERT Secure Coding guideline:
|
||||
Please allow this letter to serve as confirmation that open source projects on
|
||||
http://llvm.org are permitted to link via hypertext to the CERT(R) secure coding
|
||||
guidelines available at https://www.securecoding.cert.org.
|
||||
guidelines available at https://www.securecoding.cert.org.
|
||||
|
||||
The foregoing is permitted by the Terms of Use as follows:
|
||||
"Linking to the Service
|
||||
|
|
|
@ -127,7 +127,7 @@ ConversionKind ClassifyFormatString(StringRef Fmt, const LangOptions &LO,
|
|||
|
||||
Handler H;
|
||||
analyze_format_string::ParseScanfString(H, Fmt.begin(), Fmt.end(), LO, TI);
|
||||
|
||||
|
||||
return H.get();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace cppcoreguidelines {
|
||||
|
||||
|
||||
/// This check flags all array to pointer decays
|
||||
///
|
||||
/// For the user-facing documentation see:
|
||||
|
|
|
@ -16,7 +16,7 @@ using namespace clang::ast_matchers;
|
|||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace cppcoreguidelines {
|
||||
|
||||
|
||||
void ProTypeConstCastCheck::registerMatchers(MatchFinder *Finder) {
|
||||
if (!getLangOpts().CPlusPlus)
|
||||
return;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace cppcoreguidelines {
|
||||
|
||||
|
||||
/// This check flags all instances of const_cast
|
||||
///
|
||||
/// For the user-facing documentation see:
|
||||
|
|
|
@ -16,7 +16,7 @@ using namespace clang::ast_matchers;
|
|||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace cppcoreguidelines {
|
||||
|
||||
|
||||
void ProTypeStaticCastDowncastCheck::registerMatchers(MatchFinder *Finder) {
|
||||
if (!getLangOpts().CPlusPlus)
|
||||
return;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace cppcoreguidelines {
|
||||
|
||||
|
||||
/// Checks for usages of static_cast, where a base class is downcasted to a derived class.
|
||||
///
|
||||
/// For the user-facing documentation see:
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
||||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
void onEndOfTranslationUnit() override;
|
||||
|
||||
|
||||
enum class SpecialMemberFunctionKind {
|
||||
Destructor,
|
||||
CopyConstructor,
|
||||
|
@ -44,12 +44,12 @@ public:
|
|||
using ClassDefiningSpecialMembersMap = llvm::DenseMap<ClassDefId, llvm::SmallVector<SpecialMemberFunctionKind, 5>>;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
static llvm::StringRef toString(SpecialMemberFunctionKind K);
|
||||
|
||||
static std::string join(llvm::ArrayRef<SpecialMemberFunctionKind> SMFS,
|
||||
llvm::StringRef AndOr);
|
||||
|
||||
|
||||
ClassDefiningSpecialMembersMap ClassWithSpecialMembers;
|
||||
};
|
||||
|
||||
|
@ -60,7 +60,7 @@ private:
|
|||
namespace llvm {
|
||||
/// Specialisation of DenseMapInfo to allow ClassDefId objects in DenseMaps
|
||||
/// FIXME: Move this to the corresponding cpp file as is done for
|
||||
/// clang-tidy/readability/IdentifierNamingCheck.cpp.
|
||||
/// clang-tidy/readability/IdentifierNamingCheck.cpp.
|
||||
template <>
|
||||
struct DenseMapInfo<
|
||||
clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId> {
|
||||
|
|
|
@ -154,7 +154,7 @@ void MacroParenthesesPPCallbacks::replacementList(const Token &MacroNameTok,
|
|||
|
||||
void MacroParenthesesPPCallbacks::argument(const Token &MacroNameTok,
|
||||
const MacroInfo *MI) {
|
||||
|
||||
|
||||
// Skip variable declaration.
|
||||
bool VarDecl = possibleVarDecl(MI, MI->tokens_begin());
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ public:
|
|||
CheckFactories.registerCheck<SuspiciousSemicolonCheck>(
|
||||
"misc-suspicious-semicolon");
|
||||
CheckFactories.registerCheck<SuspiciousStringCompareCheck>(
|
||||
"misc-suspicious-string-compare");
|
||||
"misc-suspicious-string-compare");
|
||||
CheckFactories.registerCheck<SwappedArgumentsCheck>(
|
||||
"misc-swapped-arguments");
|
||||
CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>(
|
||||
|
|
|
@ -133,7 +133,7 @@ void MoveConstructorInitCheck::handleMoveConstructor(
|
|||
QualType QT = Initializer->getInit()->getType();
|
||||
if (QT.isTriviallyCopyableType(*Result.Context))
|
||||
return;
|
||||
|
||||
|
||||
const auto *RD = QT->getAsCXXRecordDecl();
|
||||
if (RD && RD->isTriviallyCopyable())
|
||||
return;
|
||||
|
|
|
@ -15,7 +15,7 @@ using namespace clang::ast_matchers;
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
namespace misc {
|
||||
|
||||
void SizeofContainerCheck::registerMatchers(MatchFinder *Finder) {
|
||||
Finder->addMatcher(
|
||||
|
|
|
@ -22,7 +22,7 @@ using namespace clang::ast_matchers;
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
namespace misc {
|
||||
|
||||
StaticAssertCheck::StaticAssertCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context) {}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
namespace misc {
|
||||
|
||||
/// Replaces `assert()` with `static_assert()` if the condition is evaluatable
|
||||
/// at compile time.
|
||||
|
|
|
@ -16,7 +16,7 @@ using namespace clang::ast_matchers;
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
namespace misc {
|
||||
|
||||
void StringIntegerAssignmentCheck::registerMatchers(MatchFinder *Finder) {
|
||||
if (!getLangOpts().CPlusPlus)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
namespace misc {
|
||||
|
||||
/// Finds instances where an integer is assigned to a string.
|
||||
///
|
||||
|
|
|
@ -99,7 +99,7 @@ void SuspiciousMissingCommaCheck::check(
|
|||
const auto *ConcatenatedLiteral =
|
||||
Result.Nodes.getNodeAs<StringLiteral>("str");
|
||||
assert(InitializerList && ConcatenatedLiteral);
|
||||
|
||||
|
||||
// Skip small arrays as they often generate false-positive.
|
||||
unsigned int Size = InitializerList->getNumInits();
|
||||
if (Size < SizeThreshold) return;
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace misc {
|
|||
class SuspiciousMissingCommaCheck : public ClangTidyCheck {
|
||||
public:
|
||||
SuspiciousMissingCommaCheck(StringRef Name, ClangTidyContext *Context);
|
||||
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
|
||||
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
|
||||
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
||||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ void SwappedArgumentsCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
<< RHSFrom->getType()
|
||||
<< tooling::fixit::createReplacement(*LHS, *RHS, Ctx)
|
||||
<< tooling::fixit::createReplacement(*RHS, *LHS, Ctx);
|
||||
|
||||
|
||||
// Remember that we emitted a warning for this argument.
|
||||
UsedArgs.insert(RHSCast);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ using namespace clang::ast_matchers;
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
namespace misc {
|
||||
|
||||
ThrowByValueCatchByReferenceCheck::ThrowByValueCatchByReferenceCheck(
|
||||
StringRef Name, ClangTidyContext *Context)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
namespace misc {
|
||||
|
||||
/// Finds unused namespace alias declarations.
|
||||
class UnusedAliasDeclsCheck : public ClangTidyCheck {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
namespace misc {
|
||||
|
||||
/// Finds unused parameters and fixes them, so that `-Wunused-parameter` can be
|
||||
/// turned on.
|
||||
|
|
|
@ -183,7 +183,7 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
|
||||
// If the parameter is trivial to copy, don't move it. Moving a trivivally
|
||||
// copyable type will cause a problem with misc-move-const-arg
|
||||
if (ParamDecl->getType().isTriviallyCopyableType(*Result.Context))
|
||||
if (ParamDecl->getType().isTriviallyCopyableType(*Result.Context))
|
||||
return;
|
||||
|
||||
auto Diag = diag(ParamDecl->getLocStart(), "pass by value and use std::move");
|
||||
|
|
|
@ -157,8 +157,8 @@ void UnnecessaryValueParamCheck::handleMoveFix(const ParmVarDecl &Var,
|
|||
if (CopyArgument.getLocStart().isMacroID())
|
||||
return;
|
||||
const auto &SM = Context.getSourceManager();
|
||||
auto EndLoc = Lexer::getLocForEndOfToken(CopyArgument.getLocation(), 0, SM,
|
||||
Context.getLangOpts());
|
||||
auto EndLoc = Lexer::getLocForEndOfToken(CopyArgument.getLocation(), 0, SM,
|
||||
Context.getLangOpts());
|
||||
Diag << FixItHint::CreateInsertion(CopyArgument.getLocStart(), "std::move(")
|
||||
<< FixItHint::CreateInsertion(EndLoc, ")");
|
||||
if (auto IncludeFixit = Inserter->CreateIncludeInsertion(
|
||||
|
|
|
@ -10,13 +10,13 @@ This can be misleading especially for member function slicing, for example:
|
|||
|
||||
.. code:: c++
|
||||
|
||||
struct B { int a; virtual int f(); };
|
||||
struct D : B { int b; int f() override; };
|
||||
void use(B b) { // Missing reference, intended ?
|
||||
b.f(); // Calls B::f.
|
||||
}
|
||||
D d;
|
||||
use(d); // Slice.
|
||||
struct B { int a; virtual int f(); };
|
||||
struct D : B { int b; int f() override; };
|
||||
void use(B b) { // Missing reference, intended ?
|
||||
b.f(); // Calls B::f.
|
||||
}
|
||||
D d;
|
||||
use(d); // Slice.
|
||||
|
||||
See the relevant CppCoreGuidelines sections for details:
|
||||
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es63-dont-slice
|
||||
|
|
|
@ -20,25 +20,25 @@ Before:
|
|||
|
||||
.. code:: c++
|
||||
|
||||
std::vector<MyClass> v;
|
||||
v.push_back(MyClass(21, 37));
|
||||
std::vector<MyClass> v;
|
||||
v.push_back(MyClass(21, 37));
|
||||
|
||||
std::vector<std::pair<int,int>> w;
|
||||
std::vector<std::pair<int,int>> w;
|
||||
|
||||
w.push_back(std::pair<int,int>(21, 37));
|
||||
w.push_back(std::make_pair(21L, 37L));
|
||||
w.push_back(std::pair<int,int>(21, 37));
|
||||
w.push_back(std::make_pair(21L, 37L));
|
||||
|
||||
After:
|
||||
|
||||
.. code:: c++
|
||||
|
||||
std::vector<MyClass> v;
|
||||
v.emplace_back(21, 37);
|
||||
std::vector<MyClass> v;
|
||||
v.emplace_back(21, 37);
|
||||
|
||||
std::vector<std::pair<int,int>> w;
|
||||
w.emplace_back(21, 37);
|
||||
// This will be fixed to w.push_back(21, 37); in next version
|
||||
w.emplace_back(std::make_pair(21L, 37L);
|
||||
std::vector<std::pair<int,int>> w;
|
||||
w.emplace_back(21, 37);
|
||||
// This will be fixed to w.push_back(21, 37); in next version
|
||||
w.emplace_back(std::make_pair(21L, 37L);
|
||||
|
||||
The other situation is when we pass arguments that will be converted to a type
|
||||
inside a container.
|
||||
|
@ -47,15 +47,15 @@ Before:
|
|||
|
||||
.. code:: c++
|
||||
|
||||
std::vector<boost::optional<std::string> > v;
|
||||
v.push_back("abc");
|
||||
std::vector<boost::optional<std::string> > v;
|
||||
v.push_back("abc");
|
||||
|
||||
After:
|
||||
|
||||
.. code:: c++
|
||||
|
||||
std::vector<boost::optional<std::string> > v;
|
||||
v.emplace_back("abc");
|
||||
std::vector<boost::optional<std::string> > v;
|
||||
v.emplace_back("abc");
|
||||
|
||||
|
||||
In some cases the transformation would be valid, but the code
|
||||
|
@ -63,11 +63,11 @@ wouldn't be exception safe.
|
|||
In this case the calls of ``push_back`` won't be replaced.
|
||||
|
||||
.. code:: c++
|
||||
|
||||
|
||||
std::vector<std::unique_ptr<int>> v;
|
||||
v.push_back(std::unique_ptr<int>(new int(0)));
|
||||
auto *ptr = new int(1);
|
||||
v.push_back(std::unique_ptr<int>(ptr));
|
||||
v.push_back(std::unique_ptr<int>(new int(0)));
|
||||
auto *ptr = new int(1);
|
||||
v.push_back(std::unique_ptr<int>(ptr));
|
||||
|
||||
This is because replacing it with ``emplace_back`` could cause a leak of this
|
||||
pointer if ``emplace_back`` would throw exception before emplacement
|
||||
|
|
Loading…
Reference in New Issue