|
1 | 1 | // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.Stream,debug.ExprInspection -verify %s
|
2 | 2 |
|
3 | 3 | #include "Inputs/system-header-simulator.h"
|
4 |
| -#include "Inputs/system-header-simulator-for-valist.h" |
5 | 4 |
|
6 | 5 | void clang_analyzer_eval(int);
|
7 |
| -void clang_analyzer_dump_char(char); |
8 |
| -void clang_analyzer_dump_int(int); |
9 | 6 |
|
10 | 7 | void check_fread(void) {
|
11 | 8 | FILE *fp = tmpfile();
|
@@ -363,85 +360,3 @@ void fflush_on_open_failed_stream(void) {
|
363 | 360 | }
|
364 | 361 | fclose(F);
|
365 | 362 | }
|
366 |
| - |
367 |
| -void test_fscanf_escape() { |
368 |
| - FILE *F1 = tmpfile(); |
369 |
| - if (!F1) |
370 |
| - return; |
371 |
| - |
372 |
| - int a = 48; |
373 |
| - unsigned b = 127; |
374 |
| - char buffer[] = "FSCANF"; // 70 83 67 65 78 70 |
375 |
| - |
376 |
| - clang_analyzer_dump_int(a); // expected-warning {{48 S32b}} |
377 |
| - clang_analyzer_dump_int(b); // expected-warning {{127 S32b}} |
378 |
| - clang_analyzer_dump_char(buffer[2]); // expected-warning {{67 S8b}} |
379 |
| - |
380 |
| - int ret = fscanf(F1, "%d %u %s", &a, &b, buffer); |
381 |
| - if (ret != EOF) { |
382 |
| - clang_analyzer_dump_int(a); // expected-warning {{conj_$}} |
383 |
| - clang_analyzer_dump_int(b); // expected-warning {{conj_$}} |
384 |
| - clang_analyzer_dump_char(buffer[2]); // expected-warning {{derived_$}} |
385 |
| - } else { |
386 |
| - clang_analyzer_dump_int(a); // expected-warning {{48 S32b}} |
387 |
| - clang_analyzer_dump_int(b); // expected-warning {{127 S32b}} |
388 |
| - clang_analyzer_dump_char(buffer[2]); // expected-warning {{67 S8b}} |
389 |
| - } |
390 |
| - |
391 |
| - if (ret != EOF) { |
392 |
| - char c = fgetc(F1); // ok |
393 |
| - } |
394 |
| - |
395 |
| - fclose(F1); |
396 |
| -} |
397 |
| - |
398 |
| -void test_fprintf() { |
399 |
| - FILE *F1 = tmpfile(); |
400 |
| - if (!F1) |
401 |
| - return; |
402 |
| - |
403 |
| - unsigned a = 42; |
404 |
| - char *output = "HELLO"; |
405 |
| - int r = fprintf(F1, "%s\t%u\n", output, a); |
406 |
| - // fprintf does not invalidate any of its input |
407 |
| - // 69 is ascii for 'E' |
408 |
| - clang_analyzer_dump_int(a); // expected-warning {{42 S32b}} |
409 |
| - clang_analyzer_dump_char(output[1]); // expected-warning {{69 S8b}} |
410 |
| - if (r < 0) { |
411 |
| - // Failure |
412 |
| - fprintf(F1, "%s\t%u\n", output, a); // expected-warning {{File position of the stream might be 'indeterminate' after a failed operation. Can cause undefined behavior}} |
413 |
| - } else { |
414 |
| - char buffer[10]; |
415 |
| - fscanf(F1, "%s", buffer); |
416 |
| - if (fseek(F1, 0, SEEK_SET) == 0) { |
417 |
| - fprintf(F1, "%s\t%u\n", buffer, a); // ok |
418 |
| - } |
419 |
| - } |
420 |
| - |
421 |
| - fclose(F1); |
422 |
| -} |
423 |
| - |
424 |
| - |
425 |
| -int test_vfscanf_inner(const char *fmt, ...) { |
426 |
| - FILE *F1 = tmpfile(); |
427 |
| - if (!F1) |
428 |
| - return EOF; |
429 |
| - |
430 |
| - va_list ap; |
431 |
| - va_start(ap, fmt); |
432 |
| - |
433 |
| - int r = vfscanf(F1, fmt, ap); |
434 |
| - |
435 |
| - fclose(F1); |
436 |
| - va_end(ap); |
437 |
| - return r; |
438 |
| -} |
439 |
| - |
440 |
| -void test_vfscanf() { |
441 |
| - int i = 42; |
442 |
| - int r = test_vfscanf_inner("%d", &i); |
443 |
| - if (r != EOF) { |
444 |
| - clang_analyzer_dump_int(i); // expected-warning {{conj_$}} |
445 |
| - // FIXME va_list "hides" the pointer to i |
446 |
| - } |
447 |
| -} |
0 commit comments