1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection\
2 // RUN:   -analyzer-checker cplusplus.Move,cplusplus.SmartPtr\
3 // RUN:   -std=c++11 -verify %s
4 
5 #include "Inputs/system-header-simulator-cxx.h"
6 
7 void clang_analyzer_warnIfReached();
8 
derefAfterMove(std::unique_ptr<int> P)9 void derefAfterMove(std::unique_ptr<int> P) {
10   std::unique_ptr<int> Q = std::move(P);
11   if (Q)
12     clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
13   *Q.get() = 1; // no-warning
14   if (P)
15     clang_analyzer_warnIfReached(); // no-warning
16   // TODO: Report a null dereference (instead).
17   *P.get() = 1; // expected-warning {{Method called on moved-from object 'P'}}
18 }
19 
20 // Don't crash when attempting to model a call with unknown callee.
21 namespace testUnknownCallee {
22 struct S {
23   void foo();
24 };
bar(S * s,void (S::* func)(void))25 void bar(S *s, void (S::*func)(void)) {
26   (s->*func)(); // no-crash
27 }
28 } // namespace testUnknownCallee
29