-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SR-7165. Excise <iostream> from reflection #27081
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
Conversation
This is reasonable. Removing the header usage isn't a bad idea. It would be nice if the two changes were squashed into a single change. |
@swift-ci please test |
Build failed |
Build failed |
I haven't read this PR (don't treat this as a review), but I want to give a big plus one to the effort. I wanted to look into this some time ago but had other pressing things to look at. |
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.
Looks overall pretty reasonable. Two things:
-
I did a git grep with your branch and found there are still iostream includes. Can you remove any that are unnecessary as a result of this patch? Seems like some are in the locations you have been touching.
-
Is there a reason you changed that CMakeLists.txt line I pointed out? Can you remove?
@@ -1,3 +1,5 @@ | |||
append("-undefined dynamic_lookup" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) |
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.
Whats with this part of the change here?
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.
Ugh, somehow I missed this part of the change. This seems wrong; I think that it is trying to work around the missing LLVMSupport
linkage. Thank you @gottesmm for catching this oversight.
Specifically:
|
Okay, I'll squash my changes but at first, can someone help me resolve linking error on Linux platform? I just thought that |
|
@ismetanin, I think that we are missing a link against LLVMSupport. Letting this be undefined is a bad idea, we don't want to end up in the case where the symbol is unresolved at load time. |
@compnerd |
@jrose-apple oh, okay, I’ll try to fix it Sent with GitHawk |
@jrose-apple Hey, I'm here again and I have a question. Instead Instead And should I replace the use of |
That looks reasonable to me. I think the use of plain |
@jrose-apple I reasearced a bit and found that in some places we use |
Hm. @jckarter, what do you think? (Too bad C++ doesn't have a built-in std::ostream subclass that takes a |
I would personally just use |
@jrose-apple @jckarter I've just replaced iostreams with |
include/swift/Demangling/Demangler.h
Outdated
@@ -24,7 +24,7 @@ | |||
//#define NODE_FACTORY_DEBUGGING | |||
|
|||
#ifdef NODE_FACTORY_DEBUGGING | |||
#include <iostream> | |||
#include <ostream> |
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.
Can <ostream>
be removed as well?
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.
Done
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.
Thanks!
@swift-ci Please test |
Build failed |
Build failed |
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.
Thanks for sticking with this! A few comments.
include/swift/Demangling/Demangler.h
Outdated
@@ -141,8 +133,7 @@ class NodeFactory { | |||
size_t ObjectSize = NumObjects * sizeof(T); | |||
CurPtr = align(CurPtr, alignof(T)); | |||
#ifdef NODE_FACTORY_DEBUGGING | |||
std::cerr << indent() << "alloc " << ObjectSize << ", CurPtr = " | |||
<< (void *)CurPtr << "\n"; | |||
fprintf(stderr, "%salloc%zu, CurPtr = %p\n", indent().c_str(), ObjectSize, (void *)CurPtr) |
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.
Nitpick: space after "alloc" got lost here.
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.
Fixed
unsigned Indent; | ||
|
||
std::ostream &indent(unsigned Amount) { | ||
FILE * &indent(unsigned Amount) { |
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.
These should all drop the &
. (They probably shouldn't return anything at this point since they're not going to be chained.)
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.
Done
printField("alignment", std::to_string(TI.getAlignment())); | ||
printField("stride", std::to_string(TI.getStride())); | ||
printField("num_extra_inhabitants", std::to_string(TI.getNumExtraInhabitants())); | ||
printField("bitwise_takable", TI.isBitwiseTakable() ? "1" : "0"); |
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.
Might as well go with "true" and "false" if you're changing it anyway.
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.
Done
for (auto &fieldRef : *descriptor.getLocalBuffer()) { | ||
auto field = descriptor.getField(fieldRef); | ||
auto fieldName = getTypeRefString(readTypeRef(field, field->FieldName)); | ||
OS << std::string(fieldName.begin(), fieldName.end()); | ||
fprintf(file, "%s", std::string(fieldName.begin(), fieldName.end()).c_str()); |
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.
@jckarter Is this necessary or is the field name going to be null-terminated?
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.
It would be better to use fprintf(file, "%*s", (int)fieldName.size(), fieldName.data())
.
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.
Fixed ✅
fprintf(file, "Size: %s\n", std::to_string(descriptor->Size).c_str()); | ||
fprintf(file, "Alignment: %s:\n", std::to_string(descriptor->getAlignment()).c_str()); | ||
fprintf(file, "Stride: %s:\n", std::to_string(descriptor->Stride).c_str()); | ||
fprintf(file, "NumExtraInhabitants: %s:\n", std::to_string(descriptor->NumExtraInhabitants).c_str()); |
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.
These are all numeric values, why go through %s
?
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.
Oh, my bad 🧐
I'll fix it
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.
Done
Can someone help me with fails on @swift-ci? I'm confused with error |
You can ignore it - the job gets restarted if you look at the status checks. I don't know why it fails initially most of the time; might have something to do with force pushes/rebase or maybe something's wrong with the bot. |
@swift-ci Please test |
Build failed |
Build failed |
@swift-ci Please test |
Oops, that's my fault for wanting it to say "true". |
Build failed |
Sorry, looks like some of the tests need to be updated for the change in the way we present bool output:
|
Build failed |
Sorry, I didn't retest after PR fixes, now everything should be ok 👌 Could someone help me with the development process? |
@swift-ci Please test |
Build failed |
Build failed |
Replace iostream with raw_ostream to follow LLVM Coding Standards.
Related to closed PR of @nafu
Resolves SR-7165.