false-positive-suppression.cpp revision 44ec3f00e64199667edf9f12c0f31f66916c95fe
1// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-null-return-paths=false -verify %s 2// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -DSUPPRESSED=1 %s 3 4#ifdef SUPPRESSED 5// expected-no-diagnostics 6#endif 7 8namespace rdar12676053 { 9 // Delta-reduced from a preprocessed file. 10 template<class T> 11 class RefCount { 12 T *ref; 13 public: 14 T *operator->() const { 15 return ref ? ref : 0; 16 } 17 }; 18 19 class string {}; 20 21 class ParserInputState { 22 public: 23 string filename; 24 }; 25 26 class Parser { 27 void setFilename(const string& f) { 28 inputState->filename = f; 29#ifndef SUPPRESSED 30// expected-warning@-2 {{Called C++ object pointer is null}} 31#endif 32 } 33 protected: 34 RefCount<ParserInputState> inputState; 35 }; 36}