[demangler] Preserve line numbering in copied demangler sources
While prepending lines to the copied source files is functional, it disturbs the line numbering between the original and the copy. That makes development more awkward than necessary, as it is the copy that generally gets compiled first and emits compiler errors. This uses sed to alter the first two lines, and also emits better emacs mode setting, getting both C++ mode and read-only mode. While here, also update and clarify documentation. Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D118135
This commit is contained in:
parent
af8f1dbb43
commit
fa7834a554
|
@ -6,8 +6,10 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Generic itanium demangler library. This file has two byte-per-byte identical
|
||||
// copies in the source tree, one in libcxxabi, and the other in llvm.
|
||||
// Generic itanium demangler library.
|
||||
// There are two copies of this file in the source tree. The one under
|
||||
// libcxxabi is the original and the one under llvm is the copy. Use
|
||||
// cp-to-llvm.sh to update the copy. See README.txt for more details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
|
|
@ -4,41 +4,50 @@ Itanium Name Demangler Library
|
|||
Introduction
|
||||
------------
|
||||
|
||||
This directory contains the generic itanium name demangler library. The main
|
||||
purpose of the library is to demangle C++ symbols, i.e. convert the string
|
||||
"_Z1fv" into "f()". You can also use the CRTP base ManglingParser to perform
|
||||
some simple analysis on the mangled name, or (in LLVM) use the opaque
|
||||
ItaniumPartialDemangler to query the demangled AST.
|
||||
This directory contains the generic itanium name demangler
|
||||
library. The main purpose of the library is to demangle C++ symbols,
|
||||
i.e. convert the string "_Z1fv" into "f()". You can also use the CRTP
|
||||
base ManglingParser to perform some simple analysis on the mangled
|
||||
name, or (in LLVM) use the opaque ItaniumPartialDemangler to query the
|
||||
demangled AST.
|
||||
|
||||
Why are there multiple copies of the this library in the source tree?
|
||||
---------------------------------------------------------------------
|
||||
|
||||
This directory is mirrored between libcxxabi/demangle and
|
||||
llvm/include/llvm/Demangle. The simple reason for this is that both projects
|
||||
need to demangle symbols, but neither can depend on each other. libcxxabi needs
|
||||
the demangler to implement __cxa_demangle, which is part of the itanium ABI
|
||||
spec. LLVM needs a copy for a bunch of places, but doesn't want to use the
|
||||
system's __cxa_demangle because it a) might not be available (i.e., on Windows),
|
||||
and b) probably isn't that up-to-date on the latest language features.
|
||||
The canonical sources are in libcxxabi/src/demangle and some of the
|
||||
files are copied to llvm/include/llvm/Demangle. The simple reason for
|
||||
this comes from before the monorepo, and both [sub]projects need to
|
||||
demangle symbols, but neither can depend on each other.
|
||||
|
||||
The copy of the demangler in LLVM has some extra stuff that aren't needed in
|
||||
libcxxabi (ie, the MSVC demangler, ItaniumPartialDemangler), which depend on the
|
||||
shared generic components. Despite these differences, we want to keep the "core"
|
||||
generic demangling library identical between both copies to simplify development
|
||||
and testing.
|
||||
* libcxxabi needs the demangler to implement __cxa_demangle, which is
|
||||
part of the itanium ABI spec.
|
||||
|
||||
If you're working on the generic library, then do the work first in libcxxabi,
|
||||
then run the cp-to-llvm.sh script in src/demangle. This script takes as an
|
||||
argument the path to llvm, and re-copies the changes you made to libcxxabi over.
|
||||
Note that this script just blindly overwrites all changes to the generic library
|
||||
in llvm, so be careful.
|
||||
* LLVM needs a copy for a bunch of places, and cannot rely on the
|
||||
system's __cxa_demangle because it a) might not be available (i.e.,
|
||||
on Windows), and b) may not be up-to-date on the latest language
|
||||
features.
|
||||
|
||||
Because the core demangler needs to work in libcxxabi, everything needs to be
|
||||
declared in an anonymous namespace (see DEMANGLE_NAMESPACE_BEGIN), and you can't
|
||||
introduce any code that depends on the libcxx dylib.
|
||||
The copy of the demangler in LLVM has some extra stuff that aren't
|
||||
needed in libcxxabi (ie, the MSVC demangler, ItaniumPartialDemangler),
|
||||
which depend on the shared generic components. Despite these
|
||||
differences, we want to keep the "core" generic demangling library
|
||||
identical between both copies to simplify development and testing.
|
||||
|
||||
Hopefully, when LLVM becomes a monorepo, we can de-duplicate this code, and have
|
||||
both LLVM and libcxxabi depend on a shared demangler library.
|
||||
If you're working on the generic library, then do the work first in
|
||||
libcxxabi, then run the cp-to-llvm.sh script in src/demangle. This
|
||||
script takes as an optional argument the path to llvm, and copies the
|
||||
changes you made to libcxxabi over. Note that this script just
|
||||
blindly overwrites all changes to the generic library in llvm, so be
|
||||
careful.
|
||||
|
||||
Because the core demangler needs to work in libcxxabi, everything
|
||||
needs to be declared in an anonymous namespace (see
|
||||
DEMANGLE_NAMESPACE_BEGIN), and you can't introduce any code that
|
||||
depends on the libcxx dylib.
|
||||
|
||||
FIXME: Now that LLVM is a monorepo, it should be possible to
|
||||
de-duplicate this code, and have both LLVM and libcxxabi depend on a
|
||||
shared demangler library.
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// FIXME: Use std::string_view instead when we support C++17.
|
||||
// There are two copies of this file in the source tree. The one under
|
||||
// libcxxabi is the original and the one under llvm is the copy. Use
|
||||
// cp-to-llvm.sh to update the copy. See README.txt for more details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Provide some utility classes for use in the demangler(s).
|
||||
// Provide some utility classes for use in the demangler.
|
||||
// There are two copies of this file in the source tree. The one in libcxxabi
|
||||
// is the original and the one in llvm is the copy. Use cp-to-llvm.sh to update
|
||||
// the copy. See README.txt for more details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
|
|
@ -26,10 +26,11 @@ if [[ $ANSWER =~ ^[Yy]$ ]]; then
|
|||
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
|
||||
dash=$(echo "$I---------------------------" | cut -c -27 |\
|
||||
sed 's|[^-]*||')
|
||||
sed -e '1s|^//=*-* .*\.h -*.*=*// *$|//===--- '"$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
|
||||
done
|
||||
fi
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
// Do not edit! -*- read-only -*-
|
||||
// See README.txt for instructions
|
||||
//===------------------------- ItaniumDemangle.h ----------------*- C++ -*-===//
|
||||
//
|
||||
//===--- ItaniumDemangle.h -----------*- mode:c++;eval:(read-only-mode) -*-===//
|
||||
// Do not edit! See README.txt.
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Generic itanium demangler library. This file has two byte-per-byte identical
|
||||
// copies in the source tree, one in libcxxabi, and the other in llvm.
|
||||
// Generic itanium demangler library.
|
||||
// There are two copies of this file in the source tree. The one under
|
||||
// libcxxabi is the original and the one under llvm is the copy. Use
|
||||
// cp-to-llvm.sh to update the copy. See README.txt for more details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
|
|
@ -4,41 +4,50 @@ Itanium Name Demangler Library
|
|||
Introduction
|
||||
------------
|
||||
|
||||
This directory contains the generic itanium name demangler library. The main
|
||||
purpose of the library is to demangle C++ symbols, i.e. convert the string
|
||||
"_Z1fv" into "f()". You can also use the CRTP base ManglingParser to perform
|
||||
some simple analysis on the mangled name, or (in LLVM) use the opaque
|
||||
ItaniumPartialDemangler to query the demangled AST.
|
||||
This directory contains the generic itanium name demangler
|
||||
library. The main purpose of the library is to demangle C++ symbols,
|
||||
i.e. convert the string "_Z1fv" into "f()". You can also use the CRTP
|
||||
base ManglingParser to perform some simple analysis on the mangled
|
||||
name, or (in LLVM) use the opaque ItaniumPartialDemangler to query the
|
||||
demangled AST.
|
||||
|
||||
Why are there multiple copies of the this library in the source tree?
|
||||
---------------------------------------------------------------------
|
||||
|
||||
This directory is mirrored between libcxxabi/demangle and
|
||||
llvm/include/llvm/Demangle. The simple reason for this is that both projects
|
||||
need to demangle symbols, but neither can depend on each other. libcxxabi needs
|
||||
the demangler to implement __cxa_demangle, which is part of the itanium ABI
|
||||
spec. LLVM needs a copy for a bunch of places, but doesn't want to use the
|
||||
system's __cxa_demangle because it a) might not be available (i.e., on Windows),
|
||||
and b) probably isn't that up-to-date on the latest language features.
|
||||
The canonical sources are in libcxxabi/src/demangle and some of the
|
||||
files are copied to llvm/include/llvm/Demangle. The simple reason for
|
||||
this comes from before the monorepo, and both [sub]projects need to
|
||||
demangle symbols, but neither can depend on each other.
|
||||
|
||||
The copy of the demangler in LLVM has some extra stuff that aren't needed in
|
||||
libcxxabi (ie, the MSVC demangler, ItaniumPartialDemangler), which depend on the
|
||||
shared generic components. Despite these differences, we want to keep the "core"
|
||||
generic demangling library identical between both copies to simplify development
|
||||
and testing.
|
||||
* libcxxabi needs the demangler to implement __cxa_demangle, which is
|
||||
part of the itanium ABI spec.
|
||||
|
||||
If you're working on the generic library, then do the work first in libcxxabi,
|
||||
then run the cp-to-llvm.sh script in src/demangle. This script takes as an
|
||||
argument the path to llvm, and re-copies the changes you made to libcxxabi over.
|
||||
Note that this script just blindly overwrites all changes to the generic library
|
||||
in llvm, so be careful.
|
||||
* LLVM needs a copy for a bunch of places, and cannot rely on the
|
||||
system's __cxa_demangle because it a) might not be available (i.e.,
|
||||
on Windows), and b) may not be up-to-date on the latest language
|
||||
features.
|
||||
|
||||
Because the core demangler needs to work in libcxxabi, everything needs to be
|
||||
declared in an anonymous namespace (see DEMANGLE_NAMESPACE_BEGIN), and you can't
|
||||
introduce any code that depends on the libcxx dylib.
|
||||
The copy of the demangler in LLVM has some extra stuff that aren't
|
||||
needed in libcxxabi (ie, the MSVC demangler, ItaniumPartialDemangler),
|
||||
which depend on the shared generic components. Despite these
|
||||
differences, we want to keep the "core" generic demangling library
|
||||
identical between both copies to simplify development and testing.
|
||||
|
||||
Hopefully, when LLVM becomes a monorepo, we can de-duplicate this code, and have
|
||||
both LLVM and libcxxabi depend on a shared demangler library.
|
||||
If you're working on the generic library, then do the work first in
|
||||
libcxxabi, then run the cp-to-llvm.sh script in src/demangle. This
|
||||
script takes as an optional argument the path to llvm, and copies the
|
||||
changes you made to libcxxabi over. Note that this script just
|
||||
blindly overwrites all changes to the generic library in llvm, so be
|
||||
careful.
|
||||
|
||||
Because the core demangler needs to work in libcxxabi, everything
|
||||
needs to be declared in an anonymous namespace (see
|
||||
DEMANGLE_NAMESPACE_BEGIN), and you can't introduce any code that
|
||||
depends on the libcxx dylib.
|
||||
|
||||
FIXME: Now that LLVM is a monorepo, it should be possible to
|
||||
de-duplicate this code, and have both LLVM and libcxxabi depend on a
|
||||
shared demangler library.
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// Do not edit! -*- read-only -*-
|
||||
// See README.txt for instructions
|
||||
//===--- StringView.h -------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
//===--- StringView.h ----------------*- mode:c++;eval:(read-only-mode) -*-===//
|
||||
// Do not edit! See README.txt.
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
@ -9,6 +7,9 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// FIXME: Use std::string_view instead when we support C++17.
|
||||
// There are two copies of this file in the source tree. The one under
|
||||
// libcxxabi is the original and the one under llvm is the copy. Use
|
||||
// cp-to-llvm.sh to update the copy. See README.txt for more details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
// Do not edit! -*- read-only -*-
|
||||
// See README.txt for instructions
|
||||
//===--- Utility.h ----------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
//===--- Utility.h -------------------*- mode:c++;eval:(read-only-mode) -*-===//
|
||||
// Do not edit! See README.txt.
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Provide some utility classes for use in the demangler(s).
|
||||
// Provide some utility classes for use in the demangler.
|
||||
// There are two copies of this file in the source tree. The one in libcxxabi
|
||||
// is the original and the one in llvm is the copy. Use cp-to-llvm.sh to update
|
||||
// the copy. See README.txt for more details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
|
Loading…
Reference in New Issue