diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-01-28 01:12:10 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-01-28 01:12:10 +0000 |
commit | b2486af6abbf7adbed00d689f2845a8c4814bd78 (patch) | |
tree | 7368da6351c5dcd13e567559673dbdb88922851f /lib/Parse | |
parent | f239d427be5c811e3666d67f63b0a98b279a6cf3 (diff) |
Convert sequence of 'if's on the same value to a switch. No functionality change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293354 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse')
-rw-r--r-- | lib/Parse/ParseDeclCXX.cpp | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index ca5a251b35..7f54f6c777 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -2958,56 +2958,47 @@ void Parser::SkipCXXMemberSpecification(SourceLocation RecordLoc, Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclarationWithPragmas( AccessSpecifier &AS, ParsedAttributesWithRange &AccessAttrs, DeclSpec::TST TagType, Decl *TagDecl) { - if (getLangOpts().MicrosoftExt && - Tok.isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) { + switch (Tok.getKind()) { + case tok::kw___if_exists: + case tok::kw___if_not_exists: ParseMicrosoftIfExistsClassDeclaration(TagType, AS); return nullptr; - } - // Check for extraneous top-level semicolon. - if (Tok.is(tok::semi)) { + case tok::semi: + // Check for extraneous top-level semicolon. ConsumeExtraSemi(InsideStruct, TagType); return nullptr; - } - if (Tok.is(tok::annot_pragma_vis)) { + // Handle pragmas that can appear as member declarations. + case tok::annot_pragma_vis: HandlePragmaVisibility(); return nullptr; - } - - if (Tok.is(tok::annot_pragma_pack)) { + case tok::annot_pragma_pack: HandlePragmaPack(); return nullptr; - } - - if (Tok.is(tok::annot_pragma_align)) { + case tok::annot_pragma_align: HandlePragmaAlign(); return nullptr; - } - - if (Tok.is(tok::annot_pragma_ms_pointers_to_members)) { + case tok::annot_pragma_ms_pointers_to_members: HandlePragmaMSPointersToMembers(); return nullptr; - } - - if (Tok.is(tok::annot_pragma_ms_pragma)) { + case tok::annot_pragma_ms_pragma: HandlePragmaMSPragma(); return nullptr; - } - - if (Tok.is(tok::annot_pragma_ms_vtordisp)) { + case tok::annot_pragma_ms_vtordisp: HandlePragmaMSVtorDisp(); return nullptr; - } - // If we see a namespace here, a close brace was missing somewhere. - if (Tok.is(tok::kw_namespace)) { + case tok::kw_namespace: + // If we see a namespace here, a close brace was missing somewhere. DiagnoseUnexpectedNamespace(cast<NamedDecl>(TagDecl)); return nullptr; - } - AccessSpecifier NewAS = getAccessSpecifierIfPresent(); - if (NewAS != AS_none) { + case tok::kw_public: + case tok::kw_protected: + case tok::kw_private: { + AccessSpecifier NewAS = getAccessSpecifierIfPresent(); + assert(NewAS != AS_none); // Current token is a C++ access specifier. AS = NewAS; SourceLocation ASLoc = Tok.getLocation(); @@ -3042,12 +3033,13 @@ Parser::DeclGroupPtrTy Parser::ParseCXXClassMemberDeclarationWithPragmas( return nullptr; } - if (Tok.is(tok::annot_pragma_openmp)) + case tok::annot_pragma_openmp: return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, AccessAttrs, TagType, TagDecl); - // Parse all the comma separated declarators. - return ParseCXXClassMemberDeclaration(AS, AccessAttrs.getList()); + default: + return ParseCXXClassMemberDeclaration(AS, AccessAttrs.getList()); + } } /// ParseCXXMemberSpecification - Parse the class definition. |