[llvm] f33274c - [llvm-cxxfilt] Replace isalnum with isAlnum from StringExtras

Tomasz Miąsko via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 1 23:57:39 PDT 2021


Author: Tomasz Miąsko
Date: 2021-10-02T08:54:04+02:00
New Revision: f33274c7bf44af652f1b52f1566552620f72ce1f

URL: https://github.com/llvm/llvm-project/commit/f33274c7bf44af652f1b52f1566552620f72ce1f
DIFF: https://github.com/llvm/llvm-project/commit/f33274c7bf44af652f1b52f1566552620f72ce1f.diff

LOG: [llvm-cxxfilt] Replace isalnum with isAlnum from StringExtras

D104366 introduced a new llvm-cxxfilt test with non-ASCII characters,
which caused a failure on llvm-clang-x86_64-expensive-checks-win
builder, with a stack trace suggesting issue in a call to isalnum.

The argument to isalnum should be either EOF or a value that is
representable in the type unsigned char. The llvm-cxxfilt does not
perform a cast from char to unsigned char before the call, so the
value might be out of valid range.

Replace the call to isalnum with isAlnum from StringExtras, which takes
a char as the argument. This also makes the check independent of the
current locale.

Differential Revision: https://reviews.llvm.org/D110986

Added: 
    

Modified: 
    llvm/test/tools/llvm-cxxfilt/delimiters.test
    llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-cxxfilt/delimiters.test b/llvm/test/tools/llvm-cxxfilt/delimiters.test
index 1c5b0e352a74c..c1eb05d0e8567 100644
--- a/llvm/test/tools/llvm-cxxfilt/delimiters.test
+++ b/llvm/test/tools/llvm-cxxfilt/delimiters.test
@@ -27,6 +27,7 @@ RUN:      "\"_Z3Foo{\"" \
 RUN:      '_Z3Foo|'   \
 RUN:      '_Z3Foo}'   \
 RUN:      '_Z3Foo~,,' \
+RUN:      '_Z3Foo⦙_Z3Bar' \
 RUN:      '_Z3Foo,,_Z3Bar::_Z3Baz  _Z3Foo,_Z3Bar:_Z3Baz' \
 RUN:      '_Z3Foo$ ._Z3Foo' | llvm-cxxfilt -n | FileCheck %s
 
@@ -59,5 +60,6 @@ CHECK: Foo{
 CHECK: Foo|
 CHECK: Foo}
 CHECK: Foo~,,
+CHECK: Foo⦙Bar
 CHECK: Foo,,Bar::Baz  Foo,Bar:Baz
 CHECK: _Z3Foo$ ._Z3Foo

diff  --git a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
index d8bf8dbccce0f..0a6d4b50ecf37 100644
--- a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
+++ b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
@@ -128,7 +128,7 @@ static void SplitStringDelims(
 static bool IsLegalItaniumChar(char C) {
   // Itanium CXX ABI [External Names]p5.1.1:
   // '$' and '.' in mangled names are reserved for private implementations.
-  return isalnum(C) || C == '.' || C == '$' || C == '_';
+  return isAlnum(C) || C == '.' || C == '$' || C == '_';
 }
 
 // If 'Split' is true, then 'Mangled' is broken into individual words and each


        


More information about the llvm-commits mailing list