[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
This commit is contained in:
Nathan Sidwell 2022-01-24 04:14:47 -08:00
parent 38ffea9b4c
commit 897d1bb659
4 changed files with 24 additions and 10 deletions

View File

@ -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 <<EOF
// Do not edit! -*- read-only -*-
// See README.txt for instructions
EOF
chmod -w $LLVM_DEMANGLE_DIR/$I
done
fi

View File

@ -1,3 +1,5 @@
// Do not edit! -*- read-only -*-
// See README.txt for instructions
//===------------------------- ItaniumDemangle.h ----------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@ -11,8 +13,8 @@
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_DEMANGLE_ITANIUMDEMANGLE_H
#define LLVM_DEMANGLE_ITANIUMDEMANGLE_H
#ifndef DEMANGLE_ITANIUMDEMANGLE_H
#define DEMANGLE_ITANIUMDEMANGLE_H
// FIXME: (possibly) incomplete list of features that clang mangles that this
// file does not yet support:
@ -5749,4 +5751,4 @@ struct ManglingParser : AbstractManglingParser<ManglingParser<Alloc>, Alloc> {
DEMANGLE_NAMESPACE_END
#endif // LLVM_DEMANGLE_ITANIUMDEMANGLE_H
#endif // DEMANGLE_ITANIUMDEMANGLE_H

View File

@ -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 <cassert>

View File

@ -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 <array>