Browse Source

Simplify record redeclarations handling in the parser.

pull/970/head
Joao Matos 8 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) @@ -785,6 +785,14 @@ Class* Parser::GetRecord(const clang::RecordDecl* Record, bool& Process)
HandleDeclaration(Record, 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)
{
auto USR = GetDeclUSR(Record);
@ -3474,8 +3482,7 @@ Declaration* Parser::WalkDeclarationDef(clang::Decl* D) @@ -3474,8 +3482,7 @@ Declaration* Parser::WalkDeclarationDef(clang::Decl* D)
return WalkDeclaration(D, /*CanBeDefinition=*/true);
}
Declaration* Parser::WalkDeclaration(const clang::Decl* D,
bool CanBeDefinition, bool WalkRedecls)
Declaration* Parser::WalkDeclaration(const clang::Decl* D, bool CanBeDefinition)
{
using namespace clang;
@ -3487,7 +3494,6 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D, @@ -3487,7 +3494,6 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D,
case Decl::Record:
{
auto RD = cast<RecordDecl>(D);
auto Record = WalkRecord(RD);
// We store a definition order index into the declarations.
@ -3508,13 +3514,8 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D, @@ -3508,13 +3514,8 @@ Declaration* Parser::WalkDeclaration(const clang::Decl* D,
case Decl::CXXRecord:
{
auto RD = cast<CXXRecordDecl>(D);
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.
// This is needed because declarations are added to their contexts as
// soon as they are referenced and we need to know the original order

3
src/CppParser/Parser.h

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

Loading…
Cancel
Save