Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[analyzer] Enable analysis of WebKit "unified sources".
Normally the analyzer begins path-sensitive analysis from functions within the main file, even though the path is allowed to go through any functions within the translation unit. When a recent version of WebKit is compiled, the "unified sources" technique is used, that assumes #including multiple code files into a single main file. Such file would have no functions defined in it, so the analyzer wouldn't be able to find any entry points for path-sensitive analysis. This patch pattern-matches unified file names that are similar to those used by WebKit and allows the analyzer to find entry points in the included code files. A more aggressive/generic approach is being planned as well. Differential Revision: https://reviews.llvm.org/D45839 llvm-svn: 330876
- Loading branch information
Showing
9 changed files
with
99 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s | ||
|
||
// There should still be diagnostics within included files. | ||
#include "source1.cpp" | ||
#include "source2.cpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class ContainerInHeaderFile { | ||
class Iterator { | ||
}; | ||
|
||
public: | ||
Iterator begin() const; | ||
Iterator end() const; | ||
|
||
int method() { return 0; } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s | ||
|
||
// This test tests that the warning is here when it is included from | ||
// the unified sources file. The run-line in this file is there | ||
// only to suppress LIT warning for the complete lack of run-line. | ||
int foo(int x) { | ||
if (x) {} | ||
return 1 / x; // expected-warning{{}} | ||
} | ||
|
||
// Let's see if the container inlining heuristic still works. | ||
#include "container.h" | ||
int testContainerMethodInHeaderFile(ContainerInHeaderFile Cont) { | ||
return 1 / Cont.method(); // no-warning | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s | ||
|
||
// This test tests that the warning is here when it is included from | ||
// the unified sources file. The run-line in this file is there | ||
// only to suppress LIT warning for the complete lack of run-line. | ||
int testNullDereference() { | ||
int *x = 0; | ||
return *x; // expected-warning{{}} | ||
} | ||
|
||
// Let's see if the container inlining heuristic still works. | ||
class ContainerInCodeFile { | ||
class Iterator { | ||
}; | ||
|
||
public: | ||
Iterator begin() const; | ||
Iterator end() const; | ||
|
||
int method() { return 0; } | ||
}; | ||
|
||
int testContainerMethodInCodeFile(ContainerInCodeFile Cont) { | ||
return 1 / Cont.method(); // expected-warning{{}} | ||
} |