First Last Prev Next    No search results available
Details
: [C++] Catch blocks make unparsable labels
Bug#: 89
: tools
: llvm-g++
Status: RESOLVED
Resolution: FIXED
: All
: All
: 1.0
: P2
: normal
: 1.1

:
: compile-fail
:
:
  Show dependency tree - Show dependency graph
People
Reporter: Chris Lattner <sabre@nondot.org>
Assigned To: Chris Lattner <sabre@nondot.org>

Attachments


Note

You need to log in before you can comment on or make changes to this bug.

Related actions


Description:   Opened: 2003-11-04 19:39
This testcase:

----
#include <string>
void bar();
void test() {
  try {
    bar();
  } catch (std::string) {}
}
---

Produces a label named
'%caught.basic_string<char,std::char_traits<char>,std::allocator<char> >', which
is causing parse errors.

Testcase is test/Regression/C++Frontend/2003-11-04-CatchLabelName.cpp

-Chris
------- Comment #1 From Chris Lattner 2003-11-04 23:51:45 -------
Fixed like so:

$ diff -u llvm-representation.c~ llvm-representation.c
--- llvm-representation.c~      2003-10-29 13:19:23.000000000 -0600
+++ llvm-representation.c       2003-11-04 23:46:44.000000000 -0600
@@ -720,8 +720,26 @@
 
 llvm_basicblock *llvm_basicblock_new(const char *Name) {
   llvm_basicblock *BB = (llvm_basicblock*)xcalloc(sizeof(llvm_basicblock), 1);
-  llvm_value_construct(D2V(BB), LabelTy, Name, BasicBlock);
+  const char *NewName = xstrdup(Name), *R, *W;
+
+  /* We can't tolerate wierd characters in label names yet, so just strip them
+   * out mercilessly!
+   */
+  for (R = W = NewName; *R; ++R) {
+    char C = *R;
+    /* Only copy the char over if it is known good. */
+    if ((C >= 'a' && C <= 'z') ||
+        (C >= 'A' && C <= 'Z') ||
+        (C >= '0' && C <= '9') ||
+        C == '.' || C == '_') {
+      *W++ = C;
+    }
+  }
+  *W = *R;  /* Copy the null terminator */
+
+  llvm_value_construct(D2V(BB), LabelTy, NewName, BasicBlock);
   llvm_ilist_construct(llvm_instruction, BB->Instructions);
+  free(NewName);
   return BB;
 }

First Last Prev Next    No search results available