2018-12-08 00:05:58 +08:00
|
|
|
// Test typedef and global variable in function.
|
|
|
|
typedef struct {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
} FooBar;
|
|
|
|
FooBar fb;
|
|
|
|
int f(int i) {
|
|
|
|
if (fb.a) {
|
|
|
|
fb.b = i;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test enums.
|
2019-08-27 19:36:10 +08:00
|
|
|
enum B { x2 = 42,
|
|
|
|
y2,
|
|
|
|
z2 };
|
2018-12-08 00:05:58 +08:00
|
|
|
int enumCheck(void) {
|
2019-08-27 19:36:10 +08:00
|
|
|
return x2;
|
2018-12-08 00:05:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Test reporting an error in macro definition
|
|
|
|
#define MYMACRO(ctx) \
|
|
|
|
ctx->a;
|
|
|
|
struct S {
|
|
|
|
int a;
|
|
|
|
};
|
|
|
|
int g(struct S *ctx) {
|
|
|
|
MYMACRO(ctx);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test that asm import does not fail.
|
[analyzer] On-demand parsing capability for CTU
Summary:
Introduce on-demand parsing of needed ASTs during CTU analysis.
The index-file format is extended, and analyzer-option CTUInvocationList
is added to specify the exact invocations needed to parse the needed
source-files.
Reviewers: martong, balazske, Szelethus, xazax.hun, whisperity
Reviewed By: martong, xazax.hun
Subscribers: gribozavr2, thakis, ASDenysPetrov, ormris, mgorny, whisperity, xazax.hun, baloghadamsoftware, szepet, rnkovacs, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, steakhal, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75665
2020-06-10 14:59:04 +08:00
|
|
|
// TODO: Support the GNU extension asm keyword as well.
|
|
|
|
// Example using the GNU extension: asm("mov $42, %0" : "=r"(res));
|
2018-12-08 00:05:58 +08:00
|
|
|
int inlineAsm() {
|
|
|
|
int res;
|
[analyzer] On-demand parsing capability for CTU
Summary:
Introduce on-demand parsing of needed ASTs during CTU analysis.
The index-file format is extended, and analyzer-option CTUInvocationList
is added to specify the exact invocations needed to parse the needed
source-files.
Reviewers: martong, balazske, Szelethus, xazax.hun, whisperity
Reviewed By: martong, xazax.hun
Subscribers: gribozavr2, thakis, ASDenysPetrov, ormris, mgorny, whisperity, xazax.hun, baloghadamsoftware, szepet, rnkovacs, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, steakhal, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75665
2020-06-10 14:59:04 +08:00
|
|
|
__asm__("mov $42, %0"
|
|
|
|
: "=r"(res));
|
2018-12-08 00:05:58 +08:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implicit function.
|
|
|
|
int identImplicit(int in) {
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ASTImporter doesn't support this construct.
|
|
|
|
int structInProto(struct DataType {int a;int b; } * d) {
|
|
|
|
return 0;
|
|
|
|
}
|