<div><div>Hi:</div><div>I'm building a small tool on top of LLVM Core Library.</div><div><br></div><div>```</div><div>LLVMContext context;</div><div>SMDiagnostic diag;</div><div>Module *M = parseIRFile(InputIR, diag, context).get();</div><div>  if (M == nullptr) {</div><div>    diag.print("LLVM", errs());</div><div>    exit(-1);</div><div>  }</div><div>  assert(M->isMaterialized() && "Module not materialized!");</div><div>  PointerType *ArrayPtrTy =</div><div>      M->getTypeByName("struct._Array")->getPointerTo();</div><div>```</div><div><br></div><div>However this piece of code crashes at Module::getTypeByName because getContext().pImpl is NULL pointer. Other similar issues include Module::getTypeByName results in a NULL pointer dereference because TheTable in StringMap is not allocated/initialized.</div><div><br></div><div>It would be great if someone could show me what's the correct way to initialize all this kind of internal data structures so I could focus on my tool's logic</div></div><div><br></div><div><includetail><!--<![endif]--></includetail></div>