Skip to content

Commit

Permalink
Fixing #11.
Browse files Browse the repository at this point in the history
Parse namespace-scoped declarations differently, depending on
context. Also, explciitly handle top-level declarations, using the
AST consumer, which seems to ensure that they get defined.
  • Loading branch information
asutton committed Apr 10, 2017
1 parent f28e024 commit 4d811cd
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/Parse/ParseInject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//

#include "RAIIObjectsForParser.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Parse/Parser.h"
#include "clang/Sema/PrettyDeclStackTrace.h"
Expand Down Expand Up @@ -67,16 +68,15 @@ void Parser::ParseInjectedNamespaceMember(Stmt *S)
CachedTokens Toks;
InjectTokens(S, Toks);

SourceLocation End;
ParsedAttributesWithRange Attrs(AttrFactory);
DeclGroupPtrTy Decls = ParseDeclaration(Declarator::FileContext, End, Attrs);
(void)Decls;

// FIXME: These are causing linker errors.

// DeclGroupRef DG = Decls.get();
// for (auto I = DG.begin(); I != DG.end(); ++I)
// (*I)->dump();
// The parsing method depends on context.
if (Actions.CurContext->isTranslationUnit()) {
DeclGroupPtrTy Decls;
ParseTopLevelDecl(Decls);
Actions.getASTConsumer().HandleTopLevelDecl(Decls.get());
} else {
ParsedAttributesWithRange Attrs(AttrFactory);
ParseExternalDeclaration(Attrs);
}
}

void Parser::ParseInjectedClassMember(Stmt *S)
Expand Down

0 comments on commit 4d811cd

Please sign in to comment.