From 319a1415b88d43873717a917023774b570e8a711 Mon Sep 17 00:00:00 2001 From: Torok Edwin Date: Fri, 30 Sep 2011 12:31:57 +0000 Subject: Instead of crashing when MCAsmInfo is NULL, add an assert. This helps with porting code from 2.9 to 3.0 as TargetSelect.h changed location, and if you include the old one by accident you will trigger this assert. llvm-svn: 140848 --- llvm/lib/CodeGen/LLVMTargetMachine.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/CodeGen/LLVMTargetMachine.cpp') diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp index 8f463e2d3f9..3bd1d6071e4 100644 --- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp +++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp @@ -114,6 +114,11 @@ LLVMTargetMachine::LLVMTargetMachine(const Target &T, StringRef Triple, : TargetMachine(T, Triple, CPU, FS) { CodeGenInfo = T.createMCCodeGenInfo(Triple, RM, CM); AsmInfo = T.createMCAsmInfo(Triple); + // TargetSelect.h moved to different directory between LLVM 2.9 and 3.0, + // and if the old one gets included then MCAsmInfo will be NULL and we'd crash + // later. + // Provide the user a useful error message about whats wrong. + assert(AsmInfo && "MCAsmInfo not initialized. Make sure you include the correct TargetSelect.h!"); } bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, -- cgit v1.2.3