Fix --protect-ids when using SV classes (#2994)

A few names were incorrectly mangled, which made --protect-ids produce
invalid output when certain SV class constructs were uses. Now fixed and
added a few extra tests to catch this.
This commit is contained in:
Geza Lore
2021-05-31 13:40:22 +01:00
committed by GitHub
parent e4dcbb22e3
commit e1f9fffb42
7 changed files with 139 additions and 2 deletions
+3 -1
View File
@@ -1016,7 +1016,8 @@ public:
}
}
string protectWordsIf(const string& old, bool doIt) {
// Split at " " (for traces), "." (for scopes), or "->" (for scopes)
// Split at " " (for traces), "." (for scopes), "->" (for scopes), "::" (for superclass
// reference)
if (!(doIt && v3Global.opt.protectIds())) return old;
string out;
string::size_type start = 0;
@@ -1028,6 +1029,7 @@ public:
trySep(old, start, " ", pos /*ref*/, separator /*ref*/);
trySep(old, start, ".", pos /*ref*/, separator /*ref*/);
trySep(old, start, "->", pos /*ref*/, separator /*ref*/);
trySep(old, start, "::", pos /*ref*/, separator /*ref*/);
if (pos == string::npos) break;
out += protectIf(old.substr(start, pos - start), true) + separator;
start = pos + separator.length();