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

Method build_initializer_str

src/ArrayVariable.cpp:480–505  ·  view source on GitHub ↗

build the string initializer in form of "{...}"

Source from the content-addressed store, hash-verified

478
479// build the string initializer in form of "{...}"
480string
481ArrayVariable::build_initializer_str(const vector<string>& init_strings) const
482{
483 string str, str_dimen;
484 if (CGOptions::force_non_uniform_array_init()) {
485 return build_init_recursive(0, init_strings);
486 }
487
488 for (int i=sizes.size()-1; i>=0; i--) {
489 size_t len = sizes[i];
490 str_dimen = "{";
491 for (size_t j=0; j<len; j++) {
492 // for last dimension, use magic number to choose an initial value
493 if (i == ((int)sizes.size()) - 1) {
494 unsigned int rnd_index = ((i + (j+7) * (j+13)) * 52369) % (init_strings.size());
495 str_dimen += init_strings[rnd_index];
496 } else {
497 str_dimen += str;
498 }
499 str_dimen += ((j<len-1) ? ", " : "");
500 }
501 str_dimen += "}";
502 str = str_dimen;
503 }
504 return str;
505}
506
507// --------------------------------------------------------------
508void

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected