MCSymbol: Make print() robust against empty names
authorMatthias Braun <matze@braunis.de>
Wed, 27 May 2015 05:12:37 +0000 (05:12 +0000)
committerMatthias Braun <matze@braunis.de>
Wed, 27 May 2015 05:12:37 +0000 (05:12 +0000)
This shouldn't happen, but it's nice not to abort when printing broken machine
functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238287 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCSymbol.cpp

index 0009decef9b41d580bf4bd79290f856645b4cb1d..b2034eaf51727cb1e643f51a33511b91d5d5ab2d 100644 (file)
@@ -50,6 +50,10 @@ void MCSymbol::print(raw_ostream &OS) const {
   // some targets support quoting names with funny characters.  If the name
   // contains a funny character, then print it quoted.
   StringRef Name = getName();
+  if (Name.empty()) {
+    OS << "\"\"";
+    return;
+  }
   if (!NameNeedsQuoting(Name)) {
     OS << Name;
     return;