[PATCH] D71189: [Parser] Don't crash on MS assembly if target desc/asm parser isn't linked in.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 9 03:27:54 PST 2019


sammccall marked 4 inline comments as done.
sammccall added inline comments.


================
Comment at: clang/lib/Parse/ParseStmtAsm.cpp:591
   std::unique_ptr<llvm::MCAsmInfo> MAI(
       TheTarget->createMCAsmInfo(*MRI, TT, MCOptions));
   // Get the instruction descriptor.
----------------
kadircet wrote:
> is it ok for MRI to be dereferenced here?
No :-( Fixed with yet more code
(In practice it didn't cause a problem because all these are null or not-null, and the function doesn't do anything if they're null)


================
Comment at: clang/lib/Parse/ParseStmtAsm.cpp:599
+  if (!MRI || !MAI || !MII | !MOFI || !STI) {
+    Diag(AsmLoc, diag::err_msasm_unable_to_create_target)
+        << "target MC unavailable";
----------------
kadircet wrote:
> the original bail out(no target or no tokens) doesn't seem to be emitting diags, are we sure we want to emit diags here? (same for the one below)
For no tokens there's no diagnostic required, the empty statement is correct.

Missing target does have a diagnostic: the if statement on line 555 will either set Target to non-null or emit a diagnostic.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71189/new/

https://reviews.llvm.org/D71189





More information about the cfe-commits mailing list