[cfe-commits] r44501 - in /cfe/trunk: CodeGen/CGStmt.cpp CodeGen/CodeGenModule.cpp CodeGen/CodeGenModule.h CodeGen/ModuleBuilder.cpp Driver/ASTConsumers.cpp include/clang/CodeGen/ModuleBuilder.h

Chris Lattner sabre at nondot.org
Sat Dec 1 17:40:18 PST 2007


Author: lattner
Date: Sat Dec  1 19:40:18 2007
New Revision: 44501

URL: http://llvm.org/viewvc/llvm-project?rev=44501&view=rev
Log:
Warn about unsupported codegen with the diags machinery, giving us:

t.c:3322:5: warning: cannot codegen this yet
    __asm__ ("bswap   %0" : "+r" (_data));
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

instead of:

Unimplemented stmt!
(AsmStmt 0x80eaa0 <t.c:3331:5, line:3334:28>)


Modified:
    cfe/trunk/CodeGen/CGStmt.cpp
    cfe/trunk/CodeGen/CodeGenModule.cpp
    cfe/trunk/CodeGen/CodeGenModule.h
    cfe/trunk/CodeGen/ModuleBuilder.cpp
    cfe/trunk/Driver/ASTConsumers.cpp
    cfe/trunk/include/clang/CodeGen/ModuleBuilder.h

Modified: cfe/trunk/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGStmt.cpp?rev=44501&r1=44500&r2=44501&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/CodeGen/CGStmt.cpp Sat Dec  1 19:40:18 2007
@@ -19,6 +19,9 @@
 using namespace clang;
 using namespace CodeGen;
 
+#include "clang/Basic/Diagnostic.h"
+#include "CodeGenModule.h"
+
 //===----------------------------------------------------------------------===//
 //                              Statement Emission
 //===----------------------------------------------------------------------===//
@@ -38,8 +41,11 @@
       else
         EmitAggExpr(E, 0, false);
     } else {
-      fprintf(stderr, "Unimplemented stmt!\n");
-      S->dump(getContext().SourceMgr);
+      
+      unsigned DiagID = CGM.getDiags().getCustomDiagID(Diagnostic::Warning, 
+                                                  "cannot codegen this yet");
+      SourceRange Range = S->getSourceRange();
+      CGM.getDiags().Report(S->getLocStart(), DiagID, 0, 0, &Range, 1);
     }
     break;
   case Stmt::NullStmtClass: break;

Modified: cfe/trunk/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=44501&r1=44500&r2=44501&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenModule.cpp Sat Dec  1 19:40:18 2007
@@ -26,8 +26,9 @@
 
 
 CodeGenModule::CodeGenModule(ASTContext &C, const LangOptions &LO,
-                             llvm::Module &M, const llvm::TargetData &TD)
-  : Context(C), Features(LO), TheModule(M), TheTargetData(TD),
+                             llvm::Module &M, const llvm::TargetData &TD,
+                             Diagnostic &diags)
+  : Context(C), Features(LO), TheModule(M), TheTargetData(TD), Diags(diags),
     Types(C, M, TD), MemCpyFn(0), CFConstantStringClassRef(0) {}
 
 llvm::Constant *CodeGenModule::GetAddrOfGlobalDecl(const ValueDecl *D) {

Modified: cfe/trunk/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.h?rev=44501&r1=44500&r2=44501&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/CodeGen/CodeGenModule.h Sat Dec  1 19:40:18 2007
@@ -34,6 +34,7 @@
   class ValueDecl;
   class FileVarDecl;
   struct LangOptions;
+  class Diagnostic;
     
 namespace CodeGen {
 
@@ -44,6 +45,7 @@
   const LangOptions &Features;
   llvm::Module &TheModule;
   const llvm::TargetData &TheTargetData;
+  Diagnostic &Diags;
   CodeGenTypes Types;
 
   llvm::Function *MemCpyFn;
@@ -56,12 +58,13 @@
   std::vector<llvm::Function *> BuiltinFunctions;
 public:
   CodeGenModule(ASTContext &C, const LangOptions &Features, llvm::Module &M, 
-                const llvm::TargetData &TD);
+                const llvm::TargetData &TD, Diagnostic &Diags);
   
   ASTContext &getContext() const { return Context; }
   const LangOptions &getLangOptions() const { return Features; }
   llvm::Module &getModule() const { return TheModule; }
   CodeGenTypes &getTypes() { return Types; }
+  Diagnostic &getDiags() const { return Diags; }
   
   llvm::Constant *GetAddrOfGlobalDecl(const ValueDecl *D);
   

Modified: cfe/trunk/CodeGen/ModuleBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/ModuleBuilder.cpp?rev=44501&r1=44500&r2=44501&view=diff

==============================================================================
--- cfe/trunk/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/CodeGen/ModuleBuilder.cpp Sat Dec  1 19:40:18 2007
@@ -19,8 +19,9 @@
 /// Init - Create an ModuleBuilder with the specified ASTContext.
 clang::CodeGen::CodeGenModule *
 clang::CodeGen::Init(ASTContext &Context, const LangOptions &Features, 
-                     llvm::Module &M, const llvm::TargetData &TD) {
-  return new CodeGenModule(Context, Features, M, TD);
+                     llvm::Module &M, const llvm::TargetData &TD, 
+                     Diagnostic &Diags) {
+  return new CodeGenModule(Context, Features, M, TD, Diags);
 }
 
 void clang::CodeGen::Terminate(CodeGenModule *B) {

Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=44501&r1=44500&r2=44501&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Sat Dec  1 19:40:18 2007
@@ -570,7 +570,7 @@
       M = new llvm::Module("foo");
       M->setTargetTriple(Ctx->Target.getTargetTriple());
       TD = new llvm::TargetData(Ctx->Target.getTargetDescription());
-      Builder = CodeGen::Init(Context, Features, *M, *TD);
+      Builder = CodeGen::Init(Context, Features, *M, *TD, Diags);
     }
     
     virtual void HandleTopLevelDecl(Decl *D) {

Modified: cfe/trunk/include/clang/CodeGen/ModuleBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/ModuleBuilder.h?rev=44501&r1=44500&r2=44501&view=diff

==============================================================================
--- cfe/trunk/include/clang/CodeGen/ModuleBuilder.h (original)
+++ cfe/trunk/include/clang/CodeGen/ModuleBuilder.h Sat Dec  1 19:40:18 2007
@@ -24,13 +24,15 @@
   class FunctionDecl;
   class FileVarDecl;
   struct LangOptions;
+  class Diagnostic;
 
 namespace CodeGen {
   class CodeGenModule;
   
   /// Init - Create an ModuleBuilder with the specified ASTContext.
   CodeGenModule *Init(ASTContext &Context, const LangOptions &Features,
-                      llvm::Module &M, const llvm::TargetData &TD);
+                      llvm::Module &M, const llvm::TargetData &TD,
+                      Diagnostic &Diags);
   
   /// CodeGenFunction - Convert the AST node for a FunctionDecl into LLVM.
   ///





More information about the cfe-commits mailing list