[PATCH] D138658: [DebugInfo] Protect DIFile::Source against empty string

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 26 12:01:05 PST 2022


dblaikie added a comment.

Where did this issue come up in practice? Change seems reasonable, but wouldn't mind having more context.



================
Comment at: llvm/include/llvm/IR/DebugInfoMetadata.h:658-661
+    if (!Source)
+      return None;
+    assert(*Source && "nullptr in Optional?");
+    return Optional<StringRef>((*Source)->getString());
----------------
How is this different from the previous code?  Optional::operator* would have an assert in it, right? So the previous code would've been asserting in the same places/ways, I think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138658



More information about the llvm-commits mailing list