示例#1
0
  // Regression test: we used to assert here.
  // PR16664 and PR18159
  void testConsistencyNested(int i) {
    extern bool compute(bool);

    if (i == 5 && (i == 4 || i == 5 || check(NoReturnDtor())))
      clang_analyzer_eval(true);  // expected-warning{{TRUE}}

    if (i == 5 && (i == 4 || i == 5 || check(NoReturnDtor())))
      clang_analyzer_eval(true);  // expected-warning{{TRUE}}

    if (i != 5)
      return;

    if (compute(i == 5 &&
                (i == 4 || compute(true) ||
                 compute(i == 5 && (i == 4 || check(NoReturnDtor()))))) ||
        i != 4) {
      clang_analyzer_eval(true);  // expected-warning{{TRUE}}
    }

    if (compute(i == 5 &&
                (i == 4 || i == 4 ||
                 compute(i == 5 && (i == 4 || check(NoReturnDtor()))))) ||
        i != 4) {
      clang_analyzer_eval(true);  // no warning, unreachable code
    }
  }
示例#2
0
  void testConsistencyIf(int i) {
    if (i == 5 && (i == 4 || i == 5 || check(NoReturnDtor())))
      clang_analyzer_eval(true); // expected-warning{{TRUE}}

    if (i != 5)
      return;
    if (i == 5 && (i == 4 || check(NoReturnDtor()) || i == 5)) {
      clang_analyzer_eval(true); // no warning, unreachable code
    }
  }
示例#3
0
  void testConsistencyTernary(int i) {
    (i == 5 && (i == 4 || check(NoReturnDtor()) || i == 5)) ? 1 : 0;

    clang_analyzer_eval(true);  // expected-warning{{TRUE}}

    if (i != 5)
      return;

    (i == 5 && (i == 4 || check(NoReturnDtor()) || i == 5)) ? 1 : 0;

    clang_analyzer_eval(true); // no warning, unreachable code
  }
示例#4
0
 void testLoop() {
   for (int i = 0; i < 10; ++i) {
     if (i < 3 && (i >= 2 || check(NoReturnDtor()))) {
       clang_analyzer_eval(true);  // no warning, unreachable code
     }
   }
 }
示例#5
0
 // PR16664 and PR18159
 void testConsistencyNestedComplexNestedBranch(bool value) {
   if (value) {
     if (!value || (!value || check(NoReturnDtor()) || value)) {
       clang_analyzer_eval(true);  // no warning, unreachable code
     }
   }
 }
示例#6
0
 // PR16664 and PR18159
 void testConsistencyNestedWarning(bool value) {
   if (value) {
     if (!value || value || check(NoReturnDtor())) {
       clang_analyzer_eval(true); // expected-warning{{TRUE}}
     }
   }
 }
示例#7
0
 bool testRecursiveFrames(bool isInner) {
   if (isInner ||
       (clang_analyzer_warnIfReached(), false) || // expected-warning{{REACHABLE}}
       check(NoReturnDtor()) ||
       testRecursiveFrames(true)) {
     clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
   }
 }
示例#8
0
 // PR16664 and PR18159
 void testConsistencyNestedVariableModification(bool value) {
   bool other = true;
   if (value) {
     if (!other || !value || (other = false) || check(NoReturnDtor()) ||
         !other) {
       clang_analyzer_eval(true);  // no warning, unreachable code
     }
   }
 }
示例#9
0
 void testLambdas() {
   []() { check(NoReturnDtor()); } != nullptr || check(Dtor());
 }
示例#10
0
 void testTernaryFalseBranchReached(bool value) {
   value ? check(NoReturnDtor()) :
           clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
 }
示例#11
0
 void testTernaryIgnoreNoreturnBranch(bool value) {
   if (value) {
     bool b = !value && !value ? check(NoReturnDtor()) : true;
     clang_analyzer_eval(true);  // expected-warning{{TRUE}}
   }
 }
示例#12
0
 void testTernaryNoReturnFalseBranch(bool value) {
   if (value) {
     bool b = !value && !value ? true : check(NoReturnDtor());
     clang_analyzer_eval(true);  // no warning, unreachable code
   }
 }
示例#13
0
 void testTernaryNoReturnTrueBranch(bool value) {
   if (value) {
     bool b = value && (value ? check(NoReturnDtor()) : true);
     clang_analyzer_eval(true);  // no warning, unreachable code
   }
 }
示例#14
0
 void noReturnInline(int **x) {
   NoReturnDtor();
 }
示例#15
0
 void noReturnTemp(int *x) {
   if (! x) NoReturnDtor();
   *x = 47; // no warning
 }