Open beccadax opened 3 years ago
@beccadax should this be closed? I don't see any such uses, but maybe I'm not looking carefully enough.
@beccadax I guess this should be closed.
There's still a few:
include/swift/AST/ASTPrinter.h
258: if (Opts.SkipUnderscoredKeywords && name.starts_with("_"))
lib/AST/Attr.cpp
161: return StringRef(#SPELLING).starts_with("_");
lib/Sema/TypeCheckNameLookup.cpp
556: if (correctedBase.starts_with("_") && !writtenBase.starts_with("_")) {
Though of those, it's really only the TypeCheckNameLookup.cpp
uses that could be replaced with a helper on DeclName
.
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler, Source Tooling | |Labels | Improvement, Refactoring, StarterBug | |Assignee | mohit.athwani (JIRA) | |Priority | Medium | md5: 2f01bbed82012d22d725137279f99626Issue Description:
Various parts of the compiler and SourceKit treat names with leading underscores a little bit specially. For example, SourceKit keeps these names out of code completion results.
To help with this,
Decl
has ahasUnderscoredNaming()
method which checks if the method's name starts with an underscore. However, there are half a dozen places in the compiler where we need to check if plain old identifiers are underscored, and in those places, we usually write something like:It would be better if
Identifier
, and possibly some other name-related types likeDeclName
, had a helper likeDecl
's to standardize this check.