[analyzer] Don't assert on a temporary of pointer-to-member type.

While we don't do anything intelligent with pointers-to-members today,
it's perfectly legal to need a temporary of pointer-to-member type to, say,
pass by const reference. Tweak an assertion to allow this.

PR15742 and PR15747

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179563 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp
index c79cf96..1969d94 100644
--- a/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -181,7 +181,8 @@
   } else {
     // We need to create a region no matter what. For sanity, make sure we don't
     // try to stuff a Loc into a non-pointer temporary region.
-    assert(!V.getAs<Loc>() || Loc::isLocType(Result->getType()));
+    assert(!V.getAs<Loc>() || Loc::isLocType(Result->getType()) ||
+           Result->getType()->isMemberPointerType());
   }
 
   ProgramStateManager &StateMgr = State->getStateManager();
diff --git a/test/Analysis/pointer-to-member.cpp b/test/Analysis/pointer-to-member.cpp
index 84dfe30..c9150e8 100644
--- a/test/Analysis/pointer-to-member.cpp
+++ b/test/Analysis/pointer-to-member.cpp
@@ -8,6 +8,9 @@
   operator MemberPointer() const { return m_ptr ? &A::m_ptr : 0; }
 
   A *m_ptr;
+
+  A *getPtr();
+  typedef A * (A::*MemberFnPointer)(void);
 };
 
 void testConditionalUse() {
@@ -22,6 +25,40 @@
   clang_analyzer_eval(obj.m_ptr); // expected-warning{{FALSE}}
   clang_analyzer_eval(A::MemberPointer(0)); // expected-warning{{FALSE}}
   clang_analyzer_eval(obj); // expected-warning{{FALSE}}
+
+  clang_analyzer_eval(&A::getPtr); // expected-warning{{TRUE}}
+  clang_analyzer_eval(A::MemberFnPointer(0)); // expected-warning{{FALSE}}
+}
+
+
+void testComparison() {
+  clang_analyzer_eval(&A::getPtr == &A::getPtr); // expected-warning{{TRUE}}
+
+  // FIXME: Should be TRUE.
+  clang_analyzer_eval(&A::m_ptr == &A::m_ptr); // expected-warning{{UNKNOWN}}
+}
+
+namespace PR15742 {
+  template <class _T1, class _T2> struct A {
+    A (const _T1 &, const _T2 &);
+  };
+  
+  typedef void *NPIdentifier;
+
+  template <class T> class B {
+  public:
+    typedef A<NPIdentifier, bool (T::*) (const NPIdentifier *, unsigned,
+                                         NPIdentifier *)> MethodMapMember;
+  };
+
+  class C : public B<C> {
+  public:
+    bool Find(const NPIdentifier *, unsigned, NPIdentifier *);
+  };
+
+  void InitStaticData () {
+    C::MethodMapMember(0, &C::Find); // don't crash
+  }
 }
 
 // ---------------