forked from facebook/infer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang] Sorting the fields in structs and classes. Was needed in the …
…backend and forgotten. Summary: @public Sorting the fields in structs and classes. Was needed in the backend and forgotten. Fixes the github issue facebook#90. Test Plan: Added a new test that shows that we now get a spec for the example from the github issue.
- Loading branch information
Showing
12 changed files
with
98 additions
and
3 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
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,12 @@ | ||
|
||
SOURCES = $(shell ls *.c) | ||
OBJECTS = $(SOURCES:.c=.o) | ||
|
||
all: clean $(OBJECTS) | ||
echo $(OBJECTS) | ||
|
||
.c.o: | ||
${CC} -c $< | ||
|
||
clean: | ||
rm -rf $(OBJECTS) |
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,22 @@ | ||
/* | ||
* Copyright (c) 2015 - Facebook. | ||
* All rights reserved. | ||
*/ | ||
struct l2 { | ||
int b; | ||
struct l2 *a; | ||
}; | ||
|
||
int add2(struct l2 *l) { | ||
int r = 0; | ||
for (; l; l = l->a) { | ||
r += l->b; | ||
} | ||
return r; | ||
} | ||
|
||
/* Divide by zero error shows that we get a spec for add2 */ | ||
int main() { | ||
int res = add2(0); | ||
return 5/res; | ||
} |
2 changes: 1 addition & 1 deletion
2
infer/tests/codetoanalyze/c/frontend/initialization/struct_initlistexpr.dot
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,48 @@ | ||
/* | ||
* Copyright (c) 2013- Facebook. | ||
* All rights reserved. | ||
*/ | ||
|
||
package endtoend.c; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static utils.matchers.ResultContainsExactly.containsExactly; | ||
|
||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import utils.InferException; | ||
import utils.InferResults; | ||
|
||
public class ListsTest { | ||
|
||
public static final String SOURCE_FILE = "lists/lists.c"; | ||
|
||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO"; | ||
|
||
private static InferResults inferResults; | ||
|
||
@BeforeClass | ||
public static void runInfer() throws InterruptedException, IOException { | ||
inferResults = InferResults.loadCInferResults(DivideByZeroTest.class, SOURCE_FILE); | ||
} | ||
|
||
@Test | ||
public void whenInferRunsOnDivideByZeroThenDivideByZeroIsFound() | ||
throws InterruptedException, IOException, InferException { | ||
String[] procedures = {"main"}; | ||
assertThat( | ||
"Results should contain divide by zero error", | ||
inferResults, | ||
containsExactly( | ||
DIVIDE_BY_ZERO, | ||
SOURCE_FILE, | ||
procedures | ||
) | ||
); | ||
} | ||
|
||
|
||
} |