]> granicus.if.org Git - clang/commitdiff
Switch ProcessASTInputFile to still use ParseAST.
authorDaniel Dunbar <daniel@zuster.org>
Mon, 21 Sep 2009 03:03:56 +0000 (03:03 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 21 Sep 2009 03:03:56 +0000 (03:03 +0000)
 - Currently this requires us to fake an input file.

 - This allows Sema to be keep all the logic for how to pull decls out of the external AST source and how to handle things like tentative definitions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82432 91177308-0d34-0410-b5e6-96231b3b80d8

test/Frontend/ast-codegen.c
tools/clang-cc/clang-cc.cpp

index 795be92a24d89838b7021d5da31b3cfa09782704..1fe74d4fbeb4c97167f733ab2e129124c775c46e 100644 (file)
@@ -3,3 +3,10 @@
 
 // CHECK: module asm "foo"
 __asm__("foo");
+
+// CHECK: @g0 = common global i32 0, align 4
+int g0;
+
+// CHECK: define i32 @f0()
+int f0() {
+}
index 6c2f1d6d077ba6dc8f9ba45d986f54f4fe5b4c4c..3e7c0262709977a9103d058767bde118afbf2566 100644 (file)
@@ -2181,14 +2181,17 @@ static void ProcessASTInputFile(const std::string &InFile, ProgActions PA,
     return;
   }
 
-  // Stream the input AST to the consumer.
-  Consumer->Initialize(AST->getASTContext());
-  AST->getASTContext()
-    .getExternalSource()->StartTranslationUnit(Consumer.get());
-  Consumer->HandleTranslationUnit(AST->getASTContext());
+  // Set the main file ID to an empty file.
+  //
+  // FIXME: We probably shouldn't need this, but for now this is the simplest
+  // way to reuse the logic in ParseAST.
+  const char *EmptyStr = "";
+  llvm::MemoryBuffer *SB =
+    llvm::MemoryBuffer::getMemBuffer(EmptyStr, EmptyStr, "<dummy input>");
+  AST->getSourceManager().createMainFileIDForMemBuffer(SB);
 
-  // FIXME: Tentative decls and #pragma weak aren't going to get handled
-  // correctly here.
+  // Stream the input AST to the consumer.
+  ParseAST(PP, Consumer.get(), AST->getASTContext(), Stats);
 
   // Release the consumer and the AST, in that order since the consumer may
   // perform actions in its destructor which require the context.