-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better detection of typedefs in C++ (#1896)
- Loading branch information
Showing
6 changed files
with
107 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
typedef struct test { | ||
int a; | ||
int b; | ||
} S; | ||
|
||
int structs() { | ||
S s; | ||
S t; | ||
S* p=&s; | ||
s.a=1; | ||
s.b=2; | ||
printf("%d %d\n", s.a, s.b); | ||
} |
15 changes: 15 additions & 0 deletions
15
cpg-language-cxx/src/test/resources/cxx/typedef_struct.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,15 @@ | ||
typedef struct test { | ||
int a; | ||
int b; | ||
} S; | ||
|
||
int structs() { | ||
S s; | ||
S t; | ||
S* p=&s; | ||
s.a=1; | ||
s.b=2; | ||
printf("%d %d\n", s.a, s.b); | ||
} | ||
|
||
long typedef bla; |
19 changes: 19 additions & 0 deletions
19
cpg-language-cxx/src/test/resources/typedefs/weird_typedefs.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,19 @@ | ||
// typedef can be used anywhere in the decl-specifier-seq | ||
// more conventionally spelled "typedef unsigned long long int ullong;" | ||
unsigned long typedef long int ullong; | ||
|
||
// usage of type that is identical to typedef | ||
unsigned long long int someUllong1; | ||
// usage of typedef | ||
ullong someUllong2; | ||
|
||
// also possible with structs | ||
struct bar { | ||
int a; | ||
int b; | ||
} typedef baz; | ||
|
||
// just some type that contains a typedef for more confusion | ||
struct foo { | ||
typedef const int a; | ||
}; |