summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclCXX.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2014-05-12 05:36:57 +0000
committerCraig Topper <craig.topper@gmail.com>2014-05-12 05:36:57 +0000
commit36250ad632a5a2611919413c1a00a1b9f338fc85 (patch)
tree368e401ec64b5cfa5dfcc922ab3134ab6ecc035a /clang/lib/AST/DeclCXX.cpp
parent4ca40eda368a99b8c3934653a9b7abf92d8afc87 (diff)
downloadbcm5719-llvm-36250ad632a5a2611919413c1a00a1b9f338fc85.tar.gz
bcm5719-llvm-36250ad632a5a2611919413c1a00a1b9f338fc85.zip
[C++11] Use 'nullptr'. AST edition.
llvm-svn: 208517
Diffstat (limited to 'clang/lib/AST/DeclCXX.cpp')
-rw-r--r--clang/lib/AST/DeclCXX.cpp121
1 files changed, 65 insertions, 56 deletions
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 8d183b2534a..4cd35fc462b 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -86,7 +86,7 @@ CXXRecordDecl::CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
SourceLocation StartLoc, SourceLocation IdLoc,
IdentifierInfo *Id, CXXRecordDecl *PrevDecl)
: RecordDecl(K, TK, DC, StartLoc, IdLoc, Id, PrevDecl),
- DefinitionData(PrevDecl ? PrevDecl->DefinitionData : 0),
+ DefinitionData(PrevDecl ? PrevDecl->DefinitionData : nullptr),
TemplateOrInstantiation() { }
CXXRecordDecl *CXXRecordDecl::Create(const ASTContext &C, TagKind TK,
@@ -109,7 +109,8 @@ CXXRecordDecl *CXXRecordDecl::CreateLambda(const ASTContext &C, DeclContext *DC,
bool Dependent, bool IsGeneric,
LambdaCaptureDefault CaptureDefault) {
CXXRecordDecl *R =
- new (C, DC) CXXRecordDecl(CXXRecord, TTK_Class, DC, Loc, Loc, 0, 0);
+ new (C, DC) CXXRecordDecl(CXXRecord, TTK_Class, DC, Loc, Loc, nullptr,
+ nullptr);
R->IsBeingDefined = true;
R->DefinitionData = new (C) struct LambdaDefinitionData(R, Info,
Dependent,
@@ -117,14 +118,15 @@ CXXRecordDecl *CXXRecordDecl::CreateLambda(const ASTContext &C, DeclContext *DC,
CaptureDefault);
R->MayHaveOutOfDateDef = false;
R->setImplicit(true);
- C.getTypeDeclType(R, /*PrevDecl=*/0);
+ C.getTypeDeclType(R, /*PrevDecl=*/nullptr);
return R;
}
CXXRecordDecl *
CXXRecordDecl::CreateDeserialized(const ASTContext &C, unsigned ID) {
CXXRecordDecl *R = new (C, ID) CXXRecordDecl(
- CXXRecord, TTK_Struct, 0, SourceLocation(), SourceLocation(), 0, 0);
+ CXXRecord, TTK_Struct, nullptr, SourceLocation(), SourceLocation(),
+ nullptr, nullptr);
R->MayHaveOutOfDateDef = false;
return R;
}
@@ -386,7 +388,7 @@ bool CXXRecordDecl::hasAnyDependentBases() const {
if (!isDependentContext())
return false;
- return !forallBases(SawBase, 0);
+ return !forallBases(SawBase, nullptr);
}
bool CXXRecordDecl::isTriviallyCopyable() const {
@@ -972,7 +974,7 @@ bool CXXRecordDecl::isGenericLambda() const {
}
CXXMethodDecl* CXXRecordDecl::getLambdaCallOperator() const {
- if (!isLambda()) return 0;
+ if (!isLambda()) return nullptr;
DeclarationName Name =
getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
DeclContext::lookup_const_result Calls = lookup(Name);
@@ -989,11 +991,11 @@ CXXMethodDecl* CXXRecordDecl::getLambdaCallOperator() const {
}
CXXMethodDecl* CXXRecordDecl::getLambdaStaticInvoker() const {
- if (!isLambda()) return 0;
+ if (!isLambda()) return nullptr;
DeclarationName Name =
&getASTContext().Idents.get(getLambdaStaticInvokerName());
DeclContext::lookup_const_result Invoker = lookup(Name);
- if (Invoker.empty()) return 0;
+ if (Invoker.empty()) return nullptr;
assert(Invoker.size() == 1 && "More than one static invoker operator!");
NamedDecl *InvokerFun = Invoker.front();
if (FunctionTemplateDecl *InvokerTemplate =
@@ -1007,7 +1009,7 @@ void CXXRecordDecl::getCaptureFields(
llvm::DenseMap<const VarDecl *, FieldDecl *> &Captures,
FieldDecl *&ThisCapture) const {
Captures.clear();
- ThisCapture = 0;
+ ThisCapture = nullptr;
LambdaDefinitionData &Lambda = getLambdaData();
RecordDecl::field_iterator Field = field_begin();
@@ -1023,11 +1025,11 @@ void CXXRecordDecl::getCaptureFields(
TemplateParameterList *
CXXRecordDecl::getGenericLambdaTemplateParameterList() const {
- if (!isLambda()) return 0;
+ if (!isLambda()) return nullptr;
CXXMethodDecl *CallOp = getLambdaCallOperator();
if (FunctionTemplateDecl *Tmpl = CallOp->getDescribedFunctionTemplate())
return Tmpl->getTemplateParameters();
- return 0;
+ return nullptr;
}
static CanQualType GetConversionType(ASTContext &Context, NamedDecl *Conv) {
@@ -1204,8 +1206,8 @@ void CXXRecordDecl::removeConversion(const NamedDecl *ConvDecl) {
CXXRecordDecl *CXXRecordDecl::getInstantiatedFromMemberClass() const {
if (MemberSpecializationInfo *MSInfo = getMemberSpecializationInfo())
return cast<CXXRecordDecl>(MSInfo->getInstantiatedFrom());
-
- return 0;
+
+ return nullptr;
}
void
@@ -1255,14 +1257,14 @@ CXXDestructorDecl *CXXRecordDecl::getDestructor() const {
DeclContext::lookup_const_result R = lookup(Name);
if (R.empty())
- return 0;
+ return nullptr;
CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(R.front());
return Dtor;
}
void CXXRecordDecl::completeDefinition() {
- completeDefinition(0);
+ completeDefinition(nullptr);
}
void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) {
@@ -1374,7 +1376,7 @@ CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD,
if (MayBeBase && recursivelyOverrides(this, MD))
return MD;
}
- return NULL;
+ return nullptr;
}
lookup_const_result Candidates = RD->lookup(getDeclName());
@@ -1398,7 +1400,7 @@ CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD,
return T;
}
- return NULL;
+ return nullptr;
}
CXXMethodDecl *
@@ -1413,8 +1415,8 @@ CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
}
CXXMethodDecl *CXXMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) CXXMethodDecl(CXXMethod, 0, SourceLocation(),
- DeclarationNameInfo(), QualType(), 0,
+ return new (C, ID) CXXMethodDecl(CXXMethod, nullptr, SourceLocation(),
+ DeclarationNameInfo(), QualType(), nullptr,
SC_None, false, false, SourceLocation());
}
@@ -1512,12 +1514,12 @@ void CXXMethodDecl::addOverriddenMethod(const CXXMethodDecl *MD) {
}
CXXMethodDecl::method_iterator CXXMethodDecl::begin_overridden_methods() const {
- if (isa<CXXConstructorDecl>(this)) return 0;
+ if (isa<CXXConstructorDecl>(this)) return nullptr;
return getASTContext().overridden_methods_begin(this);
}
CXXMethodDecl::method_iterator CXXMethodDecl::end_overridden_methods() const {
- if (isa<CXXConstructorDecl>(this)) return 0;
+ if (isa<CXXConstructorDecl>(this)) return nullptr;
return getASTContext().overridden_methods_end(this);
}
@@ -1647,7 +1649,7 @@ const Type *CXXCtorInitializer::getBaseClass() const {
if (isBaseInitializer())
return Initializee.get<TypeSourceInfo*>()->getType().getTypePtr();
else
- return 0;
+ return nullptr;
}
SourceLocation CXXCtorInitializer::getSourceLocation() const {
@@ -1678,9 +1680,9 @@ void CXXConstructorDecl::anchor() { }
CXXConstructorDecl *
CXXConstructorDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) CXXConstructorDecl(0, SourceLocation(),
+ return new (C, ID) CXXConstructorDecl(nullptr, SourceLocation(),
DeclarationNameInfo(), QualType(),
- 0, false, false, false, false);
+ nullptr, false, false, false, false);
}
CXXConstructorDecl *
@@ -1703,8 +1705,8 @@ CXXConstructorDecl *CXXConstructorDecl::getTargetConstructor() const {
Expr *E = (*init_begin())->getInit()->IgnoreImplicit();
if (CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(E))
return Construct->getConstructor();
-
- return 0;
+
+ return nullptr;
}
bool CXXConstructorDecl::isDefaultConstructor() const {
@@ -1740,8 +1742,8 @@ bool CXXConstructorDecl::isCopyOrMoveConstructor(unsigned &TypeQuals) const {
// all other parameters have default arguments.
if ((getNumParams() < 1) ||
(getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) ||
- (getPrimaryTemplate() != 0) ||
- (getDescribedFunctionTemplate() != 0))
+ (getPrimaryTemplate() != nullptr) ||
+ (getDescribedFunctionTemplate() != nullptr))
return false;
const ParmVarDecl *Param = getParamDecl(0);
@@ -1789,8 +1791,8 @@ bool CXXConstructorDecl::isConvertingConstructor(bool AllowExplicit) const {
bool CXXConstructorDecl::isSpecializationCopyingObject() const {
if ((getNumParams() < 1) ||
(getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) ||
- (getPrimaryTemplate() == 0) ||
- (getDescribedFunctionTemplate() != 0))
+ (getPrimaryTemplate() == nullptr) ||
+ (getDescribedFunctionTemplate() != nullptr))
return false;
const ParmVarDecl *Param = getParamDecl(0);
@@ -1811,7 +1813,7 @@ const CXXConstructorDecl *CXXConstructorDecl::getInheritedConstructor() const {
// Hack: we store the inherited constructor in the overridden method table
method_iterator It = getASTContext().overridden_methods_begin(this);
if (It == getASTContext().overridden_methods_end(this))
- return 0;
+ return nullptr;
return cast<CXXConstructorDecl>(*It);
}
@@ -1829,7 +1831,8 @@ void CXXDestructorDecl::anchor() { }
CXXDestructorDecl *
CXXDestructorDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
return new (C, ID) CXXDestructorDecl(
- 0, SourceLocation(), DeclarationNameInfo(), QualType(), 0, false, false);
+ nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr,
+ false, false);
}
CXXDestructorDecl *
@@ -1849,9 +1852,9 @@ void CXXConversionDecl::anchor() { }
CXXConversionDecl *
CXXConversionDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) CXXConversionDecl(0, SourceLocation(),
+ return new (C, ID) CXXConversionDecl(nullptr, SourceLocation(),
DeclarationNameInfo(), QualType(),
- 0, false, false, false,
+ nullptr, false, false, false,
SourceLocation());
}
@@ -1888,8 +1891,8 @@ LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C,
LinkageSpecDecl *LinkageSpecDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
- return new (C, ID) LinkageSpecDecl(0, SourceLocation(), SourceLocation(),
- lang_c, false);
+ return new (C, ID) LinkageSpecDecl(nullptr, SourceLocation(),
+ SourceLocation(), lang_c, false);
}
void UsingDirectiveDecl::anchor() { }
@@ -1909,9 +1912,10 @@ UsingDirectiveDecl *UsingDirectiveDecl::Create(ASTContext &C, DeclContext *DC,
UsingDirectiveDecl *UsingDirectiveDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
- return new (C, ID) UsingDirectiveDecl(0, SourceLocation(), SourceLocation(),
+ return new (C, ID) UsingDirectiveDecl(nullptr, SourceLocation(),
+ SourceLocation(),
NestedNameSpecifierLoc(),
- SourceLocation(), 0, 0);
+ SourceLocation(), nullptr, nullptr);
}
NamespaceDecl *UsingDirectiveDecl::getNominatedNamespace() {
@@ -1926,8 +1930,8 @@ NamespaceDecl::NamespaceDecl(DeclContext *DC, bool Inline,
SourceLocation IdLoc, IdentifierInfo *Id,
NamespaceDecl *PrevDecl)
: NamedDecl(Namespace, DC, IdLoc, Id), DeclContext(Namespace),
- LocStart(StartLoc), RBraceLoc(), AnonOrFirstNamespaceAndInline(0, Inline)
-{
+ LocStart(StartLoc), RBraceLoc(),
+ AnonOrFirstNamespaceAndInline(nullptr, Inline) {
setPreviousDecl(PrevDecl);
if (PrevDecl)
@@ -1942,8 +1946,8 @@ NamespaceDecl *NamespaceDecl::Create(ASTContext &C, DeclContext *DC,
}
NamespaceDecl *NamespaceDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) NamespaceDecl(0, false, SourceLocation(), SourceLocation(),
- 0, 0);
+ return new (C, ID) NamespaceDecl(nullptr, false, SourceLocation(),
+ SourceLocation(), nullptr, nullptr);
}
NamespaceDecl *NamespaceDecl::getNextRedeclarationImpl() {
@@ -1973,16 +1977,18 @@ NamespaceAliasDecl *NamespaceAliasDecl::Create(ASTContext &C, DeclContext *DC,
NamespaceAliasDecl *
NamespaceAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) NamespaceAliasDecl(0, SourceLocation(), SourceLocation(),
- 0, NestedNameSpecifierLoc(),
- SourceLocation(), 0);
+ return new (C, ID) NamespaceAliasDecl(nullptr, SourceLocation(),
+ SourceLocation(), nullptr,
+ NestedNameSpecifierLoc(),
+ SourceLocation(), nullptr);
}
void UsingShadowDecl::anchor() { }
UsingShadowDecl *
UsingShadowDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) UsingShadowDecl(0, SourceLocation(), 0, 0);
+ return new (C, ID) UsingShadowDecl(nullptr, SourceLocation(), nullptr,
+ nullptr);
}
UsingDecl *UsingShadowDecl::getUsingDecl() const {
@@ -2034,8 +2040,9 @@ UsingDecl *UsingDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation UL,
}
UsingDecl *UsingDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) UsingDecl(0, SourceLocation(), NestedNameSpecifierLoc(),
- DeclarationNameInfo(), false);
+ return new (C, ID) UsingDecl(nullptr, SourceLocation(),
+ NestedNameSpecifierLoc(), DeclarationNameInfo(),
+ false);
}
SourceRange UsingDecl::getSourceRange() const {
@@ -2057,9 +2064,10 @@ UnresolvedUsingValueDecl::Create(ASTContext &C, DeclContext *DC,
UnresolvedUsingValueDecl *
UnresolvedUsingValueDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
- return new (C, ID) UnresolvedUsingValueDecl(0, QualType(), SourceLocation(),
+ return new (C, ID) UnresolvedUsingValueDecl(nullptr, QualType(),
+ SourceLocation(),
NestedNameSpecifierLoc(),
- DeclarationNameInfo());
+ DeclarationNameInfo());
}
SourceRange UnresolvedUsingValueDecl::getSourceRange() const {
@@ -2085,8 +2093,8 @@ UnresolvedUsingTypenameDecl::Create(ASTContext &C, DeclContext *DC,
UnresolvedUsingTypenameDecl *
UnresolvedUsingTypenameDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
return new (C, ID) UnresolvedUsingTypenameDecl(
- 0, SourceLocation(), SourceLocation(), NestedNameSpecifierLoc(),
- SourceLocation(), 0);
+ nullptr, SourceLocation(), SourceLocation(), NestedNameSpecifierLoc(),
+ SourceLocation(), nullptr);
}
void StaticAssertDecl::anchor() { }
@@ -2103,8 +2111,8 @@ StaticAssertDecl *StaticAssertDecl::Create(ASTContext &C, DeclContext *DC,
StaticAssertDecl *StaticAssertDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
- return new (C, ID) StaticAssertDecl(0, SourceLocation(), 0, 0,
- SourceLocation(), false);
+ return new (C, ID) StaticAssertDecl(nullptr, SourceLocation(), nullptr,
+ nullptr, SourceLocation(), false);
}
MSPropertyDecl *MSPropertyDecl::Create(ASTContext &C, DeclContext *DC,
@@ -2118,8 +2126,9 @@ MSPropertyDecl *MSPropertyDecl::Create(ASTContext &C, DeclContext *DC,
MSPropertyDecl *MSPropertyDecl::CreateDeserialized(ASTContext &C,
unsigned ID) {
- return new (C, ID) MSPropertyDecl(0, SourceLocation(), DeclarationName(),
- QualType(), 0, SourceLocation(), 0, 0);
+ return new (C, ID) MSPropertyDecl(nullptr, SourceLocation(),
+ DeclarationName(), QualType(), nullptr,
+ SourceLocation(), nullptr, nullptr);
}
static const char *getAccessName(AccessSpecifier AS) {
OpenPOWER on IntegriCloud