[demangler][NFC] Small cleanups and sync
Some precursor work to adding module demangling.
* some mismatched comment and code in the demangler
* a const fn was not marked thusly
* we use std::islower. A direct range check is smaller code (no function call),
and we know we're in ASCII-land and later in that same function make the same
assumption about upper-case contiguity. Heck, maybe just drop the switch's
precondition and rely on the optimizer to do its thing?
* the directory is cloned in two places, which had gotten out of sync.
Differential Revision: https://reviews.llvm.org/D117800
GitOrigin-RevId: 8105e404f186c6f31e08185b37f81e6da904f6d7
diff --git a/src/demangle/ItaniumDemangle.h b/src/demangle/ItaniumDemangle.h
index 85e1511..b25139d 100644
--- a/src/demangle/ItaniumDemangle.h
+++ b/src/demangle/ItaniumDemangle.h
@@ -310,7 +310,7 @@
printRight(OB);
}
- // Print the "left" side of this Node into OutputString.
+ // Print the "left" side of this Node into OutputBuffer.
virtual void printLeft(OutputBuffer &) const = 0;
// Print the "right". This distinction is necessary to represent C++ types
@@ -1210,7 +1210,8 @@
class ParameterPack final : public Node {
NodeArray Data;
- // Setup OutputString for a pack expansion unless we're already expanding one.
+ // Setup OutputBuffer for a pack expansion, unless we're already expanding
+ // one.
void initializePackExpansion(OutputBuffer &OB) const {
if (OB.CurrentPackMax == std::numeric_limits<unsigned>::max()) {
OB.CurrentPackMax = static_cast<unsigned>(Data.size());
@@ -2473,7 +2474,7 @@
char consume() { return First != Last ? *First++ : '\0'; }
- char look(unsigned Lookahead = 0) {
+ char look(unsigned Lookahead = 0) const {
if (static_cast<size_t>(Last - First) <= Lookahead)
return '\0';
return First[Lookahead];
@@ -5437,7 +5438,7 @@
if (!consumeIf('S'))
return nullptr;
- if (std::islower(look())) {
+ if (look() >= 'a' && look() <= 'z') {
Node *SpecialSub;
switch (look()) {
case 'a':