From 897d1bb659c2a23baed8ff4881960945125c40f7 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 24 Jan 2022 04:14:47 -0800 Subject: [PATCH] [demangler] write-protect non-canonical source To try and avoid undesired changes to the non-canonical demangler sources, change the cp-to-llvm script to (a) write-protect the target files and (b) prepend 'do not edit' comments that are significant to emacs[*], and hopefully humans. Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D118008 --- libcxxabi/src/demangle/cp-to-llvm.sh | 14 +++++++++++--- llvm/include/llvm/Demangle/ItaniumDemangle.h | 8 +++++--- llvm/include/llvm/Demangle/StringView.h | 6 ++++-- llvm/include/llvm/Demangle/Utility.h | 6 ++++-- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/libcxxabi/src/demangle/cp-to-llvm.sh b/libcxxabi/src/demangle/cp-to-llvm.sh index 808abbc..e4342a0 100755 --- a/libcxxabi/src/demangle/cp-to-llvm.sh +++ b/libcxxabi/src/demangle/cp-to-llvm.sh @@ -5,7 +5,8 @@ set -e -FILES="ItaniumDemangle.h StringView.h Utility.h README.txt" +cd $(dirname $0) +HDRS="ItaniumDemangle.h StringView.h Utility.h" LLVM_DEMANGLE_DIR=$1 if [[ -z "$LLVM_DEMANGLE_DIR" ]]; then @@ -21,7 +22,14 @@ read -p "This will overwrite the copies of $FILES in $LLVM_DEMANGLE_DIR; are you echo if [[ $ANSWER =~ ^[Yy]$ ]]; then - for I in $FILES ; do - cp $I $LLVM_DEMANGLE_DIR/$I + 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 + cat - $I >$LLVM_DEMANGLE_DIR/$I <, Alloc> { DEMANGLE_NAMESPACE_END -#endif // LLVM_DEMANGLE_ITANIUMDEMANGLE_H +#endif // DEMANGLE_ITANIUMDEMANGLE_H diff --git a/llvm/include/llvm/Demangle/StringView.h b/llvm/include/llvm/Demangle/StringView.h index 6b5d01c..323282f 100644 --- a/llvm/include/llvm/Demangle/StringView.h +++ b/llvm/include/llvm/Demangle/StringView.h @@ -1,3 +1,5 @@ +// Do not edit! -*- read-only -*- +// See README.txt for instructions //===--- StringView.h -------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. @@ -10,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEMANGLE_STRINGVIEW_H -#define LLVM_DEMANGLE_STRINGVIEW_H +#ifndef DEMANGLE_STRINGVIEW_H +#define DEMANGLE_STRINGVIEW_H #include "DemangleConfig.h" #include diff --git a/llvm/include/llvm/Demangle/Utility.h b/llvm/include/llvm/Demangle/Utility.h index dcd12b0..bec019d 100644 --- a/llvm/include/llvm/Demangle/Utility.h +++ b/llvm/include/llvm/Demangle/Utility.h @@ -1,3 +1,5 @@ +// Do not edit! -*- read-only -*- +// See README.txt for instructions //===--- Utility.h ----------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. @@ -10,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEMANGLE_UTILITY_H -#define LLVM_DEMANGLE_UTILITY_H +#ifndef DEMANGLE_UTILITY_H +#define DEMANGLE_UTILITY_H #include "StringView.h" #include -- 2.7.4