using namespace clang;
using namespace CodeGen;
+#include "clang/Basic/Diagnostic.h"
+#include "CodeGenModule.h"
+
//===----------------------------------------------------------------------===//
// Statement Emission
//===----------------------------------------------------------------------===//
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;
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) {
class ValueDecl;
class FileVarDecl;
struct LangOptions;
+ class Diagnostic;
namespace CodeGen {
const LangOptions &Features;
llvm::Module &TheModule;
const llvm::TargetData &TheTargetData;
+ Diagnostic &Diags;
CodeGenTypes Types;
llvm::Function *MemCpyFn;
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);
/// 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) {
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) {
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.
///