Browse Source

Simplify record redeclarations handling in the parser.

pull/970/head
Joao Matos 9 years ago committed by João Matos
parent
commit
656e4f3773
  1. 17
      src/CppParser/Parser.cpp
  2. 3
      src/CppParser/Parser.h

17
src/CppParser/Parser.cpp

@ -785,6 +785,14 @@ Class* Parser::GetRecord(const clang::RecordDecl* Record, bool& Process)
HandleDeclaration(Record, RC); HandleDeclaration(Record, RC);
EnsureCompleteRecord(Record, NS, RC); EnsureCompleteRecord(Record, NS, RC);
for (auto Redecl : Record->redecls())
{
if (Redecl->isImplicit() || Redecl == Record)
continue;
RC->Redeclarations.push_back(WalkDeclaration(Redecl, false));
}
if (HasEmptyName) if (HasEmptyName)
{ {
auto USR = GetDeclUSR(Record); auto USR = GetDeclUSR(Record);
@ -3474,8 +3482,7 @@ Declaration* Parser::WalkDeclarationDef(clang::Decl* D)
return WalkDeclaration(D, /*CanBeDefinition=*/true); return WalkDeclaration(D, /*CanBeDefinition=*/true);
} }
Declaration* Parser::WalkDeclaration(const clang::Decl* D, Declaration* Parser::WalkDeclaration(const clang::Decl* D, bool CanBeDefinition)
bool CanBeDefinition, bool WalkRedecls)
{ {
using namespace clang; using namespace clang;
@ -3487,7 +3494,6 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D,
case Decl::Record: case Decl::Record:
{ {
auto RD = cast<RecordDecl>(D); auto RD = cast<RecordDecl>(D);
auto Record = WalkRecord(RD); auto Record = WalkRecord(RD);
// We store a definition order index into the declarations. // We store a definition order index into the declarations.
@ -3508,13 +3514,8 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D,
case Decl::CXXRecord: case Decl::CXXRecord:
{ {
auto RD = cast<CXXRecordDecl>(D); auto RD = cast<CXXRecordDecl>(D);
auto Class = WalkRecordCXX(RD); auto Class = WalkRecordCXX(RD);
if (WalkRedecls)
for (auto redecl : RD->redecls())
Class->Redeclarations.push_back(WalkDeclaration(redecl, false, false));
// We store a definition order index into the declarations. // We store a definition order index into the declarations.
// This is needed because declarations are added to their contexts as // This is needed because declarations are added to their contexts as
// soon as they are referenced and we need to know the original order // soon as they are referenced and we need to know the original order

3
src/CppParser/Parser.h

@ -61,8 +61,7 @@ public:
private: private:
// AST traversers // AST traversers
void WalkAST(); void WalkAST();
Declaration* WalkDeclaration(const clang::Decl* D, bool CanBeDefinition = false, Declaration* WalkDeclaration(const clang::Decl* D, bool CanBeDefinition = false);
bool WalkDeclarations = true);
Declaration* WalkDeclarationDef(clang::Decl* D); Declaration* WalkDeclarationDef(clang::Decl* D);
Enumeration* WalkEnum(const clang::EnumDecl* ED); Enumeration* WalkEnum(const clang::EnumDecl* ED);
Enumeration::Item* WalkEnumItem(clang::EnumConstantDecl* ECD); Enumeration::Item* WalkEnumItem(clang::EnumConstantDecl* ECD);

Loading…
Cancel
Save