Skip to content

Commit d797473

Browse files
committed
[swift-demangle] Warn when passed an empty argument.
We already have a warning when a single _ is passed, which catches the case where someone passes _$someMangledName and the shell expands it as a variable. But sometimes people do this without the leading underscore. Detect and warn about that case too.
1 parent 69cbb45 commit d797473

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/swift-demangle/swift-demangle.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ int main(int argc, char **argv) {
403403
"is quoted or escaped.\n";
404404
continue;
405405
}
406+
if (name == "") {
407+
llvm::errs() << "warning: empty input symbol is likely the result of "
408+
"variable expansion by the shell. Ensure the argument "
409+
"is quoted or escaped.\n";
410+
continue;
411+
}
406412
if (name.startswith("S") || name.startswith("s") ) {
407413
std::string correctedName = std::string("$") + name.str();
408414
demangle(llvm::outs(), correctedName, DCtx, options);

0 commit comments

Comments
 (0)