File indexing completed on 2024-05-12 05:41:13
0001 #include <QtCore/QObject> 0002 0003 class A : public QObject 0004 { 0005 Q_OBJECT 0006 public: 0007 int g; 0008 A() 0009 : g(foo()) // OK 0010 { 0011 } 0012 bool foo_bool() const 0013 { 0014 return true; 0015 } 0016 int foo() const 0017 { 0018 return 5; 0019 } 0020 void bar() const 0021 { 0022 foo(); // WARN 0023 if (foo()) // OK 0024 { } 0025 } 0026 }; 0027 0028 class B 0029 { 0030 public: 0031 A a; 0032 B() 0033 : g(a.foo()) // OK 0034 { 0035 } 0036 int g; 0037 }; 0038 0039 class C 0040 { 0041 public: 0042 A a; 0043 }; 0044 0045 int main(int argc, char *argv[]) 0046 { 0047 A a; 0048 B b; 0049 a.bar(); 0050 auto lambda = [](A &obj) { 0051 obj.foo(); // WARN 0052 }; 0053 lambda(a); 0054 0055 C *c = new C(); 0056 if (c->a.foo_bool()) { // OK 0057 } 0058 while (c->a.foo_bool()) { // OK 0059 A obj; 0060 obj.foo(); // WARN 0061 0062 int x = 10; 0063 switch (c->a.foo()) { // OK 0064 case 1: 0065 A bar; 0066 bar.foo(); // WARN 0067 break; 0068 } 0069 0070 for (int i = 0; i < (c->a.foo()); i++) { 0071 A bar; 0072 bar.foo(); // WARN 0073 } 0074 0075 do { 0076 A bar; 0077 bar.foo(); // WARN 0078 } while (c->a.foo_bool()); // OK 0079 } 0080 return 0; 0081 }