-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Triple: Forward declare Twine and remove include #145685
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
| #ifndef LLVM_TARGETPARSER_TRIPLE_H | ||
| #define LLVM_TARGETPARSER_TRIPLE_H | ||
|
|
||
| #include "llvm/ADT/Twine.h" | ||
| #include "llvm/ADT/StringRef.h" | ||
| #include "llvm/Support/Compiler.h" | ||
| #include "llvm/Support/VersionTuple.h" | ||
|
|
||
|
|
@@ -20,6 +20,7 @@ | |
| #undef sparc | ||
|
|
||
| namespace llvm { | ||
| class Twine; | ||
|
|
||
| /// Triple - Helper class for working with autoconf configuration names. For | ||
| /// historical reasons, we also call these 'triples' (they used to contain | ||
|
|
@@ -349,7 +350,12 @@ class Triple { | |
| /// triple fields unknown. | ||
| Triple() = default; | ||
|
|
||
| LLVM_ABI explicit Triple(std::string &&Str); | ||
| explicit Triple(StringRef Str) : Triple(Str.str()) {} | ||
| explicit Triple(const char *Str) : Triple(std::string(Str)) {} | ||
| explicit Triple(const std::string &Str) : Triple(std::string(Str)) {} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the StringRef overload (consider dropping explicit?), is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This avoids ambiguous conversion to Twine or StringRef |
||
| LLVM_ABI explicit Triple(const Twine &Str); | ||
|
|
||
| LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr, | ||
| const Twine &OSStr); | ||
| LLVM_ABI Triple(const Twine &ArchStr, const Twine &VendorStr, | ||
|
|
||
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.
Why
std::string &&andconst std::string &rather than onestd::stringctor?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.
Avoiding string copies, most of the uses (particularly the local uses) are just producing temporary strings that can be claimed
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.
Probably my C++-foo is not strong enough, but I thought that doing a by-value pass + std::move gives you the same behavior (i.e. temporary or std::move argument doesn't get copied, everything else does).
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.
That is indeed the case. Technically there is an additional
move, OTOH that pretty much never matters, since the optimizer is almost always perfectly capable of removing that.