TranslationUnit object instead of an ASTContext. By default it calls
Initialize(ASTConstext& Context) (to match with the current interface used by
most ASTConsumers).
Modified the ObjC-Rewriter to use InitializeTU, and to tell the TranslationUnit
to not free its Decls. This is a workaround for: <rdar://problem/
5966749>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51825
91177308-0d34-0410-b5e6-
96231b3b80d8
virtual ~ASTSerializer() { delete TU; }
- virtual void Initialize(ASTContext &Context) {
- if (!TU) TU = new TranslationUnit(Context, lang);
- TU->SetOwnsDecls(false);
+ virtual void InitializeTU(TranslationUnit &TU) {
+ TU.SetOwnsDecls(false);
}
virtual void HandleTopLevelDecl(Decl *D) {
#include "clang/Rewrite/Rewriter.h"
#include "clang/AST/AST.h"
#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/TranslationUnit.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/Diagnostic.h"
static const int OBJC_ABI_VERSION =7 ;
public:
- void Initialize(ASTContext &context);
+ virtual void Initialize(ASTContext &context);
+
+ virtual void InitializeTU(TranslationUnit &TU) {
+ TU.SetOwnsDecls(false);
+ Initialize(TU.getContext());
+ }
// Top Level Driver code.
namespace clang {
class ASTContext;
+ class TranslationUnit;
class Decl;
class TagDecl;
class HandleTagDeclDefinition;
/// ASTContext.
virtual void Initialize(ASTContext &Context) {}
+ virtual void InitializeTU(TranslationUnit& TU);
+
/// HandleTopLevelDecl - Handle the specified top-level declaration. This is
/// called by HandleTopLevelDeclaration to process every top-level Decl*.
virtual void HandleTopLevelDecl(Decl *D) {}
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/Decl.h"
+#include "clang/AST/TranslationUnit.h"
+
using namespace clang;
ASTConsumer::~ASTConsumer() {}
else
HandleTopLevelDecl(d);
}
+
+void ASTConsumer::InitializeTU(TranslationUnit& TU) {
+ Initialize(TU.getContext());
+}
// Initialize the parser.
P.Initialize();
- Consumer->Initialize(Context);
+ Consumer->InitializeTU(TU);
Parser::DeclTy *ADecl;