OpaquePtr: Use nullptr construction for DeclGroupPtrTy OpaquePtr typedef

llvm-svn: 257956
This commit is contained in:
David Blaikie 2016-01-15 23:43:25 +00:00
parent 62d4a253f7
commit 0403cb11a1
7 changed files with 73 additions and 73 deletions

View File

@ -1522,7 +1522,7 @@ Parser::ParseSimpleDeclaration(unsigned Context,
// may get this far before the problem becomes obvious.
if (DS.hasTagDefinition() &&
DiagnoseMissingSemiAfterTagDefinition(DS, AS_none, DSContext))
return DeclGroupPtrTy();
return nullptr;
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
// declaration-specifiers init-declarator-list[opt] ';'
@ -1701,7 +1701,7 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
// Bail out if the first declarator didn't seem well-formed.
if (!D.hasName() && !D.mayOmitIdentifier()) {
SkipMalformedDecl();
return DeclGroupPtrTy();
return nullptr;
}
// Save late-parsed attributes for now; they need to be parsed in the
@ -1766,19 +1766,19 @@ Parser::DeclGroupPtrTy Parser::ParseDeclGroup(ParsingDeclSpec &DS,
} else {
Diag(Tok, diag::err_expected_fn_body);
SkipUntil(tok::semi);
return DeclGroupPtrTy();
return nullptr;
}
} else {
if (Tok.is(tok::l_brace)) {
Diag(Tok, diag::err_function_definition_not_allowed);
SkipMalformedDecl();
return DeclGroupPtrTy();
return nullptr;
}
}
}
if (ParseAsmAttributesAfterDeclarator(D))
return DeclGroupPtrTy();
return nullptr;
// C++0x [stmt.iter]p1: Check if we have a for-range-declarator. If so, we
// must parse and analyze the for-range-initializer before the declaration is

View File

@ -65,7 +65,7 @@ Parser::DeclGroupPtrTy Parser::ParseNamespace(unsigned Context,
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteNamespaceDecl(getCurScope());
cutOffParsing();
return DeclGroupPtrTy();
return nullptr;
}
SourceLocation IdentLoc;
@ -109,7 +109,7 @@ Parser::DeclGroupPtrTy Parser::ParseNamespace(unsigned Context,
Diag(Tok, diag::err_expected) << tok::identifier;
// Skip to end of the definition and eat the ';'.
SkipUntil(tok::semi);
return DeclGroupPtrTy();
return nullptr;
}
if (attrLoc.isValid())
Diag(attrLoc, diag::err_unexpected_namespace_attributes_alias);
@ -126,7 +126,7 @@ Parser::DeclGroupPtrTy Parser::ParseNamespace(unsigned Context,
Diag(Tok, diag::err_expected) << tok::l_brace;
else
Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
return DeclGroupPtrTy();
return nullptr;
}
if (getCurScope()->isClassScope() || getCurScope()->isTemplateParamScope() ||
@ -134,7 +134,7 @@ Parser::DeclGroupPtrTy Parser::ParseNamespace(unsigned Context,
getCurScope()->getFnParent()) {
Diag(T.getOpenLocation(), diag::err_namespace_nonnamespace_scope);
SkipUntil(tok::r_brace);
return DeclGroupPtrTy();
return nullptr;
}
if (ExtraIdent.empty()) {
@ -2253,7 +2253,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
ConsumeToken();
SkipUntil(tok::r_brace, StopAtSemi);
return DeclGroupPtrTy();
return nullptr;
}
// Turn on colon protection early, while parsing declspec, although there is
@ -2287,7 +2287,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
if (SS.isInvalid()) {
SkipUntil(tok::semi);
return DeclGroupPtrTy();
return nullptr;
}
// Try to parse an unqualified-id.
@ -2296,14 +2296,14 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
if (ParseUnqualifiedId(SS, false, true, true, ParsedType(),
TemplateKWLoc, Name)) {
SkipUntil(tok::semi);
return DeclGroupPtrTy();
return nullptr;
}
// TODO: recover from mistakenly-qualified operator declarations.
if (ExpectAndConsume(tok::semi, diag::err_expected_after,
"access declaration")) {
SkipUntil(tok::semi);
return DeclGroupPtrTy();
return nullptr;
}
return DeclGroupPtrTy::make(DeclGroupRef(Actions.ActOnUsingDeclaration(
@ -2361,7 +2361,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
if (Tok.is(tok::kw_namespace)) {
Diag(UsingLoc, diag::err_using_namespace_in_class);
SkipUntil(tok::semi, StopBeforeMatch);
return DeclGroupPtrTy();
return nullptr;
}
SourceLocation DeclEnd;
// Otherwise, it must be a using-declaration or an alias-declaration.
@ -2391,7 +2391,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate &&
DiagnoseMissingSemiAfterTagDefinition(DS, AS, DSC_class,
&CommonLateParsedAttrs))
return DeclGroupPtrTy();
return nullptr;
MultiTemplateParamsArg TemplateParams(
TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->data()
@ -2446,7 +2446,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
if (ParseCXXMemberDeclaratorBeforeInitializer(
DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
TryConsumeToken(tok::semi);
return DeclGroupPtrTy();
return nullptr;
}
// Check for a member function definition.
@ -2495,7 +2495,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
// Consume the optional ';'
TryConsumeToken(tok::semi);
return DeclGroupPtrTy();
return nullptr;
}
if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
@ -2698,7 +2698,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
// If we stopped at a ';', eat it.
TryConsumeToken(tok::semi);
return DeclGroupPtrTy();
return nullptr;
}
return Actions.FinalizeDeclaratorGroup(getCurScope(), DS, DeclsInGroup);
@ -2825,49 +2825,49 @@ Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclarationWithPragmas(
if (getLangOpts().MicrosoftExt &&
Tok.isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
ParseMicrosoftIfExistsClassDeclaration(TagType, AS);
return DeclGroupPtrTy();
return nullptr;
}
// Check for extraneous top-level semicolon.
if (Tok.is(tok::semi)) {
ConsumeExtraSemi(InsideStruct, TagType);
return DeclGroupPtrTy();
return nullptr;
}
if (Tok.is(tok::annot_pragma_vis)) {
HandlePragmaVisibility();
return DeclGroupPtrTy();
return nullptr;
}
if (Tok.is(tok::annot_pragma_pack)) {
HandlePragmaPack();
return DeclGroupPtrTy();
return nullptr;
}
if (Tok.is(tok::annot_pragma_align)) {
HandlePragmaAlign();
return DeclGroupPtrTy();
return nullptr;
}
if (Tok.is(tok::annot_pragma_ms_pointers_to_members)) {
HandlePragmaMSPointersToMembers();
return DeclGroupPtrTy();
return nullptr;
}
if (Tok.is(tok::annot_pragma_ms_pragma)) {
HandlePragmaMSPragma();
return DeclGroupPtrTy();
return nullptr;
}
if (Tok.is(tok::annot_pragma_ms_vtordisp)) {
HandlePragmaMSVtorDisp();
return DeclGroupPtrTy();
return nullptr;
}
// If we see a namespace here, a close brace was missing somewhere.
if (Tok.is(tok::kw_namespace)) {
DiagnoseUnexpectedNamespace(cast<NamedDecl>(TagDecl));
return DeclGroupPtrTy();
return nullptr;
}
AccessSpecifier NewAS = getAccessSpecifierIfPresent();
@ -2903,7 +2903,7 @@ Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclarationWithPragmas(
AccessAttrs.clear();
}
return DeclGroupPtrTy();
return nullptr;
}
if (Tok.is(tok::annot_pragma_openmp))

View File

@ -50,7 +50,7 @@ Parser::DeclGroupPtrTy Parser::ParseObjCAtDirectives() {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCAtDirective(getCurScope());
cutOffParsing();
return DeclGroupPtrTy();
return nullptr;
}
Decl *SingleDecl = nullptr;
@ -2005,14 +2005,14 @@ Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCProtocolDecl(getCurScope());
cutOffParsing();
return DeclGroupPtrTy();
return nullptr;
}
MaybeSkipAttributes(tok::objc_protocol);
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected) << tok::identifier; // missing protocol name.
return DeclGroupPtrTy();
return nullptr;
}
// Save the protocol name, then consume it.
IdentifierInfo *protocolName = Tok.getIdentifierInfo();
@ -2036,7 +2036,7 @@ Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected) << tok::identifier;
SkipUntil(tok::semi);
return DeclGroupPtrTy();
return nullptr;
}
ProtocolRefs.push_back(IdentifierLocPair(Tok.getIdentifierInfo(),
Tok.getLocation()));
@ -2047,7 +2047,7 @@ Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
}
// Consume the ';'.
if (ExpectAndConsume(tok::semi, diag::err_expected_after, "@protocol"))
return DeclGroupPtrTy();
return nullptr;
return Actions.ActOnForwardProtocolDeclaration(AtLoc, ProtocolRefs,
attrs.getList());
@ -2062,7 +2062,7 @@ Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc,
ParseObjCProtocolReferences(ProtocolRefs, ProtocolLocs, false, true,
LAngleLoc, EndProtoLoc,
/*consumeLastToken=*/true))
return DeclGroupPtrTy();
return nullptr;
Decl *ProtoType =
Actions.ActOnStartProtocolInterface(AtLoc, protocolName, nameLoc,
@ -2096,7 +2096,7 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCImplementationDecl(getCurScope());
cutOffParsing();
return DeclGroupPtrTy();
return nullptr;
}
MaybeSkipAttributes(tok::objc_implementation);
@ -2104,7 +2104,7 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) {
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected)
<< tok::identifier; // missing class or category name.
return DeclGroupPtrTy();
return nullptr;
}
// We have a class or category name - consume it.
IdentifierInfo *nameId = Tok.getIdentifierInfo();
@ -2137,7 +2137,7 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCImplementationCategory(getCurScope(), nameId, nameLoc);
cutOffParsing();
return DeclGroupPtrTy();
return nullptr;
}
if (Tok.is(tok::identifier)) {
@ -2146,12 +2146,12 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) {
} else {
Diag(Tok, diag::err_expected)
<< tok::identifier; // missing category name.
return DeclGroupPtrTy();
return nullptr;
}
if (Tok.isNot(tok::r_paren)) {
Diag(Tok, diag::err_expected) << tok::r_paren;
SkipUntil(tok::r_paren); // don't stop at ';'
return DeclGroupPtrTy();
return nullptr;
}
rparenLoc = ConsumeParen();
if (Tok.is(tok::less)) { // we have illegal '<' try to recover
@ -2178,7 +2178,7 @@ Parser::ParseObjCAtImplementationDeclaration(SourceLocation AtLoc) {
if (Tok.isNot(tok::identifier)) {
Diag(Tok, diag::err_expected)
<< tok::identifier; // missing super class name.
return DeclGroupPtrTy();
return nullptr;
}
superClassId = Tok.getIdentifierInfo();
superClassLoc = ConsumeToken(); // Consume super class name
@ -2232,7 +2232,7 @@ Parser::ParseObjCAtEndDeclaration(SourceRange atEnd) {
else
// missing @implementation
Diag(atEnd.getBegin(), diag::err_expected_objc_container);
return DeclGroupPtrTy();
return nullptr;
}
Parser::ObjCImplParsingDataRAII::~ObjCImplParsingDataRAII() {

View File

@ -146,7 +146,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() {
break;
}
SkipUntil(tok::annot_pragma_openmp_end);
return DeclGroupPtrTy();
return nullptr;
}
/// \brief Parsing of declarative or executable OpenMP directives.

View File

@ -1632,7 +1632,7 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) {
ConsumeToken(); // consume 'in'
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteObjCForCollection(getCurScope(), DeclGroupPtrTy());
Actions.CodeCompleteObjCForCollection(getCurScope(), nullptr);
cutOffParsing();
return StmtError();
}

View File

@ -545,7 +545,7 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) {
if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof))
ConsumeToken();
Result = DeclGroupPtrTy();
Result = nullptr;
switch (Tok.getKind()) {
case tok::annot_pragma_unused:
HandlePragmaUnused();
@ -625,52 +625,52 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
if (PP.isCodeCompletionReached()) {
cutOffParsing();
return DeclGroupPtrTy();
return nullptr;
}
Decl *SingleDecl = nullptr;
switch (Tok.getKind()) {
case tok::annot_pragma_vis:
HandlePragmaVisibility();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_pack:
HandlePragmaPack();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_msstruct:
HandlePragmaMSStruct();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_align:
HandlePragmaAlign();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_weak:
HandlePragmaWeak();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_weakalias:
HandlePragmaWeakAlias();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_redefine_extname:
HandlePragmaRedefineExtname();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_fp_contract:
HandlePragmaFPContract();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_opencl_extension:
HandlePragmaOpenCLExtension();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_openmp:
return ParseOpenMPDeclarativeDirective();
case tok::annot_pragma_ms_pointers_to_members:
HandlePragmaMSPointersToMembers();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_ms_vtordisp:
HandlePragmaMSVtorDisp();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_ms_pragma:
HandlePragmaMSPragma();
return DeclGroupPtrTy();
return nullptr;
case tok::annot_pragma_dump:
HandlePragmaDump();
return DeclGroupPtrTy();
return nullptr;
case tok::semi:
// Either a C++11 empty-declaration or attribute-declaration.
SingleDecl = Actions.ActOnEmptyDeclaration(getCurScope(),
@ -681,10 +681,10 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
case tok::r_brace:
Diag(Tok, diag::err_extraneous_closing_brace);
ConsumeBrace();
return DeclGroupPtrTy();
return nullptr;
case tok::eof:
Diag(Tok, diag::err_expected_external_declaration);
return DeclGroupPtrTy();
return nullptr;
case tok::kw___extension__: {
// __extension__ silences extension warnings in the subexpression.
ExtensionRAIIObject O(Diags); // Use RAII to do this.
@ -712,7 +712,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
"top-level asm block");
if (Result.isInvalid())
return DeclGroupPtrTy();
return nullptr;
SingleDecl = Actions.ActOnFileScopeAsmDecl(Result.get(), StartLoc, EndLoc);
break;
}
@ -723,7 +723,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
if (!getLangOpts().ObjC1) {
Diag(Tok, diag::err_expected_external_declaration);
ConsumeToken();
return DeclGroupPtrTy();
return nullptr;
}
SingleDecl = ParseObjCMethodDefinition();
break;
@ -732,7 +732,7 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
CurParsedObjCImpl? Sema::PCC_ObjCImplementation
: Sema::PCC_Namespace);
cutOffParsing();
return DeclGroupPtrTy();
return nullptr;
case tok::kw_using:
case tok::kw_namespace:
case tok::kw_typedef:
@ -796,8 +796,8 @@ Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
case tok::kw___if_exists:
case tok::kw___if_not_exists:
ParseMicrosoftIfExistsExternalDeclaration();
return DeclGroupPtrTy();
return nullptr;
default:
dont_know:
// We can't tell whether this is a function-definition or declaration yet.
@ -876,7 +876,7 @@ Parser::ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs,
// may get this far before the problem becomes obvious.
if (DS.hasTagDefinition() &&
DiagnoseMissingSemiAfterTagDefinition(DS, AS, DSC_top_level))
return DeclGroupPtrTy();
return nullptr;
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
// declaration-specifiers init-declarator-list[opt] ';'
@ -899,7 +899,7 @@ Parser::ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs,
!Tok.isObjCAtKeyword(tok::objc_protocol)) {
Diag(Tok, diag::err_objc_unexpected_attr);
SkipUntil(tok::semi); // FIXME: better skip?
return DeclGroupPtrTy();
return nullptr;
}
DS.abort();
@ -1990,12 +1990,12 @@ Parser::DeclGroupPtrTy Parser::ParseModuleImport(SourceLocation AtLoc) {
if (Tok.is(tok::code_completion)) {
Actions.CodeCompleteModuleImport(ImportLoc, Path);
cutOffParsing();
return DeclGroupPtrTy();
return nullptr;
}
Diag(Tok, diag::err_module_expected_ident);
SkipUntil(tok::semi);
return DeclGroupPtrTy();
return nullptr;
}
// Record this part of the module path.
@ -2013,14 +2013,14 @@ Parser::DeclGroupPtrTy Parser::ParseModuleImport(SourceLocation AtLoc) {
if (PP.hadModuleLoaderFatalFailure()) {
// With a fatal failure in the module loader, we abort parsing.
cutOffParsing();
return DeclGroupPtrTy();
return nullptr;
}
DeclResult Import = Actions.ActOnModuleImport(AtLoc, ImportLoc, Path);
ExpectAndConsumeSemi(diag::err_module_expected_semi);
if (Import.isInvalid())
return DeclGroupPtrTy();
return nullptr;
return Actions.ConvertDeclToDeclGroup(Import.get());
}

View File

@ -1141,7 +1141,7 @@ Sema::ActOnOpenMPThreadprivateDirective(SourceLocation Loc,
CurContext->addDecl(D);
return DeclGroupPtrTy::make(DeclGroupRef(D));
}
return DeclGroupPtrTy();
return nullptr;
}
namespace {