[cfe-commits] r82432 - in /cfe/trunk: test/Frontend/ast-codegen.c tools/clang-cc/clang-cc.cpp

Daniel Dunbar daniel at zuster.org
Sun Sep 20 20:03:57 PDT 2009


Author: ddunbar
Date: Sun Sep 20 22:03:56 2009
New Revision: 82432

URL: http://llvm.org/viewvc/llvm-project?rev=82432&view=rev
Log:
Switch ProcessASTInputFile to still use ParseAST.
 - 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.

Modified:
    cfe/trunk/test/Frontend/ast-codegen.c
    cfe/trunk/tools/clang-cc/clang-cc.cpp

Modified: cfe/trunk/test/Frontend/ast-codegen.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/ast-codegen.c?rev=82432&r1=82431&r2=82432&view=diff

==============================================================================
--- cfe/trunk/test/Frontend/ast-codegen.c (original)
+++ cfe/trunk/test/Frontend/ast-codegen.c Sun Sep 20 22:03:56 2009
@@ -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() {
+}

Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=82432&r1=82431&r2=82432&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Sun Sep 20 22:03:56 2009
@@ -2181,14 +2181,17 @@
     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.





More information about the cfe-commits mailing list