diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-09 21:40:53 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-09 21:40:53 +0000 |
commit | bcced4ec315718d9a7775620eb2743b9aea89fd2 (patch) | |
tree | fa18ab54ceebd06f7b26e501e8566e1a09480b07 /clang/tools/clang-cc | |
parent | 32e6e8ed3b522b4ff2c41ad907b53566d6f757a7 (diff) | |
download | bcm5719-llvm-bcced4ec315718d9a7775620eb2743b9aea89fd2.tar.gz bcm5719-llvm-bcced4ec315718d9a7775620eb2743b9aea89fd2.zip |
Propagate the ASTContext to various AST traversal and lookup functions.
No functionality change (really).
llvm-svn: 68726
Diffstat (limited to 'clang/tools/clang-cc')
-rw-r--r-- | clang/tools/clang-cc/ASTConsumers.cpp | 55 | ||||
-rw-r--r-- | clang/tools/clang-cc/ASTConsumers.h | 2 | ||||
-rw-r--r-- | clang/tools/clang-cc/AnalysisConsumer.cpp | 3 | ||||
-rw-r--r-- | clang/tools/clang-cc/RewriteBlocks.cpp | 40 | ||||
-rw-r--r-- | clang/tools/clang-cc/RewriteObjC.cpp | 92 | ||||
-rw-r--r-- | clang/tools/clang-cc/SerializationTest.cpp | 6 | ||||
-rw-r--r-- | clang/tools/clang-cc/clang-cc.cpp | 6 |
7 files changed, 129 insertions, 75 deletions
diff --git a/clang/tools/clang-cc/ASTConsumers.cpp b/clang/tools/clang-cc/ASTConsumers.cpp index 1b5cdd36bef..74683e30317 100644 --- a/clang/tools/clang-cc/ASTConsumers.cpp +++ b/clang/tools/clang-cc/ASTConsumers.cpp @@ -125,8 +125,10 @@ void DeclPrinter:: PrintDecl(Decl *D) { Out << ";\n"; } else if (EnumDecl *ED = dyn_cast<EnumDecl>(D)) { Out << "enum " << ED->getNameAsString() << " {\n"; - for (EnumDecl::enumerator_iterator E = ED->enumerator_begin(), - EEnd = ED->enumerator_end(); + // FIXME: Shouldn't pass a NULL context + ASTContext *Context = 0; + for (EnumDecl::enumerator_iterator E = ED->enumerator_begin(*Context), + EEnd = ED->enumerator_end(*Context); E != EEnd; ++E) Out << " " << (*E)->getNameAsString() << ",\n"; Out << "};\n"; @@ -139,8 +141,10 @@ void DeclPrinter:: PrintDecl(Decl *D) { Out << " {\n"; ChangeIndent(1); - for (DeclContext::decl_iterator i = TD->decls_begin(); - i != TD->decls_end(); + // FIXME: Shouldn't pass a NULL context + ASTContext *Context = 0; + for (DeclContext::decl_iterator i = TD->decls_begin(*Context); + i != TD->decls_end(*Context); ++i) PrintDecl(*i); ChangeIndent(-1); @@ -198,8 +202,10 @@ void DeclPrinter::Print(NamedDecl *ND) { void DeclPrinter::Print(NamespaceDecl *NS) { Out << "namespace " << NS->getNameAsString() << " {\n"; ChangeIndent(1); - for (DeclContext::decl_iterator i = NS->decls_begin(); - i != NS->decls_end(); + // FIXME: Shouldn't pass a NULL context + ASTContext *Context = 0; + for (DeclContext::decl_iterator i = NS->decls_begin(*Context); + i != NS->decls_end(*Context); ++i) PrintDecl(*i); ChangeIndent(-1); @@ -278,8 +284,10 @@ void DeclPrinter::PrintLinkageSpec(LinkageSpecDecl *LS) { ChangeIndent(1); } - for (LinkageSpecDecl::decl_iterator D = LS->decls_begin(), - DEnd = LS->decls_end(); + // FIXME: Should not use a NULL DeclContext! + ASTContext *Context = 0; + for (LinkageSpecDecl::decl_iterator D = LS->decls_begin(*Context), + DEnd = LS->decls_end(*Context); D != DEnd; ++D) PrintDecl(*D); @@ -389,16 +397,18 @@ void DeclPrinter::PrintObjCInterfaceDecl(ObjCInterfaceDecl *OID) { Out << "}\n"; } - for (ObjCInterfaceDecl::prop_iterator I = OID->prop_begin(), - E = OID->prop_end(); I != E; ++I) + // FIXME: Should not use a NULL DeclContext! + ASTContext *Context = 0; + for (ObjCInterfaceDecl::prop_iterator I = OID->prop_begin(*Context), + E = OID->prop_end(*Context); I != E; ++I) PrintObjCPropertyDecl(*I); bool eol_needed = false; - for (ObjCInterfaceDecl::classmeth_iterator I = OID->classmeth_begin(), - E = OID->classmeth_end(); I != E; ++I) + for (ObjCInterfaceDecl::classmeth_iterator I = OID->classmeth_begin(*Context), + E = OID->classmeth_end(*Context); I != E; ++I) eol_needed = true, PrintObjCMethodDecl(*I); - for (ObjCInterfaceDecl::instmeth_iterator I = OID->instmeth_begin(), - E = OID->instmeth_end(); I != E; ++I) + for (ObjCInterfaceDecl::instmeth_iterator I = OID->instmeth_begin(*Context), + E = OID->instmeth_end(*Context); I != E; ++I) eol_needed = true, PrintObjCMethodDecl(*I); Out << (eol_needed ? "\n@end\n" : "@end\n"); @@ -408,8 +418,10 @@ void DeclPrinter::PrintObjCInterfaceDecl(ObjCInterfaceDecl *OID) { void DeclPrinter::PrintObjCProtocolDecl(ObjCProtocolDecl *PID) { Out << "@protocol " << PID->getNameAsString() << '\n'; - for (ObjCProtocolDecl::prop_iterator I = PID->prop_begin(), - E = PID->prop_end(); I != E; ++I) + // FIXME: Should not use a NULL DeclContext! + ASTContext *Context = 0; + for (ObjCProtocolDecl::prop_iterator I = PID->prop_begin(*Context), + E = PID->prop_end(*Context); I != E; ++I) PrintObjCPropertyDecl(*I); Out << "@end\n"; // FIXME: implement the rest... @@ -427,12 +439,14 @@ void DeclPrinter::PrintObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) { } void DeclPrinter::PrintObjCCategoryDecl(ObjCCategoryDecl *PID) { + // FIXME: Should not use a NULL DeclContext! + ASTContext *Context = 0; Out << "@interface " << PID->getClassInterface()->getNameAsString() << '(' << PID->getNameAsString() << ");\n"; // Output property declarations. - for (ObjCCategoryDecl::prop_iterator I = PID->prop_begin(), - E = PID->prop_end(); I != E; ++I) + for (ObjCCategoryDecl::prop_iterator I = PID->prop_begin(*Context), + E = PID->prop_end(*Context); I != E; ++I) PrintObjCPropertyDecl(*I); Out << "@end\n"; @@ -867,7 +881,10 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC, Out << "\n"; // Print decls in the DeclContext. - for (DeclContext::decl_iterator I = DC->decls_begin(), E = DC->decls_end(); + // FIXME: Should not use a NULL DeclContext! + ASTContext *Context = 0; + for (DeclContext::decl_iterator I = DC->decls_begin(*Context), + E = DC->decls_end(*Context); I != E; ++I) { for (unsigned i = 0; i < Indentation; ++i) Out << " "; diff --git a/clang/tools/clang-cc/ASTConsumers.h b/clang/tools/clang-cc/ASTConsumers.h index fd8416da0ea..970dfecada0 100644 --- a/clang/tools/clang-cc/ASTConsumers.h +++ b/clang/tools/clang-cc/ASTConsumers.h @@ -67,7 +67,7 @@ ASTConsumer *CreateSerializationTest(Diagnostic &Diags, ASTConsumer *CreateASTSerializer(const std::string& InFile, const std::string& EmitDir, Diagnostic &Diags); - + ASTConsumer *CreateBlockRewriter(const std::string& InFile, const std::string& OutFile, Diagnostic &Diags, diff --git a/clang/tools/clang-cc/AnalysisConsumer.cpp b/clang/tools/clang-cc/AnalysisConsumer.cpp index bc385934047..c39b1bcf3ff 100644 --- a/clang/tools/clang-cc/AnalysisConsumer.cpp +++ b/clang/tools/clang-cc/AnalysisConsumer.cpp @@ -459,7 +459,8 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) { if (!ObjCImplementationActions.empty()) { TranslationUnitDecl *TUD = C.getTranslationUnitDecl(); - for (DeclContext::decl_iterator I = TUD->decls_begin(),E = TUD->decls_end(); + for (DeclContext::decl_iterator I = TUD->decls_begin(C), + E = TUD->decls_end(C); I != E; ++I) if (ObjCImplementationDecl* ID = dyn_cast<ObjCImplementationDecl>(*I)) HandleCode(ID, 0, ObjCImplementationActions); diff --git a/clang/tools/clang-cc/RewriteBlocks.cpp b/clang/tools/clang-cc/RewriteBlocks.cpp index f3029136618..3610da63c5b 100644 --- a/clang/tools/clang-cc/RewriteBlocks.cpp +++ b/clang/tools/clang-cc/RewriteBlocks.cpp @@ -310,29 +310,41 @@ void RewriteBlocks::RewriteMethodDecl(ObjCMethodDecl *Method) { } void RewriteBlocks::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) { - for (ObjCInterfaceDecl::instmeth_iterator I = ClassDecl->instmeth_begin(), - E = ClassDecl->instmeth_end(); I != E; ++I) + for (ObjCInterfaceDecl::instmeth_iterator + I = ClassDecl->instmeth_begin(*Context), + E = ClassDecl->instmeth_end(*Context); + I != E; ++I) RewriteMethodDecl(*I); - for (ObjCInterfaceDecl::classmeth_iterator I = ClassDecl->classmeth_begin(), - E = ClassDecl->classmeth_end(); I != E; ++I) + for (ObjCInterfaceDecl::classmeth_iterator + I = ClassDecl->classmeth_begin(*Context), + E = ClassDecl->classmeth_end(*Context); + I != E; ++I) RewriteMethodDecl(*I); } void RewriteBlocks::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) { - for (ObjCCategoryDecl::instmeth_iterator I = CatDecl->instmeth_begin(), - E = CatDecl->instmeth_end(); I != E; ++I) + for (ObjCCategoryDecl::instmeth_iterator + I = CatDecl->instmeth_begin(*Context), + E = CatDecl->instmeth_end(*Context); + I != E; ++I) RewriteMethodDecl(*I); - for (ObjCCategoryDecl::classmeth_iterator I = CatDecl->classmeth_begin(), - E = CatDecl->classmeth_end(); I != E; ++I) + for (ObjCCategoryDecl::classmeth_iterator + I = CatDecl->classmeth_begin(*Context), + E = CatDecl->classmeth_end(*Context); + I != E; ++I) RewriteMethodDecl(*I); } void RewriteBlocks::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) { - for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(), - E = PDecl->instmeth_end(); I != E; ++I) + for (ObjCProtocolDecl::instmeth_iterator + I = PDecl->instmeth_begin(*Context), + E = PDecl->instmeth_end(*Context); + I != E; ++I) RewriteMethodDecl(*I); - for (ObjCProtocolDecl::classmeth_iterator I = PDecl->classmeth_begin(), - E = PDecl->classmeth_end(); I != E; ++I) + for (ObjCProtocolDecl::classmeth_iterator + I = PDecl->classmeth_begin(*Context), + E = PDecl->classmeth_end(*Context); + I != E; ++I) RewriteMethodDecl(*I); } @@ -1138,8 +1150,8 @@ void RewriteBlocks::HandleDeclInMainFile(Decl *D) { } if (RecordDecl *RD = dyn_cast<RecordDecl>(D)) { if (RD->isDefinition()) { - for (RecordDecl::field_iterator i = RD->field_begin(), - e = RD->field_end(); i != e; ++i) { + for (RecordDecl::field_iterator i = RD->field_begin(*Context), + e = RD->field_end(*Context); i != e; ++i) { FieldDecl *FD = *i; if (isBlockPointerType(FD->getType())) RewriteBlockPointerDecl(FD); diff --git a/clang/tools/clang-cc/RewriteObjC.cpp b/clang/tools/clang-cc/RewriteObjC.cpp index 5fcecc60307..44c0eb3d985 100644 --- a/clang/tools/clang-cc/RewriteObjC.cpp +++ b/clang/tools/clang-cc/RewriteObjC.cpp @@ -584,8 +584,8 @@ void RewriteObjC::HandleTopLevelSingleDecl(Decl *D) { RewriteForwardProtocolDecl(FP); } else if (LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(D)) { // Recurse into linkage specifications - for (DeclContext::decl_iterator DI = LSD->decls_begin(), - DIEnd = LSD->decls_end(); + for (DeclContext::decl_iterator DI = LSD->decls_begin(*Context), + DIEnd = LSD->decls_end(*Context); DI != DIEnd; ++DI) HandleTopLevelSingleDecl(*DI); } @@ -791,11 +791,15 @@ void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) { // FIXME: handle category headers that are declared across multiple lines. ReplaceText(LocStart, 0, "// ", 3); - for (ObjCCategoryDecl::instmeth_iterator I = CatDecl->instmeth_begin(), - E = CatDecl->instmeth_end(); I != E; ++I) + for (ObjCCategoryDecl::instmeth_iterator + I = CatDecl->instmeth_begin(*Context), + E = CatDecl->instmeth_end(*Context); + I != E; ++I) RewriteMethodDeclaration(*I); - for (ObjCCategoryDecl::classmeth_iterator I = CatDecl->classmeth_begin(), - E = CatDecl->classmeth_end(); I != E; ++I) + for (ObjCCategoryDecl::classmeth_iterator + I = CatDecl->classmeth_begin(*Context), + E = CatDecl->classmeth_end(*Context); + I != E; ++I) RewriteMethodDeclaration(*I); // Lastly, comment out the @end. @@ -810,11 +814,15 @@ void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) { // FIXME: handle protocol headers that are declared across multiple lines. ReplaceText(LocStart, 0, "// ", 3); - for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(), - E = PDecl->instmeth_end(); I != E; ++I) + for (ObjCProtocolDecl::instmeth_iterator + I = PDecl->instmeth_begin(*Context), + E = PDecl->instmeth_end(*Context); + I != E; ++I) RewriteMethodDeclaration(*I); - for (ObjCProtocolDecl::classmeth_iterator I = PDecl->classmeth_begin(), - E = PDecl->classmeth_end(); I != E; ++I) + for (ObjCProtocolDecl::classmeth_iterator + I = PDecl->classmeth_begin(*Context), + E = PDecl->classmeth_end(*Context); + I != E; ++I) RewriteMethodDeclaration(*I); // Lastly, comment out the @end. @@ -1038,14 +1046,18 @@ void RewriteObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) { } SynthesizeObjCInternalStruct(ClassDecl, ResultStr); - for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(), - E = ClassDecl->prop_end(); I != E; ++I) + for (ObjCInterfaceDecl::prop_iterator I = ClassDecl->prop_begin(*Context), + E = ClassDecl->prop_end(*Context); I != E; ++I) RewriteProperty(*I); - for (ObjCInterfaceDecl::instmeth_iterator I = ClassDecl->instmeth_begin(), - E = ClassDecl->instmeth_end(); I != E; ++I) + for (ObjCInterfaceDecl::instmeth_iterator + I = ClassDecl->instmeth_begin(*Context), + E = ClassDecl->instmeth_end(*Context); + I != E; ++I) RewriteMethodDeclaration(*I); - for (ObjCInterfaceDecl::classmeth_iterator I = ClassDecl->classmeth_begin(), - E = ClassDecl->classmeth_end(); I != E; ++I) + for (ObjCInterfaceDecl::classmeth_iterator + I = ClassDecl->classmeth_begin(*Context), + E = ClassDecl->classmeth_end(*Context); + I != E; ++I) RewriteMethodDeclaration(*I); // Lastly, comment out the @end. @@ -1136,7 +1148,9 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV, dyn_cast<ObjCInterfaceType>(pType->getPointeeType()); // lookup which class implements the instance variable. ObjCInterfaceDecl *clsDeclared = 0; - iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(), clsDeclared); + iFaceDecl->getDecl()->lookupInstanceVariable(*Context, + D->getIdentifier(), + clsDeclared); assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class"); // Synthesize an explicit cast to gain access to the ivar. @@ -1180,7 +1194,9 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV, ObjCInterfaceType *iFaceDecl = dyn_cast<ObjCInterfaceType>(pType->getPointeeType()); // lookup which class implements the instance variable. ObjCInterfaceDecl *clsDeclared = 0; - iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(), clsDeclared); + iFaceDecl->getDecl()->lookupInstanceVariable(*Context, + D->getIdentifier(), + clsDeclared); assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class"); // Synthesize an explicit cast to gain access to the ivar. @@ -2187,7 +2203,8 @@ QualType RewriteObjC::getSuperStructType() { // Create fields for (unsigned i = 0; i < 2; ++i) { - SuperStructDecl->addDecl(FieldDecl::Create(*Context, SuperStructDecl, + SuperStructDecl->addDecl(*Context, + FieldDecl::Create(*Context, SuperStructDecl, SourceLocation(), 0, FieldTypes[i], /*BitWidth=*/0, /*Mutable=*/false)); @@ -2216,7 +2233,8 @@ QualType RewriteObjC::getConstantStringStructType() { // Create fields for (unsigned i = 0; i < 4; ++i) { - ConstantStringDecl->addDecl(FieldDecl::Create(*Context, + ConstantStringDecl->addDecl(*Context, + FieldDecl::Create(*Context, ConstantStringDecl, SourceLocation(), 0, FieldTypes[i], @@ -2867,9 +2885,9 @@ RewriteObjCProtocolsMetaData(const ObjCList<ObjCProtocolDecl> &Protocols, if (ObjCSynthesizedProtocols.count(PDecl)) continue; - if (PDecl->instmeth_begin() != PDecl->instmeth_end()) { - unsigned NumMethods = std::distance(PDecl->instmeth_begin(), - PDecl->instmeth_end()); + if (PDecl->instmeth_begin(*Context) != PDecl->instmeth_end(*Context)) { + unsigned NumMethods = std::distance(PDecl->instmeth_begin(*Context), + PDecl->instmeth_end(*Context)); /* struct _objc_protocol_method_list { int protocol_method_count; struct protocol_methods protocols[]; @@ -2885,9 +2903,11 @@ RewriteObjCProtocolsMetaData(const ObjCList<ObjCProtocolDecl> &Protocols, "{\n\t" + utostr(NumMethods) + "\n"; // Output instance methods declared in this protocol. - for (ObjCProtocolDecl::instmeth_iterator I = PDecl->instmeth_begin(), - E = PDecl->instmeth_end(); I != E; ++I) { - if (I == PDecl->instmeth_begin()) + for (ObjCProtocolDecl::instmeth_iterator + I = PDecl->instmeth_begin(*Context), + E = PDecl->instmeth_end(*Context); + I != E; ++I) { + if (I == PDecl->instmeth_begin(*Context)) Result += "\t ,{{(SEL)\""; else Result += "\t ,{(SEL)\""; @@ -2902,8 +2922,8 @@ RewriteObjCProtocolsMetaData(const ObjCList<ObjCProtocolDecl> &Protocols, } // Output class methods declared in this protocol. - unsigned NumMethods = std::distance(PDecl->classmeth_begin(), - PDecl->classmeth_end()); + unsigned NumMethods = std::distance(PDecl->classmeth_begin(*Context), + PDecl->classmeth_end(*Context)); if (NumMethods > 0) { /* struct _objc_protocol_method_list { int protocol_method_count; @@ -2922,9 +2942,11 @@ RewriteObjCProtocolsMetaData(const ObjCList<ObjCProtocolDecl> &Protocols, Result += "\n"; // Output instance methods declared in this protocol. - for (ObjCProtocolDecl::classmeth_iterator I = PDecl->classmeth_begin(), - E = PDecl->classmeth_end(); I != E; ++I) { - if (I == PDecl->classmeth_begin()) + for (ObjCProtocolDecl::classmeth_iterator + I = PDecl->classmeth_begin(*Context), + E = PDecl->classmeth_end(*Context); + I != E; ++I) { + if (I == PDecl->classmeth_begin(*Context)) Result += "\t ,{{(SEL)\""; else Result += "\t ,{(SEL)\""; @@ -2967,14 +2989,14 @@ RewriteObjCProtocolsMetaData(const ObjCList<ObjCProtocolDecl> &Protocols, "{\n\t0, \""; Result += PDecl->getNameAsString(); Result += "\", 0, "; - if (PDecl->instmeth_begin() != PDecl->instmeth_end()) { + if (PDecl->instmeth_begin(*Context) != PDecl->instmeth_end(*Context)) { Result += "(struct _objc_protocol_method_list *)&_OBJC_PROTOCOL_INSTANCE_METHODS_"; Result += PDecl->getNameAsString(); Result += ", "; } else Result += "0, "; - if (PDecl->classmeth_begin() != PDecl->classmeth_end()) { + if (PDecl->classmeth_begin(*Context) != PDecl->classmeth_end(*Context)) { Result += "(struct _objc_protocol_method_list *)&_OBJC_PROTOCOL_CLASS_METHODS_"; Result += PDecl->getNameAsString(); Result += "\n"; @@ -4507,8 +4529,8 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) { } if (RecordDecl *RD = dyn_cast<RecordDecl>(D)) { if (RD->isDefinition()) { - for (RecordDecl::field_iterator i = RD->field_begin(), - e = RD->field_end(); i != e; ++i) { + for (RecordDecl::field_iterator i = RD->field_begin(*Context), + e = RD->field_end(*Context); i != e; ++i) { FieldDecl *FD = *i; if (isTopLevelBlockPointerType(FD->getType())) RewriteBlockPointerDecl(FD); diff --git a/clang/tools/clang-cc/SerializationTest.cpp b/clang/tools/clang-cc/SerializationTest.cpp index b4fd8d7a758..708328db77d 100644 --- a/clang/tools/clang-cc/SerializationTest.cpp +++ b/clang/tools/clang-cc/SerializationTest.cpp @@ -72,7 +72,8 @@ bool SerializationTest::Serialize(llvm::sys::Path& Filename, llvm::OwningPtr<ASTConsumer> FilePrinter(CreateASTPrinter(&DeclPP)); TranslationUnitDecl *TUD = Ctx.getTranslationUnitDecl(); - for (DeclContext::decl_iterator I = TUD->decls_begin(), E =TUD->decls_end(); + for (DeclContext::decl_iterator I = TUD->decls_begin(Ctx), + E = TUD->decls_end(Ctx); I != E; ++I) FilePrinter->HandleTopLevelDecl(DeclGroupRef(*I)); } @@ -123,7 +124,8 @@ bool SerializationTest::Deserialize(llvm::sys::Path& Filename, llvm::OwningPtr<ASTConsumer> FilePrinter(CreateASTPrinter(&DeclPP)); TranslationUnitDecl *TUD = NewCtx->getTranslationUnitDecl(); - for (DeclContext::decl_iterator I = TUD->decls_begin(), E = TUD->decls_end(); + for (DeclContext::decl_iterator I = TUD->decls_begin(*NewCtx), + E = TUD->decls_end(*NewCtx); I != E; ++I) FilePrinter->HandleTopLevelDecl(DeclGroupRef(*I)); } diff --git a/clang/tools/clang-cc/clang-cc.cpp b/clang/tools/clang-cc/clang-cc.cpp index 3c06ea736ca..b10323ab735 100644 --- a/clang/tools/clang-cc/clang-cc.cpp +++ b/clang/tools/clang-cc/clang-cc.cpp @@ -1597,7 +1597,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, ClearSourceMgr = true; break; } - + case PrintPreprocessedInput: { // -E mode. llvm::TimeRegion Timer(ClangFrontendTimer); DoPrintPreprocessedInput(PP, OutputFile); @@ -1683,7 +1683,6 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, PP.getSelectorTable(), /* FreeMemory = */ !DisableFree)); - ParseAST(PP, Consumer.get(), *ContextOwner.get(), Stats); if (FixItRewrite) @@ -1763,7 +1762,8 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag, // FIXME: We need to inform Consumer about completed TagDecls as well. TranslationUnitDecl *TUD = Ctx->getTranslationUnitDecl(); - for (DeclContext::decl_iterator I = TUD->decls_begin(), E = TUD->decls_end(); + for (DeclContext::decl_iterator I = TUD->decls_begin(*Ctx), + E = TUD->decls_end(*Ctx); I != E; ++I) Consumer->HandleTopLevelDecl(DeclGroupRef(*I)); } |