-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable processing defines from included headers
This allows properly analyzing code which uses config headers for setting various defines which influence the code. For example for platform specific behavior. Furthermore, we fix a bug in passing defines to our pre processor.
- Loading branch information
Showing
26 changed files
with
188 additions
and
94 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,2 @@ | ||
#define MY_DEFINE | ||
#define THE_ANSWER 42 |
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,13 @@ | ||
#include "src/analyze_includes/test/data/some_defines.h" | ||
|
||
#ifdef MY_DEFINE | ||
#include "expected/include_a.h" | ||
#else | ||
#include "bad/include_a.h" | ||
#endif | ||
|
||
#if THE_ANSWER > 40 | ||
#include "expected/include_b.h" | ||
#else | ||
#include "bad/include_b.h" | ||
#endif |
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 |
---|---|---|
@@ -1,11 +1,2 @@ | ||
Defines can influence which include statements are relevant. | ||
|
||
These tests concentrate on parsing single files based on defines: | ||
|
||
- specified in the parsed file itself | ||
- coming from the C/C++ toolchain | ||
- defined by the Bazel target attributes `defines`, `local_defines` or `cops` | ||
|
||
Defines can also be imported into a file via an included header which specifies a define. | ||
This use case is not yet supported. | ||
We might add it at a later stage. | ||
In these test we ensure our preprocessor behaves as expected and chooses the desired code parts for analysis. |
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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
#ifdef SOME_DEFINE | ||
#include "test/aspect/defines/lib/a.h" | ||
#include "test/aspect/defines/support/a.h" | ||
#else | ||
#include "test/aspect/defines/lib/b.h" | ||
#include "test/aspect/defines/support/b.h" | ||
#endif | ||
|
||
#ifdef LOCAL_DEFINE | ||
#include "test/aspect/defines/lib/a.h" | ||
#include "test/aspect/defines/support/a.h" | ||
#else | ||
#include "test/aspect/defines/lib/b.h" | ||
#include "test/aspect/defines/support/b.h" | ||
#endif | ||
|
||
#if SOME_COPT > 40 | ||
#include "test/aspect/defines/lib/a.h" | ||
#include "test/aspect/defines/support/a.h" | ||
#else | ||
#include "test/aspect/defines/lib/b.h" | ||
#include "test/aspect/defines/support/b.h" | ||
#endif |
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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
#define USE_A | ||
|
||
#ifdef USE_A | ||
#include "test/aspect/defines/lib/a.h" | ||
#include "test/aspect/defines/support/a.h" | ||
#else | ||
#include "test/aspect/defines/lib/b.h" | ||
#include "test/aspect/defines/support/b.h" | ||
#endif | ||
|
||
#ifdef NON_EXISTING_DEFINE | ||
#include "test/aspect/defines/lib/b.h" | ||
#include "test/aspect/defines/support/b.h" | ||
#endif | ||
|
||
#define SOME_VALUE 42 | ||
|
||
#if SOME_VALUE > 40 | ||
#include "test/aspect/defines/lib/a.h" | ||
#include "test/aspect/defines/support/a.h" | ||
#else | ||
#include "test/aspect/defines/lib/b.h" | ||
#include "test/aspect/defines/support/b.h" | ||
#endif |
Oops, something went wrong.