forked from OSchip/llvm-project
[AST] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 318582
This commit is contained in:
parent
9abeecc07c
commit
821f6983dc
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
//===--- ExprCXX.cpp - (C++) Expression AST Node Implementation -----------===//
|
||||
//===- ExprCXX.cpp - (C++) Expression AST Node Implementation -------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -11,15 +11,33 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/AST/ExprCXX.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/Attr.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclAccessPair.h"
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/DeclCXX.h"
|
||||
#include "clang/AST/DeclTemplate.h"
|
||||
#include "clang/AST/ExprCXX.h"
|
||||
#include "clang/AST/DeclarationName.h"
|
||||
#include "clang/AST/Expr.h"
|
||||
#include "clang/AST/LambdaCapture.h"
|
||||
#include "clang/AST/NestedNameSpecifier.h"
|
||||
#include "clang/AST/TemplateBase.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/TypeLoc.h"
|
||||
#include "clang/Basic/IdentifierTable.h"
|
||||
using namespace clang;
|
||||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/OperatorKinds.h"
|
||||
#include "clang/Basic/SourceLocation.h"
|
||||
#include "clang/Basic/Specifiers.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
using namespace clang;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Child Iterators for iterating over subexpressions/substatements
|
||||
|
@ -85,15 +103,14 @@ CXXNewExpr::CXXNewExpr(const ASTContext &C, bool globalNew,
|
|||
Expr *initializer, QualType ty,
|
||||
TypeSourceInfo *allocatedTypeInfo,
|
||||
SourceRange Range, SourceRange directInitRange)
|
||||
: Expr(CXXNewExprClass, ty, VK_RValue, OK_Ordinary,
|
||||
ty->isDependentType(), ty->isDependentType(),
|
||||
ty->isInstantiationDependentType(),
|
||||
ty->containsUnexpandedParameterPack()),
|
||||
SubExprs(nullptr), OperatorNew(operatorNew), OperatorDelete(operatorDelete),
|
||||
AllocatedTypeInfo(allocatedTypeInfo), TypeIdParens(typeIdParens),
|
||||
Range(Range), DirectInitRange(directInitRange),
|
||||
GlobalNew(globalNew), PassAlignment(PassAlignment),
|
||||
UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) {
|
||||
: Expr(CXXNewExprClass, ty, VK_RValue, OK_Ordinary, ty->isDependentType(),
|
||||
ty->isDependentType(), ty->isInstantiationDependentType(),
|
||||
ty->containsUnexpandedParameterPack()),
|
||||
OperatorNew(operatorNew), OperatorDelete(operatorDelete),
|
||||
AllocatedTypeInfo(allocatedTypeInfo), TypeIdParens(typeIdParens),
|
||||
Range(Range), DirectInitRange(directInitRange), GlobalNew(globalNew),
|
||||
PassAlignment(PassAlignment),
|
||||
UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) {
|
||||
assert((initializer != nullptr || initializationStyle == NoInit) &&
|
||||
"Only NoInit can have no initializer.");
|
||||
StoredInitializationStyle = initializer ? initializationStyle + 1 : 0;
|
||||
|
@ -187,8 +204,7 @@ QualType CXXDeleteExpr::getDestroyedType() const {
|
|||
|
||||
// CXXPseudoDestructorExpr
|
||||
PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info)
|
||||
: Type(Info)
|
||||
{
|
||||
: Type(Info) {
|
||||
Location = Info->getTypeLoc().getLocalSourceRange().getBegin();
|
||||
}
|
||||
|
||||
|
@ -225,7 +241,7 @@ CXXPseudoDestructorExpr::CXXPseudoDestructorExpr(const ASTContext &Context,
|
|||
Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
|
||||
OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc),
|
||||
ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
|
||||
DestroyedType(DestroyedType) { }
|
||||
DestroyedType(DestroyedType) {}
|
||||
|
||||
QualType CXXPseudoDestructorExpr::getDestroyedType() const {
|
||||
if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
|
||||
|
@ -251,8 +267,7 @@ UnresolvedLookupExpr::Create(const ASTContext &C,
|
|||
bool ADL,
|
||||
const TemplateArgumentListInfo *Args,
|
||||
UnresolvedSetIterator Begin,
|
||||
UnresolvedSetIterator End)
|
||||
{
|
||||
UnresolvedSetIterator End) {
|
||||
assert(Args || TemplateKWLoc.isValid());
|
||||
unsigned num_args = Args ? Args->size() : 0;
|
||||
|
||||
|
@ -290,21 +305,20 @@ OverloadExpr::OverloadExpr(StmtClass K, const ASTContext &C,
|
|||
bool KnownDependent,
|
||||
bool KnownInstantiationDependent,
|
||||
bool KnownContainsUnexpandedParameterPack)
|
||||
: Expr(K, C.OverloadTy, VK_LValue, OK_Ordinary, KnownDependent,
|
||||
KnownDependent,
|
||||
(KnownInstantiationDependent ||
|
||||
NameInfo.isInstantiationDependent() ||
|
||||
(QualifierLoc &&
|
||||
QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())),
|
||||
(KnownContainsUnexpandedParameterPack ||
|
||||
NameInfo.containsUnexpandedParameterPack() ||
|
||||
(QualifierLoc &&
|
||||
QualifierLoc.getNestedNameSpecifier()
|
||||
->containsUnexpandedParameterPack()))),
|
||||
NameInfo(NameInfo), QualifierLoc(QualifierLoc),
|
||||
Results(nullptr), NumResults(End - Begin),
|
||||
HasTemplateKWAndArgsInfo(TemplateArgs != nullptr ||
|
||||
TemplateKWLoc.isValid()) {
|
||||
: Expr(K, C.OverloadTy, VK_LValue, OK_Ordinary, KnownDependent,
|
||||
KnownDependent,
|
||||
(KnownInstantiationDependent ||
|
||||
NameInfo.isInstantiationDependent() ||
|
||||
(QualifierLoc &&
|
||||
QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())),
|
||||
(KnownContainsUnexpandedParameterPack ||
|
||||
NameInfo.containsUnexpandedParameterPack() ||
|
||||
(QualifierLoc &&
|
||||
QualifierLoc.getNestedNameSpecifier()
|
||||
->containsUnexpandedParameterPack()))),
|
||||
NameInfo(NameInfo), QualifierLoc(QualifierLoc), NumResults(End - Begin),
|
||||
HasTemplateKWAndArgsInfo(TemplateArgs != nullptr ||
|
||||
TemplateKWLoc.isValid()) {
|
||||
NumResults = End - Begin;
|
||||
if (NumResults) {
|
||||
// Determine whether this expression is type-dependent.
|
||||
|
@ -509,7 +523,6 @@ CXXMethodDecl *CXXMemberCallExpr::getMethodDecl() const {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
CXXRecordDecl *CXXMemberCallExpr::getRecordDecl() const {
|
||||
Expr* ThisArg = getImplicitObjectArgument();
|
||||
if (!ThisArg)
|
||||
|
@ -521,7 +534,6 @@ CXXRecordDecl *CXXMemberCallExpr::getRecordDecl() const {
|
|||
return ThisArg->getType()->getAsCXXRecordDecl();
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Named casts
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -758,16 +770,12 @@ CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(const ASTContext &C,
|
|||
bool ListInitialization,
|
||||
bool StdInitListInitialization,
|
||||
bool ZeroInitialization)
|
||||
: CXXConstructExpr(C, CXXTemporaryObjectExprClass, Type,
|
||||
TSI->getTypeLoc().getBeginLoc(),
|
||||
Cons, false, Args,
|
||||
HadMultipleCandidates,
|
||||
ListInitialization,
|
||||
StdInitListInitialization,
|
||||
ZeroInitialization,
|
||||
CXXConstructExpr::CK_Complete, ParenOrBraceRange),
|
||||
Type(TSI) {
|
||||
}
|
||||
: CXXConstructExpr(C, CXXTemporaryObjectExprClass, Type,
|
||||
TSI->getTypeLoc().getBeginLoc(), Cons, false, Args,
|
||||
HadMultipleCandidates, ListInitialization,
|
||||
StdInitListInitialization, ZeroInitialization,
|
||||
CXXConstructExpr::CK_Complete, ParenOrBraceRange),
|
||||
Type(TSI) {}
|
||||
|
||||
SourceLocation CXXTemporaryObjectExpr::getLocStart() const {
|
||||
return Type->getTypeLoc().getBeginLoc();
|
||||
|
@ -810,18 +818,16 @@ CXXConstructExpr::CXXConstructExpr(const ASTContext &C, StmtClass SC,
|
|||
bool ZeroInitialization,
|
||||
ConstructionKind ConstructKind,
|
||||
SourceRange ParenOrBraceRange)
|
||||
: Expr(SC, T, VK_RValue, OK_Ordinary,
|
||||
T->isDependentType(), T->isDependentType(),
|
||||
T->isInstantiationDependentType(),
|
||||
T->containsUnexpandedParameterPack()),
|
||||
Constructor(Ctor), Loc(Loc), ParenOrBraceRange(ParenOrBraceRange),
|
||||
NumArgs(Args.size()),
|
||||
Elidable(Elidable), HadMultipleCandidates(HadMultipleCandidates),
|
||||
ListInitialization(ListInitialization),
|
||||
StdInitListInitialization(StdInitListInitialization),
|
||||
ZeroInitialization(ZeroInitialization),
|
||||
ConstructKind(ConstructKind), Args(nullptr)
|
||||
{
|
||||
: Expr(SC, T, VK_RValue, OK_Ordinary,
|
||||
T->isDependentType(), T->isDependentType(),
|
||||
T->isInstantiationDependentType(),
|
||||
T->containsUnexpandedParameterPack()),
|
||||
Constructor(Ctor), Loc(Loc), ParenOrBraceRange(ParenOrBraceRange),
|
||||
NumArgs(Args.size()), Elidable(Elidable),
|
||||
HadMultipleCandidates(HadMultipleCandidates),
|
||||
ListInitialization(ListInitialization),
|
||||
StdInitListInitialization(StdInitListInitialization),
|
||||
ZeroInitialization(ZeroInitialization), ConstructKind(ConstructKind) {
|
||||
if (NumArgs) {
|
||||
this->Args = new (C) Stmt*[Args.size()];
|
||||
|
||||
|
@ -843,8 +849,7 @@ CXXConstructExpr::CXXConstructExpr(const ASTContext &C, StmtClass SC,
|
|||
LambdaCapture::LambdaCapture(SourceLocation Loc, bool Implicit,
|
||||
LambdaCaptureKind Kind, VarDecl *Var,
|
||||
SourceLocation EllipsisLoc)
|
||||
: DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc)
|
||||
{
|
||||
: DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) {
|
||||
unsigned Bits = 0;
|
||||
if (Implicit)
|
||||
Bits |= Capture_Implicit;
|
||||
|
@ -1011,7 +1016,7 @@ CompoundStmt *LambdaExpr::getBody() const {
|
|||
// initialized in ASTStmtReader::VisitLambdaExpr, but for reasons I
|
||||
// don't understand, that doesn't work.
|
||||
if (!getStoredStmts()[NumCaptures])
|
||||
*const_cast<clang::Stmt **>(&getStoredStmts()[NumCaptures]) =
|
||||
*const_cast<Stmt **>(&getStoredStmts()[NumCaptures]) =
|
||||
getCallOperator()->getBody();
|
||||
|
||||
return static_cast<CompoundStmt *>(getStoredStmts()[NumCaptures]);
|
||||
|
@ -1024,12 +1029,12 @@ bool LambdaExpr::isMutable() const {
|
|||
ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
|
||||
bool CleanupsHaveSideEffects,
|
||||
ArrayRef<CleanupObject> objects)
|
||||
: Expr(ExprWithCleanupsClass, subexpr->getType(),
|
||||
subexpr->getValueKind(), subexpr->getObjectKind(),
|
||||
subexpr->isTypeDependent(), subexpr->isValueDependent(),
|
||||
subexpr->isInstantiationDependent(),
|
||||
subexpr->containsUnexpandedParameterPack()),
|
||||
SubExpr(subexpr) {
|
||||
: Expr(ExprWithCleanupsClass, subexpr->getType(),
|
||||
subexpr->getValueKind(), subexpr->getObjectKind(),
|
||||
subexpr->isTypeDependent(), subexpr->isValueDependent(),
|
||||
subexpr->isInstantiationDependent(),
|
||||
subexpr->containsUnexpandedParameterPack()),
|
||||
SubExpr(subexpr) {
|
||||
ExprWithCleanupsBits.CleanupsHaveSideEffects = CleanupsHaveSideEffects;
|
||||
ExprWithCleanupsBits.NumObjects = objects.size();
|
||||
for (unsigned i = 0, e = objects.size(); i != e; ++i)
|
||||
|
@ -1046,7 +1051,7 @@ ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, Expr *subexpr,
|
|||
}
|
||||
|
||||
ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects)
|
||||
: Expr(ExprWithCleanupsClass, empty) {
|
||||
: Expr(ExprWithCleanupsClass, empty) {
|
||||
ExprWithCleanupsBits.NumObjects = numObjects;
|
||||
}
|
||||
|
||||
|
@ -1062,20 +1067,18 @@ CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(TypeSourceInfo *Type,
|
|||
SourceLocation LParenLoc,
|
||||
ArrayRef<Expr*> Args,
|
||||
SourceLocation RParenLoc)
|
||||
: Expr(CXXUnresolvedConstructExprClass,
|
||||
Type->getType().getNonReferenceType(),
|
||||
(Type->getType()->isLValueReferenceType() ? VK_LValue
|
||||
:Type->getType()->isRValueReferenceType()? VK_XValue
|
||||
:VK_RValue),
|
||||
OK_Ordinary,
|
||||
Type->getType()->isDependentType() ||
|
||||
Type->getType()->getContainedDeducedType(),
|
||||
true, true,
|
||||
Type->getType()->containsUnexpandedParameterPack()),
|
||||
Type(Type),
|
||||
LParenLoc(LParenLoc),
|
||||
RParenLoc(RParenLoc),
|
||||
NumArgs(Args.size()) {
|
||||
: Expr(CXXUnresolvedConstructExprClass,
|
||||
Type->getType().getNonReferenceType(),
|
||||
(Type->getType()->isLValueReferenceType()
|
||||
? VK_LValue
|
||||
: Type->getType()->isRValueReferenceType() ? VK_XValue
|
||||
: VK_RValue),
|
||||
OK_Ordinary,
|
||||
Type->getType()->isDependentType() ||
|
||||
Type->getType()->getContainedDeducedType(),
|
||||
true, true, Type->getType()->containsUnexpandedParameterPack()),
|
||||
Type(Type), LParenLoc(LParenLoc), RParenLoc(RParenLoc),
|
||||
NumArgs(Args.size()) {
|
||||
Expr **StoredArgs = getTrailingObjects<Expr *>();
|
||||
for (unsigned I = 0; I != Args.size(); ++I) {
|
||||
if (Args[I]->containsUnexpandedParameterPack())
|
||||
|
@ -1175,7 +1178,7 @@ CXXDependentScopeMemberExpr::CreateEmpty(const ASTContext &C,
|
|||
void *Mem = C.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
|
||||
CXXDependentScopeMemberExpr *E
|
||||
= new (Mem) CXXDependentScopeMemberExpr(C, nullptr, QualType(),
|
||||
0, SourceLocation(),
|
||||
false, SourceLocation(),
|
||||
NestedNameSpecifierLoc(),
|
||||
SourceLocation(), nullptr,
|
||||
DeclarationNameInfo(), nullptr);
|
||||
|
@ -1218,19 +1221,18 @@ UnresolvedMemberExpr::UnresolvedMemberExpr(const ASTContext &C,
|
|||
const TemplateArgumentListInfo *TemplateArgs,
|
||||
UnresolvedSetIterator Begin,
|
||||
UnresolvedSetIterator End)
|
||||
: OverloadExpr(UnresolvedMemberExprClass, C, QualifierLoc, TemplateKWLoc,
|
||||
MemberNameInfo, TemplateArgs, Begin, End,
|
||||
// Dependent
|
||||
((Base && Base->isTypeDependent()) ||
|
||||
BaseType->isDependentType()),
|
||||
((Base && Base->isInstantiationDependent()) ||
|
||||
BaseType->isInstantiationDependentType()),
|
||||
// Contains unexpanded parameter pack
|
||||
((Base && Base->containsUnexpandedParameterPack()) ||
|
||||
BaseType->containsUnexpandedParameterPack())),
|
||||
IsArrow(IsArrow), HasUnresolvedUsing(HasUnresolvedUsing),
|
||||
Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) {
|
||||
|
||||
: OverloadExpr(
|
||||
UnresolvedMemberExprClass, C, QualifierLoc, TemplateKWLoc,
|
||||
MemberNameInfo, TemplateArgs, Begin, End,
|
||||
// Dependent
|
||||
((Base && Base->isTypeDependent()) || BaseType->isDependentType()),
|
||||
((Base && Base->isInstantiationDependent()) ||
|
||||
BaseType->isInstantiationDependentType()),
|
||||
// Contains unexpanded parameter pack
|
||||
((Base && Base->containsUnexpandedParameterPack()) ||
|
||||
BaseType->containsUnexpandedParameterPack())),
|
||||
IsArrow(IsArrow), HasUnresolvedUsing(HasUnresolvedUsing), Base(Base),
|
||||
BaseType(BaseType), OperatorLoc(OperatorLoc) {
|
||||
// Check whether all of the members are non-static member functions,
|
||||
// and if so, mark give this bound-member type instead of overload type.
|
||||
if (hasOnlyNonStaticMemberFunctions(Begin, End))
|
||||
|
@ -1331,10 +1333,10 @@ SubstNonTypeTemplateParmPackExpr(QualType T,
|
|||
NonTypeTemplateParmDecl *Param,
|
||||
SourceLocation NameLoc,
|
||||
const TemplateArgument &ArgPack)
|
||||
: Expr(SubstNonTypeTemplateParmPackExprClass, T, VK_RValue, OK_Ordinary,
|
||||
true, true, true, true),
|
||||
Param(Param), Arguments(ArgPack.pack_begin()),
|
||||
NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) { }
|
||||
: Expr(SubstNonTypeTemplateParmPackExprClass, T, VK_RValue, OK_Ordinary,
|
||||
true, true, true, true),
|
||||
Param(Param), Arguments(ArgPack.pack_begin()),
|
||||
NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) {}
|
||||
|
||||
TemplateArgument SubstNonTypeTemplateParmPackExpr::getArgumentPack() const {
|
||||
return TemplateArgument(llvm::makeArrayRef(Arguments, NumArguments));
|
||||
|
@ -1390,13 +1392,12 @@ TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
|
|||
ArrayRef<TypeSourceInfo *> Args,
|
||||
SourceLocation RParenLoc,
|
||||
bool Value)
|
||||
: Expr(TypeTraitExprClass, T, VK_RValue, OK_Ordinary,
|
||||
/*TypeDependent=*/false,
|
||||
/*ValueDependent=*/false,
|
||||
/*InstantiationDependent=*/false,
|
||||
/*ContainsUnexpandedParameterPack=*/false),
|
||||
Loc(Loc), RParenLoc(RParenLoc)
|
||||
{
|
||||
: Expr(TypeTraitExprClass, T, VK_RValue, OK_Ordinary,
|
||||
/*TypeDependent=*/false,
|
||||
/*ValueDependent=*/false,
|
||||
/*InstantiationDependent=*/false,
|
||||
/*ContainsUnexpandedParameterPack=*/false),
|
||||
Loc(Loc), RParenLoc(RParenLoc) {
|
||||
TypeTraitExprBits.Kind = Kind;
|
||||
TypeTraitExprBits.Value = Value;
|
||||
TypeTraitExprBits.NumArgs = Args.size();
|
||||
|
@ -1431,4 +1432,4 @@ TypeTraitExpr *TypeTraitExpr::CreateDeserialized(const ASTContext &C,
|
|||
return new (Mem) TypeTraitExpr(EmptyShell());
|
||||
}
|
||||
|
||||
void ArrayTypeTraitExpr::anchor() { }
|
||||
void ArrayTypeTraitExpr::anchor() {}
|
||||
|
|
Loading…
Reference in New Issue