Skip to content

[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

Merged

Conversation

kitasuke
Copy link
Contributor

@kitasuke kitasuke commented Mar 4, 2018

I defined new string constants in String.h for Builtin so that we could replace string value with it.

  • Added BUILTIN_NAME
  • Added BUILTIN_TYPE_NAMEs

It 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:L797

Here is a link for the discussion.
#14959 (comment)

@omochi
Copy link
Contributor

omochi commented Mar 4, 2018

I think we should fix TypeReconstruction.cpp too.

@kitasuke kitasuke changed the title Use BUILTIN_NAME constant for module name [Gardening] Use BUILTIN_NAME constant for module name Mar 5, 2018
@harlanhaskins
Copy link
Contributor

@swift-ci please smoke test

@kitasuke kitasuke changed the title [Gardening] Use BUILTIN_NAME constant for module name [Gardening] Use string constants for Builtin module and type names Mar 12, 2018
@kitasuke
Copy link
Contributor Author

@harlanhaskins I also added BUILTIN_TYPE_NAMEs. Let me know if I should break constant string file into specific one for type name.

Copy link
Contributor

@harlanhaskins harlanhaskins left a 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!

@@ -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 + ".";
Copy link
Contributor

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.”

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Fixed it.

@kitasuke
Copy link
Contributor Author

@harlanhaskins Addressed your feedback! Would be appreciated if you could review again!

Copy link
Contributor

@harlanhaskins harlanhaskins left a 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 😓

/// 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";
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@kitasuke kitasuke force-pushed the replace-of-builtin-string-with-constant branch from 5690487 to d433428 Compare March 25, 2018 00:25
@kitasuke
Copy link
Contributor Author

I squashed and pushed the commit, thanks for reviewing!

@harlanhaskins
Copy link
Contributor

LGTM!

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 29788f6 into swiftlang:master Mar 25, 2018
@harlanhaskins
Copy link
Contributor

Thanks @kitasuke!

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.

4 participants