Benjamin Kramer 1188792480 [clang-tidy] Add a checker for code that looks like a delegate constructors but doesn't delegate.
Summary:
class Foo {
  Foo() {
    Foo(42); // oops
  }
  Foo(int);
};

This is valid code but it does nothing and we can't emit a warning in clang
because there might be side effects. The checker emits a warning for this
pattern and also for base class initializers written in this style.

There is some overlap with the unused-rtti checker but they follow different
goals and fire in different places most of the time.

Reviewers: alexfh, djasper

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4667

llvm-svn: 214397
2014-07-31 09:58:52 +00:00

61 lines
2.1 KiB
C++

//===--- MiscTidyModule.cpp - clang-tidy ----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "ArgumentCommentCheck.h"
#include "BoolPointerImplicitConversion.h"
#include "RedundantSmartptrGet.h"
#include "SwappedArgumentsCheck.h"
#include "UndelegatedConstructor.h"
#include "UnusedRAII.h"
#include "UseOverride.h"
namespace clang {
namespace tidy {
class MiscModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.addCheckFactory(
"misc-argument-comment",
new ClangTidyCheckFactory<ArgumentCommentCheck>());
CheckFactories.addCheckFactory(
"misc-bool-pointer-implicit-conversion",
new ClangTidyCheckFactory<BoolPointerImplicitConversion>());
CheckFactories.addCheckFactory(
"misc-redundant-smartptr-get",
new ClangTidyCheckFactory<RedundantSmartptrGet>());
CheckFactories.addCheckFactory(
"misc-swapped-arguments",
new ClangTidyCheckFactory<SwappedArgumentsCheck>());
CheckFactories.addCheckFactory(
"misc-undelegated-constructor",
new ClangTidyCheckFactory<UndelegatedConstructorCheck>());
CheckFactories.addCheckFactory(
"misc-unused-raii",
new ClangTidyCheckFactory<UnusedRAIICheck>());
CheckFactories.addCheckFactory(
"misc-use-override",
new ClangTidyCheckFactory<UseOverride>());
}
};
// Register the MiscTidyModule using this statically initialized variable.
static ClangTidyModuleRegistry::Add<MiscModule>
X("misc-module", "Adds miscellaneous lint checks.");
// This anchor is used to force the linker to link in the generated object file
// and thus register the MiscModule.
volatile int MiscModuleAnchorSource = 0;
} // namespace tidy
} // namespace clang