-
Notifications
You must be signed in to change notification settings - Fork 30
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
Conversation
- better tests for union printer - less divergent between struct and union
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.
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); |
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.
[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, |
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.
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; |
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.
Indent can include the inline comment, so rename it to indent.
ConstraintsState newState = { state.paramName, | ||
access, | ||
field.type, | ||
isStruct ? state.endString : false, |
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 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, |
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.
no more just by name
access. That leads to unpredictable errors.
server/src/printers/TestsPrinter.cpp
Outdated
@@ -705,17 +705,33 @@ std::string printer::MultiLinePrinter::print(TestsPrinter *printer, | |||
std::stringstream structuredValuesWithPrefixes; | |||
structuredValuesWithPrefixes << "{" << NL; | |||
++printer->tabsDepth; | |||
|
|||
int longestFieldIndexForUnionInit = view->getLongestFieldIndexForUnionInit(); |
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.
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; | |||
} | |||
}, | |||
{ |
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.
the subject of bugfix.
@@ -894,14 +858,10 @@ types::TypesHandler::isSupportedType(const Type &type, TypeUsage usage, int dept | |||
}); | |||
}; | |||
|
|||
if (isUnion(type)) { |
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.
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)) { |
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.
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); |
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.
Has no const operator[]
, so changed.
- fix for Syntax_Test.Union_With_Pointer_Test
server/src/Tests.cpp
Outdated
: AbstractValueView(std::move(subViews)), | ||
entryValue(PrinterUtils::convertBytesToUnion(typeName, rawDataView->getEntryValue(nullptr))) { | ||
} | ||
//UnionValueView::UnionValueView( |
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.
delete unused code
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
server/src/printers/TestsPrinter.cpp
Outdated
structuredValuesWithPrefixes << printer->LINE_INDENT() << view->getFieldPrefix(i) | ||
<< sview->getEntryValue(printer); | ||
} | ||
else { |
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.
fold the line
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
server/src/types/Types.h
Outdated
struct StructInfo: TypeInfo { | ||
std::vector<Field> fields{}; | ||
|
||
int longestFieldIndexForUnionInit; |
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.
try make size_t
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
server/src/types/Types.h
Outdated
* @return UnionInfo for given union. | ||
*/ | ||
UnionInfo getUnionInfo(const Type&) const; | ||
|
||
bool isStruct(uint64_t id) const; |
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.
rename to isStructLike
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
No description provided.