MCPcopy Create free account
hub / github.com/csmith-project/csmith / OutputStructUnion

Function OutputStructUnion

src/Type.cpp:1849–1928  ·  view source on GitHub ↗

--------------------------------------------------------------------- print struct definition (fields etc) *************************************************************/

Source from the content-addressed store, hash-verified

1847/* print struct definition (fields etc)
1848 *************************************************************/
1849void OutputStructUnion(Type* type, std::ostream &out)
1850{
1851 size_t i;
1852 // sanity check
1853 assert (type->is_aggregate());
1854
1855 if (!type->printed) {
1856 // output dependent structs, if any
1857 for (i=0; i<type->fields.size(); i++) {
1858 if (type->fields[i]->is_aggregate()) {
1859 OutputStructUnion((Type*)type->fields[i], out);
1860 }
1861 }
1862 // output myself
1863 if (type->packed_) {
1864 if (!CGOptions::ccomp()) {
1865 out << "#pragma pack(push)";
1866 really_outputln(out);
1867 }
1868 out << "#pragma pack(1)";
1869 really_outputln(out);
1870 }
1871 type->Output(out);
1872 out << " {";
1873 really_outputln(out);
1874
1875 assert(type->fields.size() == type->qfers_.size());
1876 unsigned int j = 0;
1877 for (i=0; i<type->fields.size(); i++) {
1878 out << " ";
1879 const Type *field = type->fields[i];
1880 bool is_bitfield = type->is_bitfield(i);
1881 if (is_bitfield) {
1882 assert(field->eType == eSimple);
1883 type->qfers_[i].OutputFirstQuals(out);
1884 if (field->simple_type == eInt)
1885 out << "signed";
1886 else if (field->simple_type == eUInt)
1887 out << "unsigned";
1888 else
1889 assert(0);
1890 int length = type->bitfields_length_[i];
1891 assert(length >= 0);
1892 if (length == 0)
1893 out << " : ";
1894 else
1895 out << " f" << j++ << " : ";
1896 out << length << ";";
1897 }
1898 else {
1899 type->qfers_[i].output_qualified_type(field, out);
1900 out << " f" << j++ << ";";
1901 }
1902 really_outputln(out);
1903 }
1904
1905 if (type->eType == eStruct){
1906 OutputStructAssignOp(type, out, false);

Callers 2

OutputStructUnionsMethod · 0.85

Calls 9

really_outputlnFunction · 0.85
OutputStructAssignOpFunction · 0.85
OutputUnionAssignOpsFunction · 0.85
sizeMethod · 0.80
is_bitfieldMethod · 0.80
OutputFirstQualsMethod · 0.80
is_aggregateMethod · 0.45
OutputMethod · 0.45
output_qualified_typeMethod · 0.45

Tested by

no test coverage detected