Skip to content

[ItaniumDemangle][test] Factor demangler test-cases into file and sync into LLVM #137947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions libcxxabi/src/demangle/cp-to-llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,52 @@ set -e

cd $(dirname $0)
HDRS="ItaniumDemangle.h ItaniumNodes.def StringViewExtras.h Utility.h"
TEST_HDRS="DemangleTestCases.inc"
LLVM_DEMANGLE_DIR=$1
LLVM_TESTING_DIR=

if [[ -z "$LLVM_DEMANGLE_DIR" ]]; then
LLVM_DEMANGLE_DIR="../../../llvm/include/llvm/Demangle"
LLVM_TESTING_DIR=$LLVM_DEMANGLE_DIR/../Testing/Demangle
fi

if [[ ! -d "$LLVM_DEMANGLE_DIR" ]]; then
echo "No such directory: $LLVM_DEMANGLE_DIR" >&2
exit 1
fi

read -p "This will overwrite the copies of $HDRS in $LLVM_DEMANGLE_DIR; are you sure? [y/N]" -n 1 -r ANSWER
if [[ ! -d "$LLVM_TESTING_DIR" ]]; then
LLVM_TESTING_DIR="../../../llvm/include/llvm/Testing/Demangle"
fi

if [[ ! -d "$LLVM_TESTING_DIR" ]]; then
echo "No such directory: $LLVM_TESTING_DIR" >&2
exit 1
fi

read -p "This will overwrite the copies of $HDRS in $LLVM_DEMANGLE_DIR and $TEST_HDRS in $LLVM_TESTING_DIR; are you sure? [y/N]" -n 1 -r ANSWER
echo

if [[ $ANSWER =~ ^[Yy]$ ]]; then
cp -f README.txt $LLVM_DEMANGLE_DIR
chmod -w $LLVM_DEMANGLE_DIR/README.txt
for I in $HDRS ; do
rm -f $LLVM_DEMANGLE_DIR/$I
dash=$(echo "$I---------------------------" | cut -c -27 |\
sed 's|[^-]*||')
sed -e '1s|^//=*-* .*\..* -*.*=*// *$|//===--- '"$I $dash"'-*- mode:c++;eval:(read-only-mode) -*-===//|' \
-e '2s|^// *$|// Do not edit! See README.txt.|' \
$I >$LLVM_DEMANGLE_DIR/$I
chmod -w $LLVM_DEMANGLE_DIR/$I
copy_files() {
local src=$1
local dst=$2
local hdrs=$3

cp -f README.txt $dst
chmod -w $dst/README.txt

for I in $hdrs ; do
rm -f $dst/$I
dash=$(echo "$I---------------------------" | cut -c -27 |\
sed 's|[^-]*||')
sed -e '1s|^//=*-* .*\..* -*.*=*// *$|//===--- '"$I $dash"'-*- mode:c++;eval:(read-only-mode) -*-===//|' \
-e '2s|^// *$|// Do not edit! See README.txt.|' \
$src/$I >$dst/$I
chmod -w $dst/$I
done
}

if [[ $ANSWER =~ ^[Yy]$ ]]; then
copy_files . $LLVM_DEMANGLE_DIR $HDRS
copy_files ../../test $LLVM_TESTING_DIR $TEST_HDRS
fi
Loading
Loading