Forráskód Böngészése

Improve validation error message formatting (#2301)

Chiefly, prints the instruction causing the validation failure rather than its address.
Tristan Labelle 6 éve
szülő
commit
146ce5ba0b
1 módosított fájl, 26 hozzáadás és 5 törlés
  1. 26 5
      lib/HLSL/DxilValidation.cpp

+ 26 - 5
lib/HLSL/DxilValidation.cpp

@@ -721,16 +721,31 @@ struct ValidationContext {
       }
       LastRuleEmit = Rule;
       LastDebugLocEmit = L;
+    }
+
+    // Print the error header matched by IDE regexes
+    DiagPrinter << "error: ";
 
+    // Print the debug location, if any, as matched by IDE regexes
+    if (L) {
       L.print(DiagStream());
-      DiagPrinter << ' ';
-      return true;
+      DiagPrinter << ": ";
     }
+
     BasicBlock *BB = I->getParent();
     Function *F = BB->getParent();
 
-    DiagPrinter << "at " << I;
-    DiagPrinter << " inside block ";
+    // Printthe instruction
+    std::string InstrStr;
+    raw_string_ostream InstrStream(InstrStr);
+    I->print(InstrStream);
+    InstrStream.flush();
+    StringRef InstrStrRef = InstrStr;
+    InstrStrRef = InstrStrRef.ltrim(); // Ignore indentation
+    DiagPrinter << "at '" << InstrStrRef << "'";
+
+    // Print the parent block name
+    DiagPrinter << " in block '";
     if (!BB->getName().empty()) {
       DiagPrinter << BB->getName();
     }
@@ -741,10 +756,16 @@ struct ValidationContext {
         if (BB == &(*i)) {
           break;
         }
+        idx++;
       }
       DiagPrinter << "#" << idx;
     }
-    DiagPrinter << " of function " << *F << ' ';
+    DiagPrinter << "'";
+
+    // Print the function name
+    DiagPrinter << " of function '" << F->getName() << "': ";
+
+    // Parent will print the message
     return true;
   }