Skip to content

demangler: Support the future final mangling prefix $S #10588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2017

Conversation

eeckstein
Copy link
Contributor

As it’s not clear if we will need underscores, the demangler accepts $S and _$S.
Note that a double underscore is handled by the demangler client.

rdar://problem/32251811

As it’s not clear if we will need underscores, the demangler accepts $S and _$S.
Note that a double underscore is handled by the demangler client.

rdar://problem/32251811
@eeckstein
Copy link
Contributor Author

@swift-ci Please smoke test and merge

@eeckstein
Copy link
Contributor Author

@swift-ci Please smoke test macos

/// Returns the length of the swift mangling prefix of the \p SymbolName.
///
/// Returns 0 if \p SymbolName is not a mangled swift (>= swift 4.x) name.
int getManglingPrefixLength(const char *mangledName);
Copy link
Contributor

@huonw huonw Jun 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be Optional<StringRef> getManglingPrefix(StringRef), where None represents no prefix and a StringRef is the actual data of the prefix? It seems like a lot of the users are thinking in those terms anyway e.g. the use in swift-demangler below could be:

auto prefix = swift::Demangle::getManglingPrefix(remangled);
if (!name.startswith(*prefix)) {
    auto namePrefix = swift::Demangle::getManglingPrefix(name);
    remangled =  namePrefix + remangled.substr(prefix->size());
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could, but I don't see the benefit of it.
I don't see the need of Optional because the None case could simply be an empty StringRef. But then, why returning the (char_ptr, size) (= StringRef) and not just the size if the char-ptr is not used? We would introduce the implicit assumption that the returned StringRef is always the prefix of the argument. Well, I prefer to just return the size.

@eeckstein eeckstein merged commit df26c47 into swiftlang:master Jun 26, 2017
@eeckstein eeckstein deleted the mangling-prefix branch June 26, 2017 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants