diff options
author | Douglas Gregor <dgregor@apple.com> | 2008-10-22 17:49:05 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2008-10-22 17:49:05 +0000 |
commit | 29a9247ec2515c4bf3b0bbf9bcbb04f9899406e1 (patch) | |
tree | fa814a563ea54a75e38498f7e7be43d4256fdc41 /clang/lib/Parse/ParseDeclCXX.cpp | |
parent | 254be031df75aef5c0a31f6397be7c207d0360a6 (diff) | |
download | bcm5719-llvm-29a9247ec2515c4bf3b0bbf9bcbb04f9899406e1.tar.gz bcm5719-llvm-29a9247ec2515c4bf3b0bbf9bcbb04f9899406e1.zip |
Add representation of base classes in the AST, and verify that we
don't have duplicated direct base classes.
Seriliazation of base class specifiers is not yet implemented.
llvm-svn: 57991
Diffstat (limited to 'clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index abd432ce9f4..21c7d6f0fe1 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -256,12 +256,19 @@ void Parser::ParseBaseClause(DeclTy *ClassDecl) assert(Tok.is(tok::colon) && "Not a base clause"); ConsumeToken(); + // Build up an array of parsed base specifiers. + llvm::SmallVector<BaseTy *, 8> BaseInfo; + while (true) { // Parse a base-specifier. - if (ParseBaseSpecifier(ClassDecl)) { + BaseResult Result = ParseBaseSpecifier(ClassDecl); + if (Result.isInvalid) { // Skip the rest of this base specifier, up until the comma or // opening brace. - SkipUntil(tok::comma, tok::l_brace); + SkipUntil(tok::comma, tok::l_brace, true, true); + } else { + // Add this to our array of base specifiers. + BaseInfo.push_back(Result.Val); } // If the next token is a comma, consume it and keep reading @@ -271,6 +278,9 @@ void Parser::ParseBaseClause(DeclTy *ClassDecl) // Consume the comma. ConsumeToken(); } + + // Attach the base specifiers + Actions.ActOnBaseSpecifiers(ClassDecl, &BaseInfo[0], BaseInfo.size()); } /// ParseBaseSpecifier - Parse a C++ base-specifier. A base-specifier is @@ -284,7 +294,7 @@ void Parser::ParseBaseClause(DeclTy *ClassDecl) /// class-name /// access-specifier 'virtual'[opt] ::[opt] nested-name-specifier[opt] /// class-name -bool Parser::ParseBaseSpecifier(DeclTy *ClassDecl) +Parser::BaseResult Parser::ParseBaseSpecifier(DeclTy *ClassDecl) { bool IsVirtual = false; SourceLocation StartLoc = Tok.getLocation(); @@ -306,7 +316,8 @@ bool Parser::ParseBaseSpecifier(DeclTy *ClassDecl) SourceLocation VirtualLoc = ConsumeToken(); if (IsVirtual) { // Complain about duplicate 'virtual' - Diag(VirtualLoc, diag::err_dup_virtual); + Diag(VirtualLoc, diag::err_dup_virtual, + SourceRange(VirtualLoc, VirtualLoc)); } IsVirtual = true; @@ -339,9 +350,8 @@ bool Parser::ParseBaseSpecifier(DeclTy *ClassDecl) // Notify semantic analysis that we have parsed a complete // base-specifier. - Actions.ActOnBaseSpecifier(ClassDecl, Range, IsVirtual, Access, BaseType, - BaseLoc); - return false; + return Actions.ActOnBaseSpecifier(ClassDecl, Range, IsVirtual, Access, BaseType, + BaseLoc); } /// getAccessSpecifierIfPresent - Determine whether the next token is |