forked from OSchip/llvm-project
change HandleTranslationUnit to take an ASTContext instead of TranslationUnit
llvm-svn: 67910
This commit is contained in:
parent
cd58cced81
commit
cf16983179
|
@ -16,7 +16,6 @@
|
|||
|
||||
namespace clang {
|
||||
class ASTContext;
|
||||
class TranslationUnit;
|
||||
class Decl;
|
||||
class TagDecl;
|
||||
class HandleTagDeclDefinition;
|
||||
|
@ -40,7 +39,7 @@ public:
|
|||
|
||||
/// HandleTranslationUnit - This method is called when the ASTs for entire
|
||||
/// translation unit have been parsed.
|
||||
virtual void HandleTranslationUnit(TranslationUnit& TU) {}
|
||||
virtual void HandleTranslationUnit(ASTContext &Ctx) {}
|
||||
|
||||
/// HandleTagDeclDefinition - This callback is invoked each time a TagDecl
|
||||
/// (e.g. struct, union, enum, class) is completed. This allows the client to
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace {
|
|||
Builder->UpdateCompletedType(D);
|
||||
}
|
||||
|
||||
virtual void HandleTranslationUnit(TranslationUnit& TU) {
|
||||
virtual void HandleTranslationUnit(ASTContext &Ctx) {
|
||||
if (Diags.hasErrorOccurred()) {
|
||||
M.reset();
|
||||
return;
|
||||
|
|
|
@ -56,7 +56,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
|
|||
}
|
||||
};
|
||||
|
||||
Consumer->HandleTranslationUnit(TU);
|
||||
Consumer->HandleTranslationUnit(TU.getContext());
|
||||
|
||||
if (PrintStats) {
|
||||
fprintf(stderr, "\nSTATISTICS:\n");
|
||||
|
|
|
@ -658,8 +658,8 @@ class DeclContextPrinter : public ASTConsumer {
|
|||
public:
|
||||
DeclContextPrinter() : Out(llvm::errs()) {}
|
||||
|
||||
void HandleTranslationUnit(TranslationUnit& TU) {
|
||||
PrintDeclContext(TU.getContext().getTranslationUnitDecl(), 4);
|
||||
void HandleTranslationUnit(ASTContext &C) {
|
||||
PrintDeclContext(C.getTranslationUnitDecl(), 4);
|
||||
}
|
||||
|
||||
void PrintDeclContext(const DeclContext* DC, unsigned Indentation);
|
||||
|
@ -935,8 +935,7 @@ class InheritanceViewer : public ASTConsumer {
|
|||
public:
|
||||
InheritanceViewer(const std::string& cname) : clsname(cname) {}
|
||||
|
||||
void HandleTranslationUnit(TranslationUnit& TU) {
|
||||
ASTContext& C = TU.getContext();
|
||||
void HandleTranslationUnit(ASTContext &C) {
|
||||
for (ASTContext::type_iterator I=C.types_begin(),E=C.types_end(); I!=E; ++I)
|
||||
if (RecordType *T = dyn_cast<RecordType>(*I)) {
|
||||
if (CXXRecordDecl *D = dyn_cast<CXXRecordDecl>(T->getDecl())) {
|
||||
|
@ -974,7 +973,7 @@ public:
|
|||
SingleFileSerializer(const llvm::sys::Path& F, Diagnostic& diags)
|
||||
: ASTSerializer(diags), FName(F) {}
|
||||
|
||||
virtual void HandleTranslationUnit(TranslationUnit& TU) {
|
||||
virtual void HandleTranslationUnit(ASTContext &Ctx) {
|
||||
if (Diags.hasErrorOccurred())
|
||||
return;
|
||||
|
||||
|
@ -982,7 +981,7 @@ public:
|
|||
std::vector<unsigned char> Buffer;
|
||||
Buffer.reserve(256*1024);
|
||||
|
||||
EmitASTBitcodeBuffer(TU.getContext(), Buffer);
|
||||
EmitASTBitcodeBuffer(Ctx, Buffer);
|
||||
|
||||
// Write the bits to disk.
|
||||
if (FILE* fp = fopen(FName.c_str(),"wb")) {
|
||||
|
@ -998,11 +997,11 @@ public:
|
|||
BuildSerializer(const llvm::sys::Path& dir, Diagnostic& diags)
|
||||
: ASTSerializer(diags), EmitDir(dir) {}
|
||||
|
||||
virtual void HandleTranslationUnit(TranslationUnit& TU) {
|
||||
virtual void HandleTranslationUnit(ASTContext &Ctx) {
|
||||
if (Diags.hasErrorOccurred())
|
||||
return;
|
||||
|
||||
SourceManager& SourceMgr = TU.getContext().getSourceManager();
|
||||
SourceManager& SourceMgr = Ctx.getSourceManager();
|
||||
FileID ID = SourceMgr.getMainFileID();
|
||||
assert(!ID.isInvalid() && "MainFileID not set!");
|
||||
const FileEntry* FE = SourceMgr.getFileEntryForID(ID);
|
||||
|
@ -1033,7 +1032,7 @@ public:
|
|||
std::vector<unsigned char> Buffer;
|
||||
Buffer.reserve(256*1024);
|
||||
|
||||
EmitASTBitcodeBuffer(TU.getContext(), Buffer);
|
||||
EmitASTBitcodeBuffer(Ctx, Buffer);
|
||||
|
||||
// Write the bits to disk.
|
||||
if (FILE* fp = fopen(FName.c_str(),"wb")) {
|
||||
|
|
|
@ -223,7 +223,7 @@ namespace {
|
|||
}
|
||||
|
||||
virtual void HandleTopLevelDecl(Decl *D);
|
||||
virtual void HandleTranslationUnit(TranslationUnit &TU);
|
||||
virtual void HandleTranslationUnit(ASTContext &C);
|
||||
|
||||
void HandleCode(Decl* D, Stmt* Body, Actions& actions);
|
||||
};
|
||||
|
@ -444,7 +444,7 @@ void AnalysisConsumer::HandleTopLevelDecl(Decl *D) {
|
|||
}
|
||||
}
|
||||
|
||||
void AnalysisConsumer::HandleTranslationUnit(TranslationUnit& TU) {
|
||||
void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
|
||||
|
||||
if(!TranslationUnitActions.empty()) {
|
||||
AnalysisManager mgr(*this, AnalyzerDisplayProgress);
|
||||
|
@ -454,7 +454,7 @@ void AnalysisConsumer::HandleTranslationUnit(TranslationUnit& TU) {
|
|||
}
|
||||
|
||||
if (!ObjCImplementationActions.empty()) {
|
||||
TranslationUnitDecl *TUD = TU.getContext().getTranslationUnitDecl();
|
||||
TranslationUnitDecl *TUD = C.getTranslationUnitDecl();
|
||||
|
||||
for (DeclContext::decl_iterator I = TUD->decls_begin(),E = TUD->decls_end();
|
||||
I != E; ++I)
|
||||
|
|
|
@ -131,13 +131,13 @@ namespace {
|
|||
LLVMIRGeneration.stopTimer();
|
||||
}
|
||||
|
||||
virtual void HandleTranslationUnit(TranslationUnit& TU) {
|
||||
virtual void HandleTranslationUnit(ASTContext &C) {
|
||||
{
|
||||
PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
|
||||
if (CompileOpts.TimePasses)
|
||||
LLVMIRGeneration.startTimer();
|
||||
|
||||
Gen->HandleTranslationUnit(TU);
|
||||
Gen->HandleTranslationUnit(C);
|
||||
|
||||
if (CompileOpts.TimePasses)
|
||||
LLVMIRGeneration.stopTimer();
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "clang/Rewrite/Rewriter.h"
|
||||
#include "clang/AST/AST.h"
|
||||
#include "clang/AST/ASTConsumer.h"
|
||||
#include "clang/AST/TranslationUnit.h"
|
||||
#include "clang/AST/ParentMap.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Basic/IdentifierTable.h"
|
||||
|
@ -134,7 +133,7 @@ namespace {
|
|||
|
||||
~RewriteObjC() {}
|
||||
|
||||
virtual void HandleTranslationUnit(TranslationUnit& TU);
|
||||
virtual void HandleTranslationUnit(ASTContext &C);
|
||||
|
||||
void ReplaceStmt(Stmt *Old, Stmt *New) {
|
||||
Stmt *ReplacingStmt = ReplacedNodes[Old];
|
||||
|
@ -4516,7 +4515,7 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) {
|
|||
// Nothing yet.
|
||||
}
|
||||
|
||||
void RewriteObjC::HandleTranslationUnit(TranslationUnit& TU) {
|
||||
void RewriteObjC::HandleTranslationUnit(ASTContext &C) {
|
||||
// Get the top-level buffer that this corresponds to.
|
||||
|
||||
// Rewrite tabs if we care.
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
~SerializationTest() {}
|
||||
|
||||
virtual void HandleTranslationUnit(TranslationUnit& TU);
|
||||
virtual void HandleTranslationUnit(ASTContext &C);
|
||||
|
||||
private:
|
||||
bool Serialize(llvm::sys::Path& Filename, llvm::sys::Path& FNameDeclPrint,
|
||||
|
@ -142,7 +142,7 @@ namespace {
|
|||
};
|
||||
}
|
||||
|
||||
void SerializationTest::HandleTranslationUnit(TranslationUnit& TU) {
|
||||
void SerializationTest::HandleTranslationUnit(ASTContext &Ctx) {
|
||||
|
||||
std::string ErrMsg;
|
||||
llvm::sys::Path Dir = llvm::sys::Path::GetTemporaryDirectory(&ErrMsg);
|
||||
|
@ -157,7 +157,7 @@ void SerializationTest::HandleTranslationUnit(TranslationUnit& TU) {
|
|||
llvm::sys::Path FNameDeclBefore = Dir;
|
||||
FNameDeclBefore.appendComponent("test.decl_before.txt");
|
||||
|
||||
if (FNameDeclBefore.makeUnique(true,&ErrMsg)) {
|
||||
if (FNameDeclBefore.makeUnique(true, &ErrMsg)) {
|
||||
llvm::cerr << "Error: " << ErrMsg << "\n";
|
||||
return;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ void SerializationTest::HandleTranslationUnit(TranslationUnit& TU) {
|
|||
llvm::sys::Path FNameDeclAfter = Dir;
|
||||
FNameDeclAfter.appendComponent("test.decl_after.txt");
|
||||
|
||||
if (FNameDeclAfter.makeUnique(true,&ErrMsg)) {
|
||||
if (FNameDeclAfter.makeUnique(true, &ErrMsg)) {
|
||||
llvm::cerr << "Error: " << ErrMsg << "\n";
|
||||
return;
|
||||
}
|
||||
|
@ -173,13 +173,13 @@ void SerializationTest::HandleTranslationUnit(TranslationUnit& TU) {
|
|||
llvm::sys::Path ASTFilename = Dir;
|
||||
ASTFilename.appendComponent("test.ast");
|
||||
|
||||
if (ASTFilename.makeUnique(true,&ErrMsg)) {
|
||||
if (ASTFilename.makeUnique(true, &ErrMsg)) {
|
||||
llvm::cerr << "Error: " << ErrMsg << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// Serialize and then deserialize the ASTs.
|
||||
bool status = Serialize(ASTFilename, FNameDeclBefore, TU.getContext());
|
||||
bool status = Serialize(ASTFilename, FNameDeclBefore, Ctx);
|
||||
assert (status && "Serialization failed.");
|
||||
status = Deserialize(ASTFilename, FNameDeclAfter);
|
||||
assert (status && "Deserialization failed.");
|
||||
|
|
Loading…
Reference in New Issue