#include "ProTypeMemberInitCheck.h"
#include "../utils/LexerUtils.h"
#include "../utils/Matchers.h"
#include "../utils/TypeTraits.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/SmallPtrSet.h"
usingnamespaceclang::ast_matchers;
usingnamespaceclang::tidy::matchers;
SmallPtrSet;
SmallPtrSetImpl;
namespace clang::tidy::cppcoreguidelines {
namespace {
AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) { … }
template <typename T, typename Func>
void forEachField(const RecordDecl &Record, const T &Fields, const Func &Fn) { … }
template <typename T, typename Func>
void forEachFieldWithFilter(const RecordDecl &Record, const T &Fields,
bool &AnyMemberHasInitPerUnion, const Func &Fn) { … }
void removeFieldInitialized(const FieldDecl *M,
SmallPtrSetImpl<const FieldDecl *> &FieldDecls) { … }
void removeFieldsInitializedInBody(
const Stmt &Stmt, ASTContext &Context,
SmallPtrSetImpl<const FieldDecl *> &FieldDecls) { … }
StringRef getName(const FieldDecl *Field) { … }
StringRef getName(const RecordDecl *Record) { … }
template <typename R, typename T>
std::string
toCommaSeparatedString(const R &OrderedDecls,
const SmallPtrSetImpl<const T *> &DeclsToInit) { … }
SourceLocation getLocationForEndOfToken(const ASTContext &Context,
SourceLocation Location) { … }
enum class InitializerPlacement { … };
struct InitializerInsertion { … };
const RecordDecl *getCanonicalRecordDecl(const QualType &Type) { … }
template <typename R, typename T>
SmallVector<InitializerInsertion, 16>
computeInsertions(const CXXConstructorDecl::init_const_range &Inits,
const R &OrderedDecls,
const SmallPtrSetImpl<const T *> &DeclsToInit) { … }
void getInitializationsInOrder(const CXXRecordDecl &ClassDecl,
SmallVectorImpl<const NamedDecl *> &Decls) { … }
template <typename T>
void fixInitializerList(const ASTContext &Context, DiagnosticBuilder &Diag,
const CXXConstructorDecl *Ctor,
const SmallPtrSetImpl<const T *> &DeclsToInit) { … }
}
ProTypeMemberInitCheck::ProTypeMemberInitCheck(StringRef Name,
ClangTidyContext *Context)
: … { … }
void ProTypeMemberInitCheck::registerMatchers(MatchFinder *Finder) { … }
void ProTypeMemberInitCheck::check(const MatchFinder::MatchResult &Result) { … }
void ProTypeMemberInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { … }
static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T) { … }
static bool isEmpty(ASTContext &Context, const QualType &Type) { … }
static const char *getInitializer(QualType QT, bool UseAssignment) { … }
void ProTypeMemberInitCheck::checkMissingMemberInitializer(
ASTContext &Context, const CXXRecordDecl &ClassDecl,
const CXXConstructorDecl *Ctor) { … }
void ProTypeMemberInitCheck::checkMissingBaseClassInitializer(
const ASTContext &Context, const CXXRecordDecl &ClassDecl,
const CXXConstructorDecl *Ctor) { … }
void ProTypeMemberInitCheck::checkUninitializedTrivialType(
const ASTContext &Context, const VarDecl *Var) { … }
}