[clang] Add support for builtin_verbose_trap (PR #79230)

Felipe de Azevedo Piovezan via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 25 11:50:49 PST 2024


================
@@ -3416,6 +3437,27 @@ llvm::DIMacroFile *CGDebugInfo::CreateTempMacroFile(llvm::DIMacroFile *Parent,
   return DBuilder.createTempMacroFile(Parent, Line, FName);
 }
 
+llvm::DILocation *CGDebugInfo::CreateTrapFailureMessageFor(
+    llvm::DebugLoc TrapLocation, StringRef Prefix, StringRef FailureMsg) {
+  // Create debug info that describes a fake function whose name is the failure
+  // message.
+  std::string FuncName(Prefix);
+  if (!FailureMsg.empty()) {
+    // A space in the function name identifies this as not being a real function
+    // because it's not a valid symbol name.
+    FuncName += ": ";
+    FuncName += FailureMsg;
+  }
+
+  assert(FuncName.size() > 0);
+  assert(FuncName.find(' ') != std::string::npos &&
----------------
felipepiovezan wrote:

We can better express this intent by moving the assert _before_ the `if` and by rewriting it as the faster `assert(!FailureMessage.empty() || FuncName.find(' ') != npos)`

https://github.com/llvm/llvm-project/pull/79230


More information about the cfe-commits mailing list