mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
For ease of reviewing, I've checked in the .expected files from the AST-based guards library. The next commit accepts output for these tests and adds tests that use getAST rather than the translation layer.
55 lines
577 B
C++
55 lines
577 B
C++
class X
|
|
{
|
|
public:
|
|
void set();
|
|
};
|
|
|
|
class Y
|
|
{
|
|
public:
|
|
Y* f();
|
|
|
|
const X* get() const { return 0; }
|
|
X* get() { return 0; }
|
|
};
|
|
|
|
Y* Y::f()
|
|
{
|
|
if ( get() )
|
|
get()->set();
|
|
return 0;
|
|
}
|
|
|
|
class Error {
|
|
public:
|
|
Error() {}
|
|
};
|
|
|
|
bool getABool();
|
|
|
|
void doSomething(int x) {
|
|
if (x == -1) {
|
|
throw new Error();
|
|
}
|
|
}
|
|
|
|
void doSomethingElse(int x);
|
|
|
|
bool testWithCatch0(int v)
|
|
{
|
|
try
|
|
{
|
|
if( getABool() )
|
|
{
|
|
doSomething(v);
|
|
return true;
|
|
}
|
|
}
|
|
catch(Error &e)
|
|
{
|
|
doSomethingElse(v);
|
|
}
|
|
|
|
return false;
|
|
}
|