summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseDeclCXX.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2014-05-21 06:02:52 +0000
committerCraig Topper <craig.topper@gmail.com>2014-05-21 06:02:52 +0000
commit161e4db52f657eac37d89e655c0772f98e97d989 (patch)
tree7e200e2d8296209044601808c2308c8ddb67bdbb /clang/lib/Parse/ParseDeclCXX.cpp
parent85a0321b150e09f06f5ae85ce72c1e2e4793f2d1 (diff)
downloadbcm5719-llvm-161e4db52f657eac37d89e655c0772f98e97d989.tar.gz
bcm5719-llvm-161e4db52f657eac37d89e655c0772f98e97d989.zip
[C++11] Use 'nullptr'. Parser edition.
llvm-svn: 209275
Diffstat (limited to 'clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r--clang/lib/Parse/ParseDeclCXX.cpp122
1 files changed, 63 insertions, 59 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 7ef04730ac9..ddecd759b2f 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -64,11 +64,11 @@ Decl *Parser::ParseNamespace(unsigned Context,
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteNamespaceDecl(getCurScope());
cutOffParsing();
- return 0;
+ return nullptr;
}
SourceLocation IdentLoc;
- IdentifierInfo *Ident = 0;
+ IdentifierInfo *Ident = nullptr;
std::vector<SourceLocation> ExtraIdentLoc;
std::vector<IdentifierInfo*> ExtraIdent;
std::vector<SourceLocation> ExtraNamespaceLoc;
@@ -93,11 +93,11 @@ Decl *Parser::ParseNamespace(unsigned Context,
}
if (Tok.is(tok::equal)) {
- if (Ident == 0) {
+ if (!Ident) {
Diag(Tok, diag::err_expected) << tok::identifier;
// Skip to end of the definition and eat the ';'.
SkipUntil(tok::semi);
- return 0;
+ return nullptr;
}
if (!attrs.empty())
Diag(attrTok, diag::err_unexpected_namespace_attributes_alias);
@@ -120,7 +120,7 @@ Decl *Parser::ParseNamespace(unsigned Context,
else
Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
- return 0;
+ return nullptr;
}
if (getCurScope()->isClassScope() || getCurScope()->isTemplateParamScope() ||
@@ -132,7 +132,7 @@ Decl *Parser::ParseNamespace(unsigned Context,
}
Diag(T.getOpenLocation(), diag::err_namespace_nonnamespace_scope);
SkipUntil(tok::r_brace);
- return 0;
+ return nullptr;
}
if (!ExtraIdent.empty()) {
@@ -246,7 +246,7 @@ Decl *Parser::ParseNamespaceAlias(SourceLocation NamespaceLoc,
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteNamespaceAliasDecl(getCurScope());
cutOffParsing();
- return 0;
+ return nullptr;
}
CXXScopeSpec SS;
@@ -257,7 +257,7 @@ Decl *Parser::ParseNamespaceAlias(SourceLocation NamespaceLoc,
Diag(Tok, diag::err_expected_namespace_name);
// Skip to end of the definition and eat the ';'.
SkipUntil(tok::semi);
- return 0;
+ return nullptr;
}
// Parse identifier.
@@ -287,7 +287,7 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, unsigned Context) {
ParseScope LinkageScope(this, Scope::DeclScope);
Decl *LinkageSpec =
Lang.isInvalid()
- ? 0
+ ? nullptr
: Actions.ActOnStartLinkageSpecification(
getCurScope(), DS.getSourceRange().getBegin(), Lang.take(),
Tok.is(tok::l_brace) ? Tok.getLocation() : SourceLocation());
@@ -306,7 +306,7 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, unsigned Context) {
ParseExternalDeclaration(attrs, &DS);
return LinkageSpec ? Actions.ActOnFinishLinkageSpecification(
getCurScope(), LinkageSpec, SourceLocation())
- : 0;
+ : nullptr;
}
DS.abort();
@@ -356,7 +356,7 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS, unsigned Context) {
T.consumeClose();
return LinkageSpec ? Actions.ActOnFinishLinkageSpecification(
getCurScope(), LinkageSpec, T.getCloseLocation())
- : 0;
+ : nullptr;
}
/// ParseUsingDirectiveOrDeclaration - Parse C++ using using-declaration or
@@ -375,7 +375,7 @@ Decl *Parser::ParseUsingDirectiveOrDeclaration(unsigned Context,
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteUsing(getCurScope());
cutOffParsing();
- return 0;
+ return nullptr;
}
// 'using namespace' means this is a using-directive.
@@ -421,14 +421,14 @@ Decl *Parser::ParseUsingDirective(unsigned Context,
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteUsingDirective(getCurScope());
cutOffParsing();
- return 0;
+ return nullptr;
}
CXXScopeSpec SS;
// Parse (optional) nested-name-specifier.
ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false);
- IdentifierInfo *NamespcName = 0;
+ IdentifierInfo *NamespcName = nullptr;
SourceLocation IdentLoc = SourceLocation();
// Parse namespace-name.
@@ -437,7 +437,7 @@ Decl *Parser::ParseUsingDirective(unsigned Context,
// If there was invalid namespace name, skip to end of decl, and eat ';'.
SkipUntil(tok::semi);
// FIXME: Are there cases, when we would like to call ActOnUsingDirective?
- return 0;
+ return nullptr;
}
// Parse identifier.
@@ -494,15 +494,16 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
HasTypenameKeyword = true;
// Parse nested-name-specifier.
- IdentifierInfo *LastII = 0;
+ IdentifierInfo *LastII = nullptr;
ParseOptionalCXXScopeSpecifier(SS, ParsedType(), /*EnteringContext=*/false,
- /*MayBePseudoDtor=*/0, /*IsTypename=*/false,
+ /*MayBePseudoDtor=*/nullptr,
+ /*IsTypename=*/false,
/*LastII=*/&LastII);
// Check nested-name specifier.
if (SS.isInvalid()) {
SkipUntil(tok::semi);
- return 0;
+ return nullptr;
}
SourceLocation TemplateKWLoc;
@@ -531,7 +532,7 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
/*AllowConstructorName=*/ true, ParsedType(),
TemplateKWLoc, Name)) {
SkipUntil(tok::semi);
- return 0;
+ return nullptr;
}
ParsedAttributesWithRange Attrs(AttrFactory);
@@ -578,7 +579,7 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
Diag(Range.getBegin(), diag::err_alias_declaration_specialization)
<< SpecKind << Range;
SkipUntil(tok::semi);
- return 0;
+ return nullptr;
}
// Name must be an identifier.
@@ -586,7 +587,7 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
Diag(Name.StartLocation, diag::err_alias_declaration_not_identifier);
// No removal fixit: can't recover from this.
SkipUntil(tok::semi);
- return 0;
+ return nullptr;
} else if (HasTypenameKeyword)
Diag(TypenameLoc, diag::err_alias_declaration_not_identifier)
<< FixItHint::CreateRemoval(SourceRange(TypenameLoc,
@@ -595,7 +596,7 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
Diag(SS.getBeginLoc(), diag::err_alias_declaration_not_identifier)
<< FixItHint::CreateRemoval(SS.getRange());
- TypeAlias = ParseTypeName(0, TemplateInfo.Kind ?
+ TypeAlias = ParseTypeName(nullptr, TemplateInfo.Kind ?
Declarator::AliasTemplateContext :
Declarator::AliasDeclContext, AS, OwnedType,
&Attrs);
@@ -628,7 +629,7 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
// Unfortunately, we have to bail out instead of recovering by
// ignoring the parameters, just in case the nested name specifier
// depends on the parameters.
- return 0;
+ return nullptr;
}
// "typename" keyword is allowed for identifiers only,
@@ -643,7 +644,7 @@ Decl *Parser::ParseUsingDeclaration(unsigned Context,
if (IsAliasDecl) {
TemplateParameterLists *TemplateParams = TemplateInfo.TemplateParams;
MultiTemplateParamsArg TemplateParamsArg(
- TemplateParams ? TemplateParams->data() : 0,
+ TemplateParams ? TemplateParams->data() : nullptr,
TemplateParams ? TemplateParams->size() : 0);
return Actions.ActOnAliasDeclaration(getCurScope(), AS, TemplateParamsArg,
UsingLoc, Name, Attrs.getList(),
@@ -679,31 +680,31 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){
if (T.consumeOpen()) {
Diag(Tok, diag::err_expected) << tok::l_paren;
SkipMalformedDecl();
- return 0;
+ return nullptr;
}
ExprResult AssertExpr(ParseConstantExpression());
if (AssertExpr.isInvalid()) {
SkipMalformedDecl();
- return 0;
+ return nullptr;
}
if (ExpectAndConsume(tok::comma)) {
SkipUntil(tok::semi);
- return 0;
+ return nullptr;
}
if (!isTokenStringLiteral()) {
Diag(Tok, diag::err_expected_string_literal)
<< /*Source='static_assert'*/1;
SkipMalformedDecl();
- return 0;
+ return nullptr;
}
ExprResult AssertMessage(ParseStringLiteralExpression());
if (AssertMessage.isInvalid()) {
SkipMalformedDecl();
- return 0;
+ return nullptr;
}
T.consumeClose();
@@ -768,7 +769,7 @@ SourceLocation Parser::ParseDecltypeSpecifier(DeclSpec &DS) {
// C++11 [dcl.type.simple]p4:
// The operand of the decltype specifier is an unevaluated operand.
EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated,
- 0, /*IsDecltype=*/true);
+ nullptr,/*IsDecltype=*/true);
Result = ParseExpression();
if (Result.isInvalid()) {
DS.SetTypeSpecError();
@@ -809,7 +810,7 @@ SourceLocation Parser::ParseDecltypeSpecifier(DeclSpec &DS) {
}
assert(!Result.isInvalid());
- const char *PrevSpec = 0;
+ const char *PrevSpec = nullptr;
unsigned DiagID;
const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
// Check for duplicate type specifiers (e.g. "int decltype(a)").
@@ -865,7 +866,7 @@ void Parser::ParseUnderlyingTypeSpecifier(DeclSpec &DS) {
if (T.getCloseLocation().isInvalid())
return;
- const char *PrevSpec = 0;
+ const char *PrevSpec = nullptr;
unsigned DiagID;
if (DS.SetTypeSpecType(DeclSpec::TST_underlyingType, StartLoc, PrevSpec,
DiagID, Result.release(),
@@ -995,7 +996,7 @@ Parser::TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
}
// We have an identifier; check whether it is actually a type.
- IdentifierInfo *CorrectedII = 0;
+ IdentifierInfo *CorrectedII = nullptr;
ParsedType Type = Actions.getTypeName(*Id, IdLoc, getCurScope(), &SS, true,
false, ParsedType(),
/*IsCtorOrDtorName=*/false,
@@ -1015,7 +1016,7 @@ Parser::TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc,
DS.SetRangeEnd(EndLocation);
DS.getTypeSpecScope() = SS;
- const char *PrevSpec = 0;
+ const char *PrevSpec = nullptr;
unsigned DiagID;
DS.SetTypeSpecType(TST_typename, IdLoc, PrevSpec, DiagID, Type,
Actions.getASTContext().getPrintingPolicy());
@@ -1030,7 +1031,7 @@ void Parser::ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs) {
Tok.is(tok::kw___virtual_inheritance)) {
IdentifierInfo *AttrName = Tok.getIdentifierInfo();
SourceLocation AttrNameLoc = ConsumeToken();
- attrs.addNew(AttrName, AttrNameLoc, 0, AttrNameLoc, 0, 0,
+ attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0,
AttributeList::AS_Keyword);
}
}
@@ -1241,9 +1242,9 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
TemplateParameterLists *TemplateParams = TemplateInfo.TemplateParams;
// Parse the (optional) class name or simple-template-id.
- IdentifierInfo *Name = 0;
+ IdentifierInfo *Name = nullptr;
SourceLocation NameLoc;
- TemplateIdAnnotation *TemplateId = 0;
+ TemplateIdAnnotation *TemplateId = nullptr;
if (Tok.is(tok::identifier)) {
Name = Tok.getIdentifierInfo();
NameLoc = ConsumeToken();
@@ -1272,14 +1273,14 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
if (TemplateParams && TemplateParams->size() > 1) {
TemplateParams->pop_back();
} else {
- TemplateParams = 0;
+ TemplateParams = nullptr;
const_cast<ParsedTemplateInfo&>(TemplateInfo).Kind
= ParsedTemplateInfo::NonTemplate;
}
} else if (TemplateInfo.Kind
== ParsedTemplateInfo::ExplicitInstantiation) {
// Pretend this is just a forward declaration.
- TemplateParams = 0;
+ TemplateParams = nullptr;
const_cast<ParsedTemplateInfo&>(TemplateInfo).Kind
= ParsedTemplateInfo::NonTemplate;
const_cast<ParsedTemplateInfo&>(TemplateInfo).TemplateLoc
@@ -1521,7 +1522,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
if (TUK == Sema::TUK_Friend) {
Diag(DS.getFriendSpecLoc(), diag::err_friend_explicit_instantiation);
- TemplateParams = 0;
+ TemplateParams = nullptr;
} else {
SourceLocation LAngleLoc =
PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
@@ -1534,8 +1535,8 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
// "template<>", so that we treat this construct as a class
// template specialization.
FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
- 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, 0, 0,
- LAngleLoc));
+ 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, nullptr,
+ 0, LAngleLoc));
TemplateParams = &FakedParamLists;
}
}
@@ -1544,7 +1545,8 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
TagOrTempResult = Actions.ActOnClassTemplateSpecialization(
getCurScope(), TagType, TUK, StartLoc, DS.getModulePrivateSpecLoc(),
*TemplateId, attrs.getList(),
- MultiTemplateParamsArg(TemplateParams ? &(*TemplateParams)[0] : 0,
+ MultiTemplateParamsArg(TemplateParams ? &(*TemplateParams)[0]
+ : nullptr,
TemplateParams ? TemplateParams->size() : 0));
}
} else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
@@ -1571,7 +1573,8 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
TagType, StartLoc, SS,
Name, NameLoc, attrs.getList(),
MultiTemplateParamsArg(
- TemplateParams? &(*TemplateParams)[0] : 0,
+ TemplateParams? &(*TemplateParams)[0]
+ : nullptr,
TemplateParams? TemplateParams->size() : 0));
} else {
if (TUK != Sema::TUK_Declaration && TUK != Sema::TUK_Definition)
@@ -1583,7 +1586,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
// recover by ignoring the 'template' keyword.
Diag(Tok, diag::err_template_defn_explicit_instantiation)
<< 1 << FixItHint::CreateRemoval(TemplateInfo.TemplateLoc);
- TemplateParams = 0;
+ TemplateParams = nullptr;
}
bool IsDependent = false;
@@ -1626,7 +1629,7 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.get());
}
- const char *PrevSpec = 0;
+ const char *PrevSpec = nullptr;
unsigned DiagID;
bool Result;
if (!TypeResult.isInvalid()) {
@@ -1798,7 +1801,7 @@ void Parser::HandleMemberFunctionDeclDelays(Declarator& DeclaratorInfo,
Decl *ThisDecl) {
// We just declared a member function. If this member function
// has any default arguments, we'll need to parse them later.
- LateParsedMethodDeclaration *LateMethod = 0;
+ LateParsedMethodDeclaration *LateMethod = nullptr;
DeclaratorChunk::FunctionTypeInfo &FTI
= DeclaratorInfo.getFunctionTypeInfo();
@@ -1873,7 +1876,7 @@ void Parser::ParseOptionalCXX11VirtSpecifierSeq(VirtSpecifiers &VS,
// C++ [class.mem]p8:
// A virt-specifier-seq shall contain at most one of each virt-specifier.
- const char *PrevSpec = 0;
+ const char *PrevSpec = nullptr;
if (VS.SetSpecifier(Specifier, Tok.getLocation(), PrevSpec))
Diag(Tok.getLocation(), diag::err_duplicate_virt_specifier)
<< PrevSpec
@@ -2043,7 +2046,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
/* HasUsingKeyword */ false,
SourceLocation(),
SS, Name,
- /* AttrList */ 0,
+ /* AttrList */ nullptr,
/* HasTypenameKeyword */ false,
SourceLocation());
return;
@@ -2132,7 +2135,8 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
return;
MultiTemplateParamsArg TemplateParams(
- TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->data() : 0,
+ TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->data()
+ : nullptr,
TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->size() : 0);
if (TryConsumeToken(tok::semi)) {
@@ -2281,7 +2285,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
// this call will *not* return the created decl; It will return null.
// See Sema::ActOnCXXMemberDeclarator for details.
- NamedDecl *ThisDecl = 0;
+ NamedDecl *ThisDecl = nullptr;
if (DS.isFriendSpecified()) {
// C++11 [dcl.attr.grammar] p4: If an attribute-specifier-seq appertains
// to a friend declaration, that declaration shall be a definition.
@@ -2305,7 +2309,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
VS, HasInClassInit);
if (VarTemplateDecl *VT =
- ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) : 0)
+ ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) : nullptr)
// Re-direct this decl to refer to the templated decl so that we can
// initialize it.
ThisDecl = VT->getTemplatedDecl();
@@ -2861,7 +2865,7 @@ Parser::MemInitResult Parser::ParseMemInitializer(Decl *ConstructorDecl) {
return true;
}
- IdentifierInfo *II = 0;
+ IdentifierInfo *II = nullptr;
DeclSpec DS(AttrFactory);
SourceLocation IdLoc = Tok.getLocation();
if (Tok.is(tok::annot_decltype)) {
@@ -3157,7 +3161,7 @@ IdentifierInfo *Parser::TryParseCXX11AttributeIdentifier(SourceLocation &Loc) {
Loc = ConsumeToken();
return II;
}
- return 0;
+ return nullptr;
case tok::ampamp: // 'and'
case tok::pipe: // 'bitor'
@@ -3178,7 +3182,7 @@ IdentifierInfo *Parser::TryParseCXX11AttributeIdentifier(SourceLocation &Loc) {
Loc = ConsumeToken();
return &PP.getIdentifierTable().get(Spelling);
}
- return 0;
+ return nullptr;
}
}
@@ -3235,7 +3239,7 @@ bool Parser::ParseCXX11AttributeArgs(IdentifierInfo *AttrName,
// GNU-scoped attributes have some special cases to handle GNU-specific
// behaviors.
ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
- ScopeLoc, AttributeList::AS_CXX11, 0);
+ ScopeLoc, AttributeList::AS_CXX11, nullptr);
else {
unsigned NumArgs =
ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
@@ -3314,7 +3318,7 @@ void Parser::ParseCXX11AttributeSpecifier(ParsedAttributes &attrs,
continue;
SourceLocation ScopeLoc, AttrLoc;
- IdentifierInfo *ScopeName = 0, *AttrName = 0;
+ IdentifierInfo *ScopeName = nullptr, *AttrName = nullptr;
AttrName = TryParseCXX11AttributeIdentifier(AttrLoc);
if (!AttrName)
@@ -3351,7 +3355,7 @@ void Parser::ParseCXX11AttributeSpecifier(ParsedAttributes &attrs,
attrs.addNew(AttrName,
SourceRange(ScopeLoc.isValid() ? ScopeLoc : AttrLoc,
AttrLoc),
- ScopeName, ScopeLoc, 0, 0, AttributeList::AS_CXX11);
+ ScopeName, ScopeLoc, nullptr, 0, AttributeList::AS_CXX11);
if (TryConsumeToken(tok::ellipsis))
Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis)
@@ -3492,7 +3496,7 @@ void Parser::ParseMicrosoftIfExistsClassDeclaration(DeclSpec::TST TagType,
}
// Parse all the comma separated declarators.
- ParseCXXClassMemberDeclaration(CurAS, 0);
+ ParseCXXClassMemberDeclaration(CurAS, nullptr);
}
Braces.consumeClose();
OpenPOWER on IntegriCloud