Skip to content

Not support anonymous union in struct #317 #391

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
merged 7 commits into from
Aug 24, 2022

Conversation

alexey-utkin
Copy link
Collaborator

No description provided.

@alexey-utkin alexey-utkin linked an issue Aug 22, 2022 that may be closed by this pull request
- better tests for union printer
- less divergent between struct and union
@alexey-utkin alexey-utkin requested a review from ladisgin August 23, 2022 06:34
Copy link
Collaborator Author

@alexey-utkin alexey-utkin left a comment

Choose a reason for hiding this comment

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

Fixing
[PERF] UTBot consumes CPU in spinlocks #382

while (holdLockFlag[callbackName].exchange(true, std::memory_order_acquire)) {
std::this_thread::yield();
std::this_thread::sleep_for(100ms);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

[PERF] UTBot consumes CPU in spinlocks #382

std::shared_ptr<PrimitiveValueView> primitiveView(const std::vector<char> &byteArray,
const types::Type &type,
size_t offset,
size_t len);
static std::shared_ptr<EnumValueView> enumView(const std::vector<char> &byteArray,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Group enum and struct-like. Seems they need to be joined in the future.

@@ -50,7 +47,7 @@ void KleeConstraintsPrinter::genConstraintsForPrimitive(const ConstraintsState &
if (!cons.empty()) {
strFunctionCall(PrinterUtils::KLEE_PREFER_CEX, { state.paramName, cons });
} else {
ss << TAB_N() << "// No constraints for " << state.curElement << NL;
ss << LINE_INDENT() << "// No constraints for " << state.curElement << NL;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indent can include the inline comment, so rename it to indent.

ConstraintsState newState = { state.paramName,
access,
field.type,
isStruct ? state.endString : false,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is still essential difference between struct and union. Need to be investigated (in progress).

break;
case TypeKind::OBJECT_POINTER:
if (types::TypesHandler::isArrayOfPointersToFunction(field.type)) {
genStubForStructFunctionPointerArray(state.curElement, field.name, stubFunctionName);
genStubForStructFunctionPointerArray(state.curElement, field,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no more just by name access. That leads to unpredictable errors.

@@ -705,17 +705,33 @@ std::string printer::MultiLinePrinter::print(TestsPrinter *printer,
std::stringstream structuredValuesWithPrefixes;
structuredValuesWithPrefixes << "{" << NL;
++printer->tabsDepth;

int longestFieldIndexForUnionInit = view->getLongestFieldIndexForUnionInit();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So now we are printing all the fields in union, but commenting all, except the longest.

@@ -864,12 +834,6 @@ types::TypesHandler::isSupportedType(const Type &type, TypeUsage usage, int dept
return getTypeKind(type) == TypeKind::UNKNOWN;
}
},
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the subject of bugfix.

@@ -894,14 +858,10 @@ types::TypesHandler::isSupportedType(const Type &type, TypeUsage usage, int dept
});
};

if (isUnion(type)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Has no direct influence to the tests

@@ -954,15 +914,10 @@ types::TypesHandler::isSupportedType(const Type &type, TypeUsage usage, int dept
return false;
});
};
if (isStruct(type)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Has no direct influence to the tests

std::string types::EnumInfo::getEntryName(const std::string &value, utbot::Language language) {
auto const& entry = valuesToEntries[value];
std::string types::EnumInfo::getEntryName(const std::string &value, utbot::Language language) const {
const EnumEntry &entry = valuesToEntries.at(value);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Has no const operator[], so changed.

- fix for Syntax_Test.Union_With_Pointer_Test
: AbstractValueView(std::move(subViews)),
entryValue(PrinterUtils::convertBytesToUnion(typeName, rawDataView->getEntryValue(nullptr))) {
}
//UnionValueView::UnionValueView(
Copy link
Member

Choose a reason for hiding this comment

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

delete unused code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

structuredValuesWithPrefixes << printer->LINE_INDENT() << view->getFieldPrefix(i)
<< sview->getEntryValue(printer);
}
else {
Copy link
Member

Choose a reason for hiding this comment

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

fold the line

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

struct StructInfo: TypeInfo {
std::vector<Field> fields{};

int longestFieldIndexForUnionInit;
Copy link
Member

Choose a reason for hiding this comment

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

try make size_t

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

* @return UnionInfo for given union.
*/
UnionInfo getUnionInfo(const Type&) const;

bool isStruct(uint64_t id) const;
Copy link
Member

Choose a reason for hiding this comment

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

rename to isStructLike

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@alexey-utkin alexey-utkin merged commit ca3734f into main Aug 24, 2022
@alexey-utkin alexey-utkin deleted the alexey-utkin/unnamedUnion branch August 24, 2022 16:08
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.

Not support anonymous union in struct
2 participants