From fb97b03e42d397405f617be0252be83e77a66f6e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 2 Dec 2007 01:40:18 +0000 Subject: [PATCH] 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 ) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44501 91177308-0d34-0410-b5e6-96231b3b80d8 --- CodeGen/CGStmt.cpp | 10 ++++++++-- CodeGen/CodeGenModule.cpp | 5 +++-- CodeGen/CodeGenModule.h | 5 ++++- CodeGen/ModuleBuilder.cpp | 5 +++-- Driver/ASTConsumers.cpp | 2 +- include/clang/CodeGen/ModuleBuilder.h | 4 +++- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/CodeGen/CGStmt.cpp b/CodeGen/CGStmt.cpp index b010e81009..d41d2dec69 100644 --- a/CodeGen/CGStmt.cpp +++ b/CodeGen/CGStmt.cpp @@ -19,6 +19,9 @@ using namespace clang; using namespace CodeGen; +#include "clang/Basic/Diagnostic.h" +#include "CodeGenModule.h" + //===----------------------------------------------------------------------===// // Statement Emission //===----------------------------------------------------------------------===// @@ -38,8 +41,11 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { 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; diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp index 171a70c5a0..54009b0e42 100644 --- a/CodeGen/CodeGenModule.cpp +++ b/CodeGen/CodeGenModule.cpp @@ -26,8 +26,9 @@ using namespace CodeGen; 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) { diff --git a/CodeGen/CodeGenModule.h b/CodeGen/CodeGenModule.h index 9278e68641..c4867c0bfa 100644 --- a/CodeGen/CodeGenModule.h +++ b/CodeGen/CodeGenModule.h @@ -34,6 +34,7 @@ namespace clang { class ValueDecl; class FileVarDecl; struct LangOptions; + class Diagnostic; namespace CodeGen { @@ -44,6 +45,7 @@ class CodeGenModule { const LangOptions &Features; llvm::Module &TheModule; const llvm::TargetData &TheTargetData; + Diagnostic &Diags; CodeGenTypes Types; llvm::Function *MemCpyFn; @@ -56,12 +58,13 @@ class CodeGenModule { std::vector 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); diff --git a/CodeGen/ModuleBuilder.cpp b/CodeGen/ModuleBuilder.cpp index adc1878196..9d2874984a 100644 --- a/CodeGen/ModuleBuilder.cpp +++ b/CodeGen/ModuleBuilder.cpp @@ -19,8 +19,9 @@ using namespace clang; /// 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) { diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp index a3d837fb2c..da9cf64b3c 100644 --- a/Driver/ASTConsumers.cpp +++ b/Driver/ASTConsumers.cpp @@ -570,7 +570,7 @@ namespace { 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) { diff --git a/include/clang/CodeGen/ModuleBuilder.h b/include/clang/CodeGen/ModuleBuilder.h index 9ca3648337..2ab7d2dc2b 100644 --- a/include/clang/CodeGen/ModuleBuilder.h +++ b/include/clang/CodeGen/ModuleBuilder.h @@ -24,13 +24,15 @@ namespace clang { 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. /// -- 2.40.0