Skip to content
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