clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name formatters.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/kfp/aldor/aldor/aldor/src -fcoverage-compilation-dir=/home/kfp/aldor/aldor/aldor/src -resource-dir /usr/local/lib/clang/18 -D PACKAGE_NAME="aldor" -D PACKAGE_TARNAME="aldor" -D PACKAGE_VERSION="1.4.0" -D PACKAGE_STRING="aldor 1.4.0" -D PACKAGE_BUGREPORT="aldor@xinutec.org" -D PACKAGE_URL="" -D PACKAGE="aldor" -D VERSION="1.4.0" -D YYTEXT_POINTER=1 -D HAVE_STDIO_H=1 -D HAVE_STDLIB_H=1 -D HAVE_STRING_H=1 -D HAVE_INTTYPES_H=1 -D HAVE_STDINT_H=1 -D HAVE_STRINGS_H=1 -D HAVE_SYS_STAT_H=1 -D HAVE_SYS_TYPES_H=1 -D HAVE_UNISTD_H=1 -D STDC_HEADERS=1 -D HAVE_LIBREADLINE=1 -D HAVE_READLINE_READLINE_H=1 -D HAVE_READLINE_HISTORY=1 -D HAVE_READLINE_HISTORY_H=1 -D USE_GLOOP_SHELL=1 -D GENERATOR_COROUTINES=0 -D HAVE_DLFCN_H=1 -D LT_OBJDIR=".libs/" -I . -D VCSVERSION="2c53e759f1e00e345f8b172e7139debda72fda13" -internal-isystem /usr/local/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-empty-body -Wno-enum-compare -Wno-missing-field-initializers -Wno-unused -Wno-unused-parameter -Wno-error=format -Wno-error=type-limits -Wno-error=strict-aliasing -Wno-sign-compare -Wno-error=shift-negative-value -Wno-error=clobbered -std=c99 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2026-01-15-223856-845667-1 -x c formatters.c
| 1 | #include "absub.h" |
| 2 | #include "axlobs.h" |
| 3 | #include "bigint.h" |
| 4 | #include "errorset.h" |
| 5 | #include "flog.h" |
| 6 | #include "format.h" |
| 7 | #include "formatters.h" |
| 8 | #include "freevar.h" |
| 9 | #include "java/javacode.h" |
| 10 | #include "ostream.h" |
| 11 | #include "sefo.h" |
| 12 | #include "susage.h" |
| 13 | #include "strops.h" |
| 14 | #include "syme.h" |
| 15 | #include "symeset.h" |
| 16 | #include "tconst.h" |
| 17 | #include "tfsat.h" |
| 18 | #include "tposs.h" |
| 19 | #include "ttable.h" |
| 20 | #include "usedef.h" |
| 21 | |
| 22 | local int tfFormatter(OStream stream, Pointer p); |
| 23 | local int tfFormatterAlt(OStream stream, int lvl, Pointer p); |
| 24 | local int tfListFormatter(OStream stream, Pointer p); |
| 25 | |
| 26 | local int tpossFormatter(OStream stream, Pointer p); |
| 27 | local int fvFormatter(OStream stream, Pointer p); |
| 28 | local int absFormatter(OStream stream, Pointer p); |
| 29 | local int abbFormatter(OStream stream, Pointer p); |
| 30 | |
| 31 | local int tconstFormatter(OStream stream, Pointer p); |
| 32 | |
| 33 | local int symeFormatter(OStream stream, Pointer p); |
| 34 | local int symeSetFormatter(OStream stream, Pointer p); |
| 35 | local int symeListFormatter(OStream stream, Pointer p); |
| 36 | local int symeListListFormatter(OStream stream, Pointer p); |
| 37 | |
| 38 | local int symeConditionFormatter(OStream stream, Pointer p); |
| 39 | local int symeConditionListFormatter(OStream stream, Pointer p); |
| 40 | |
| 41 | local int tsetFormatter(OStream stream, Pointer p); |
| 42 | |
| 43 | local int ptrFormatter(OStream stream, Pointer p); |
| 44 | local int ptrListFormatter(OStream stream, Pointer p); |
| 45 | |
| 46 | local int aintFormatter(OStream stream, Pointer p); |
| 47 | local int aintListFormatter(OStream stream, Pointer p); |
| 48 | |
| 49 | local int stringFormatter(OStream stream, Pointer p); |
| 50 | local int stringListFormatter(OStream stream, Pointer p); |
| 51 | |
| 52 | local int bintFormatter(OStream stream, Pointer p); |
| 53 | local int symbolFormatter(OStream stream, Pointer p); |
| 54 | |
| 55 | local int errorSetFormatter(OStream stream, Pointer p); |
| 56 | local int javaCodeFormatter(OStream stream, Pointer p); |
| 57 | |
| 58 | local int boolFormatter(OStream ostream, int p); |
| 59 | |
| 60 | local int slotUsageFormatter(OStream ostream, Pointer p); |
| 61 | local int slotUsageListFormatter(OStream ostream, Pointer p); |
| 62 | |
| 63 | local int udInfoFormatter(OStream ostream, Pointer p); |
| 64 | local int udInfoListFormatter(OStream ostream, Pointer p); |
| 65 | |
| 66 | void |
| 67 | fmttsInit() |
| 68 | { |
| 69 | fmtRegisterI("Bool", boolFormatter); |
| 70 | |
| 71 | fmtRegister("TForm", tfFormatter); |
| 72 | fmtRegisterAlt("TForm", tfFormatterAlt); |
| 73 | fmtRegister("TFormList", tfListFormatter); |
| 74 | |
| 75 | fmtRegister("FreeVar", fvFormatter); |
| 76 | fmtRegister("TPoss", tpossFormatter); |
| 77 | fmtRegister("AbSub", absFormatter); |
| 78 | fmtRegister("AbBind", abbFormatter); |
| 79 | |
| 80 | fmtRegister("TConst", tconstFormatter); |
| 81 | |
| 82 | fmtRegister("Syme", symeFormatter); |
| 83 | fmtRegister("SymeSet", symeSetFormatter); |
| 84 | fmtRegister("SymeList", symeListFormatter); |
| 85 | fmtRegister("SymeListList", symeListListFormatter); |
| 86 | |
| 87 | fmtRegister("SymeC", symeConditionFormatter); |
| 88 | fmtRegister("SymeCList", symeConditionListFormatter); |
| 89 | |
| 90 | fmtRegister("TSet", tsetFormatter); |
| 91 | |
| 92 | fmtRegister("Ptr", ptrFormatter); |
| 93 | fmtRegister("PtrList", ptrListFormatter); |
| 94 | |
| 95 | fmtRegister("AInt", aintFormatter); |
| 96 | fmtRegister("AIntList", aintListFormatter); |
| 97 | |
| 98 | fmtRegister("String", stringFormatter); |
| 99 | fmtRegister("StringList", stringListFormatter); |
| 100 | |
| 101 | fmtRegister("SlotUsage", slotUsageFormatter); |
| 102 | fmtRegister("SlotUsageList", slotUsageListFormatter); |
| 103 | |
| 104 | fmtRegister("UdInfo", udInfoFormatter); |
| 105 | fmtRegister("UdInfoList", udInfoListFormatter); |
| 106 | |
| 107 | fmtRegister("BInt", bintFormatter); |
| 108 | fmtRegister("Symbol", symbolFormatter); |
| 109 | |
| 110 | fmtRegister("ErrorSet", errorSetFormatter); |
| 111 | fmtRegister("JavaCode", javaCodeFormatter); |
| 112 | } |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | local int |
| 120 | symeFormatter(OStream ostream, Pointer p) |
| 121 | { |
| 122 | int c; |
| 123 | |
| 124 | c = symeOStreamWrite(ostream, p); |
| 125 | |
| 126 | return c; |
| 127 | } |
| 128 | |
| 129 | local int |
| 130 | symeConditionFormatter(OStream ostream, Pointer p) |
| 131 | { |
| 132 | Syme syme = (Syme) p; |
| 133 | int c; |
| 134 | |
| 135 | c = symeOStreamWrite(ostream, syme); |
| 136 | c += listFormat(AbSyn)(ostream, "AbSyn", (AbSynList) symeCondition(syme)); |
| 137 | |
| 138 | return c; |
| 139 | } |
| 140 | |
| 141 | local int |
| 142 | tsetFormatter(OStream ostream, Pointer p) |
| 143 | { |
| 144 | PointerTSet tset = (PointerTSet) p; |
| 145 | PointerTSetIter iter; |
| 146 | String sep = ""; |
| 147 | int c = 0; |
| 148 | |
| 149 | c += ostreamWrite(ostream, "{", -1); |
| 150 | for (iter = tsetIter(Pointer)(tset); |
| 151 | tsetIterHasNext(Pointer)(iter); |
| 152 | iter = tsetIterNext(Pointer)(iter)) { |
| 153 | c += ostreamWrite(ostream, sep, -1); |
| 154 | c += ptrFormatter(ostream, tsetIterElt(Pointer)(iter)); |
| 155 | sep = ", "; |
| 156 | } |
| 157 | |
| 158 | c += ostreamWrite(ostream, ")", -1); |
| 159 | return c; |
| 160 | } |
| 161 | |
| 162 | local int |
| 163 | ptrFormatter(OStream ostream, Pointer p) |
| 164 | { |
| 165 | char buf[20]; |
| 166 | int c; |
| 167 | |
| 168 | sprintf(buf, "%p", p); |
| 169 | c = ostreamWrite(ostream, buf, -1); |
| 170 | |
| 171 | return c; |
| 172 | } |
| 173 | |
| 174 | local int |
| 175 | aintFormatter(OStream ostream, Pointer p) |
| 176 | { |
| 177 | char buf[20]; |
| 178 | int c; |
| 179 | |
| 180 | sprintf(buf, AINT_FMT, (AInt) p); |
| 181 | c = ostreamWrite(ostream, buf, -1); |
| 182 | |
| 183 | return c; |
| 184 | } |
| 185 | |
| 186 | |
| 187 | local int |
| 188 | stringFormatter(OStream ostream, Pointer p) |
| 189 | { |
| 190 | String string = (String) p; |
| 191 | return ostreamWrite(ostream, string, -1); |
| 192 | } |
| 193 | |
| 194 | |
| 195 | local int |
| 196 | bintFormatter(OStream ostream, Pointer p) |
| 197 | { |
| 198 | String s = bintToString((BInt) p); |
| 199 | int c = ostreamWrite(ostream, s, -1); |
| 200 | strFree(s); |
| 201 | |
| 202 | return c; |
| 203 | } |
| 204 | |
| 205 | local int |
| 206 | symbolFormatter(OStream ostream, Pointer p) |
| 207 | { |
| 208 | String s = symString((Symbol) p); |
| 209 | int c = ostreamWrite(ostream, s, -1); |
| 210 | |
| 211 | return c; |
| 212 | } |
| 213 | |
| 214 | |
| 215 | local int |
| 216 | tfFormatter(OStream ostream, Pointer p) |
| 217 | { |
| 218 | int c; |
| 219 | |
| 220 | c = tformOStreamWrite(ostream, false, p); |
| 221 | |
| 222 | return c; |
| 223 | } |
| 224 | |
| 225 | local int |
| 226 | tfFormatterAlt(OStream ostream, int lvl, Pointer p) |
| 227 | { |
| 228 | int c; |
| 229 | |
| 230 | c = tformOStreamWrite(ostream, true, p); |
| 231 | |
| 232 | return c; |
| 233 | } |
| 234 | |
| 235 | local int |
| 236 | fvFormatter(OStream ostream, Pointer p) |
| 237 | { |
| 238 | FreeVar fv = (FreeVar) p; |
| 239 | int c; |
| 240 | |
| 241 | c = ostreamPrintf(ostream, "[FV: %pSymeList]", fvSymes(fv)); |
| 242 | |
| 243 | return c; |
| 244 | } |
| 245 | |
| 246 | local int |
| 247 | tpossFormatter(OStream ostream, Pointer p) |
| 248 | { |
| 249 | TPoss tp = (TPoss) p; |
| 250 | int c; |
| 251 | |
| 252 | c = tpossOStreamWrite(ostream, tp); |
| 253 | |
| 254 | return c; |
| 255 | } |
| 256 | |
| 257 | local int |
| 258 | absFormatter(OStream ostream, Pointer p) |
| 259 | { |
| 260 | AbSub tp = (AbSub) p; |
| 261 | int c; |
| 262 | |
| 263 | c = absOStreamWrite(ostream, tp); |
| 264 | |
| 265 | return c; |
| 266 | } |
| 267 | |
| 268 | |
| 269 | local int |
| 270 | abbFormatter(OStream ostream, Pointer p) |
| 271 | { |
| 272 | AbBind tp = (AbBind) p; |
| 273 | int c; |
| 274 | |
| 275 | c = abbOStreamWrite(ostream, tp); |
| 276 | |
| 277 | return c; |
| 278 | } |
| 279 | |
| 280 | local int |
| 281 | errorSetFormatter(OStream ostream, Pointer p) |
| 282 | { |
| 283 | ErrorSet errorSet = (ErrorSet) p; |
| 284 | int i; |
| 285 | |
| 286 | i = ostreamPrintf(ostream, "[E: %pStringList]", errorSet->list); |
| 287 | |
| 288 | return i; |
| 289 | } |
| 290 | |
| 291 | local int |
| 292 | javaCodeFormatter(OStream ostream, Pointer p) |
| 293 | { |
| 294 | JavaCode jco = (JavaCode) p; |
| 295 | int c; |
| 296 | |
| 297 | c = ostreamPrintf(ostream, "%pSExpr", jcoSExpr(jco)); |
| 298 | |
| 299 | return c; |
| 300 | } |
| 301 | local int |
| 302 | tconstFormatter(OStream ostream, Pointer p) |
| 303 | { |
| 304 | TConst tc = (TConst) p; |
| 305 | int i; |
| 306 | |
| 307 | i = ostreamPrintf(ostream, "[TC: %d %pTForm %pTForm]", tc->serial, tc->argv[0], tc->argv[1]); |
| 308 | |
| 309 | return i; |
| 310 | } |
| 311 | |
| 312 | local int |
| 313 | symeSetFormatter(OStream ostream, Pointer p) |
| 314 | { |
| 315 | SymeSet symeSet = (SymeSet) p; |
| 316 | return symeSetFormat(ostream, symeSet); |
| 317 | } |
| 318 | |
| 319 | local int |
| 320 | tfListFormatter(OStream ostream, Pointer p) |
| 321 | { |
| 322 | TFormList list = (TFormList) p; |
| 323 | return listFormat(TForm)(ostream, "TForm", list); |
| 324 | } |
| 325 | |
| 326 | local int |
| 327 | symeListFormatter(OStream ostream, Pointer p) |
| 328 | { |
| 329 | SymeList list = (SymeList) p; |
| 330 | return listFormat(Syme)(ostream, "Syme", list); |
| 331 | } |
| 332 | |
| 333 | local int |
| 334 | symeListListFormatter(OStream ostream, Pointer p) |
| 335 | { |
| 336 | SymeListList list = (SymeListList) p; |
| 337 | return listFormat(SymeList)(ostream, "SymeList", list); |
| 338 | } |
| 339 | |
| 340 | local int |
| 341 | symeConditionListFormatter(OStream ostream, Pointer p) |
| 342 | { |
| 343 | SymeList list = (SymeList) p; |
| 344 | return listFormat(Syme)(ostream, "SymeC", list); |
| 345 | } |
| 346 | |
| 347 | local int |
| 348 | ptrListFormatter(OStream ostream, Pointer p) |
| 349 | { |
| 350 | AbSynList list = (AbSynList) p; |
| 351 | return listFormat(AbSyn)(ostream, "Ptr", list); |
| 352 | } |
| 353 | |
| 354 | local int |
| 355 | aintListFormatter(OStream ostream, Pointer p) |
| 356 | { |
| 357 | AIntList list = (AIntList) p; |
| 358 | return listFormat(AInt)(ostream, "AInt", list); |
| 359 | } |
| 360 | |
| 361 | local int |
| 362 | stringListFormatter(OStream ostream, Pointer p) |
| 363 | { |
| 364 | StringList list = (StringList) p; |
| 365 | return listFormat(String)(ostream, "String", list); |
| 366 | } |
| 367 | |
| 368 | local int |
| 369 | boolFormatter(OStream ostream, int p) |
| 370 | { |
| 371 | Bool flg = p; |
| 372 | |
| 373 | if (flg < 0 || flg > 1) { |
| 374 | return ostreamPrintf(ostream, "Bool[%d]", flg); |
| 375 | } |
| 376 | else { |
| 377 | return ostreamPrintf(ostream, "%s", flg ? "true": "false"); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | local int |
| 382 | slotUsageFormatter(OStream ostream, Pointer p) |
| 383 | { |
| 384 | SlotUsage usage = (AInt) p; |
| 385 | return ostreamPrintf(ostream, "%d%s", suVal(usage), suIsUsed(usage) ? "R" : ""); |
| 1 | Assuming the condition is false | |
|
| |
| 3 | | Dereference of null pointer |
|
| 386 | } |
| 387 | |
| 388 | local int |
| 389 | slotUsageListFormatter(OStream ostream, Pointer p) |
| 390 | { |
| 391 | SlotUsageList list = (SlotUsageList) p; |
| 392 | return listFormat(SlotUsage)(ostream, "SlotUsage", list); |
| 393 | } |
| 394 | |
| 395 | local int |
| 396 | udInfoFormatter(OStream ostream, Pointer p) |
| 397 | { |
| 398 | UdInfo udInfo = (UdInfo) p; |
| 399 | return ostreamPrintf(ostream, "(UD %d %pFoam)", udInfo->block->label, udInfo->foam); |
| 400 | } |
| 401 | |
| 402 | local int |
| 403 | udInfoListFormatter(OStream ostream, Pointer p) |
| 404 | { |
| 405 | UdInfoList list = (UdInfoList) p; |
| 406 | return listFormat(UdInfo)(ostream, "UdInfo", list); |
| 407 | } |