-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Gardening] Use string constants for Builtin module and type names #14963
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
[Gardening] Use string constants for Builtin module and type names #14963
Conversation
I think we should fix |
@swift-ci please smoke test |
Delete redundant comment Use upper case for constant
@harlanhaskins I also added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once we factor out “Builtin.”
Thanks for this!
lib/AST/ASTPrinter.cpp
Outdated
@@ -3228,21 +3228,23 @@ class TypePrinter : public TypeVisitor<TypePrinter> { | |||
llvm::raw_svector_ostream UnderlyingOS(UnderlyingStrVec); | |||
T->getElementType().print(UnderlyingOS); | |||
} | |||
if (UnderlyingStrVec.startswith("Builtin.")) | |||
std::string builtin_name = BUILTIN_NAME; | |||
std::string builtin_type_prefix = builtin_name + "."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we dynamically construct this a few times, we should maybe just make a new constant for “Builtin.”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Fixed it.
@harlanhaskins Addressed your feedback! Would be appreciated if you could review again! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I meant to submit this comment several days ago 😓
include/swift/Strings.h
Outdated
/// The name of the Builtin type for Int512 | ||
static const char BUILTIN_TYPE_NAME_INT512[] = "Builtin.Int512"; | ||
/// The name of the Builtin type for Float | ||
static const char BUILTIN_TYPE_NAME_Float[] = "Builtin.Float"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be _FLOAT
vs _Float
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for trivial mistake... Fixed it.
5690487
to
d433428
Compare
I squashed and pushed the commit, thanks for reviewing! |
LGTM! @swift-ci please smoke test and merge |
Thanks @kitasuke! |
I defined new string constants in
String.h
for Builtin so that we could replace string value with it.BUILTIN_NAME
BUILTIN_TYPE_NAME
sIt might be a bit different case, but should I also apply to Builtin type name like here?https://github.com/apple/swift/blob/master/lib/IDE/TypeReconstruction.cpp#L795:L797Here is a link for the discussion.
#14959 (comment)