13bd24f94SGabor Horvath // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,debug.ExprInspection %s -verify 2efec1630SGabor Horvath clang_analyzer_hashDump(int)33bd24f94SGabor Horvathconstexpr int clang_analyzer_hashDump(int) { return 5; } 43bd24f94SGabor Horvath function(int)53bd24f94SGabor Horvathvoid function(int) { 63bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void function(int)$27$clang_analyzer_hashDump(5);$Category}} 7efec1630SGabor Horvath } 8efec1630SGabor Horvath 9efec1630SGabor Horvath namespace { variadicParam(int,...)103bd24f94SGabor Horvathvoid variadicParam(int, ...) { 113bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void (anonymous namespace)::variadicParam(int, ...)$27$clang_analyzer_hashDump(5);$Category}} 12efec1630SGabor Horvath } 133bd24f94SGabor Horvath } // namespace 14efec1630SGabor Horvath f()153bd24f94SGabor Horvathconstexpr int f() { 163bd24f94SGabor Horvath return clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$int f()$34$returnclang_analyzer_hashDump(5);$Category}} 173bd24f94SGabor Horvath } 18efec1630SGabor Horvath 19efec1630SGabor Horvath namespace AA { 20efec1630SGabor Horvath class X { X()213bd24f94SGabor Horvath X() { 223bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$AA::X::X()$29$clang_analyzer_hashDump(5);$Category}} 23efec1630SGabor Horvath } 24efec1630SGabor Horvath static_method()253bd24f94SGabor Horvath static void static_method() { 263bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void AA::X::static_method()$29$clang_analyzer_hashDump(5);$Category}} 273bd24f94SGabor Horvath variadicParam(5); 283bd24f94SGabor Horvath } 293bd24f94SGabor Horvath method()303bd24f94SGabor Horvath void method() && { 313bd24f94SGabor Horvath struct Y { 323bd24f94SGabor Horvath inline void method() const & { 333bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void AA::X::method()::Y::method() const &$33$clang_analyzer_hashDump(5);$Category}} 34efec1630SGabor Horvath } 35efec1630SGabor Horvath }; 36efec1630SGabor Horvath 373bd24f94SGabor Horvath Y y; 383bd24f94SGabor Horvath y.method(); 393bd24f94SGabor Horvath 403bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void AA::X::method() &&$29$clang_analyzer_hashDump(5);$Category}} 41efec1630SGabor Horvath } 42efec1630SGabor Horvath 433bd24f94SGabor Horvath void OutOfLine(); 44efec1630SGabor Horvath operator =(int)453bd24f94SGabor Horvath X &operator=(int) { 46*888673b6SJonas Devlieghere clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$class AA::X & AA::X::operator=(int)$29$clang_analyzer_hashDump(5);$Category}} 47efec1630SGabor Horvath return *this; 48efec1630SGabor Horvath } 49efec1630SGabor Horvath operator int()50efec1630SGabor Horvath operator int() { 513bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$AA::X::operator int()$29$clang_analyzer_hashDump(5);$Category}} 52efec1630SGabor Horvath return 0; 53efec1630SGabor Horvath } 54efec1630SGabor Horvath operator float()55efec1630SGabor Horvath explicit operator float() { 563bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$AA::X::operator float()$29$clang_analyzer_hashDump(5);$Category}} 57efec1630SGabor Horvath return 0; 58efec1630SGabor Horvath } 59efec1630SGabor Horvath }; 603bd24f94SGabor Horvath } // namespace AA 61efec1630SGabor Horvath OutOfLine()623bd24f94SGabor Horvathvoid AA::X::OutOfLine() { 633bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void AA::X::OutOfLine()$27$clang_analyzer_hashDump(5);$Category}} 64efec1630SGabor Horvath } 65efec1630SGabor Horvath testLambda()66efec1630SGabor Horvathvoid testLambda() { 67efec1630SGabor Horvath []() { 683bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void testLambda()::(anonymous class)::operator()() const$29$clang_analyzer_hashDump(5);$Category}} 69efec1630SGabor Horvath }(); 70efec1630SGabor Horvath } 71efec1630SGabor Horvath 723bd24f94SGabor Horvath template <typename T> f(T)733bd24f94SGabor Horvathvoid f(T) { 74404fcd30SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void f(T)$27$clang_analyzer_hashDump(5);$Category}} 753bd24f94SGabor Horvath } 763bd24f94SGabor Horvath 773bd24f94SGabor Horvath template <typename T> 783bd24f94SGabor Horvath struct TX { fTX793bd24f94SGabor Horvath void f(T) { 80404fcd30SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void TX::f(T)$29$clang_analyzer_hashDump(5);$Category}} 813bd24f94SGabor Horvath } 823bd24f94SGabor Horvath }; 833bd24f94SGabor Horvath 843bd24f94SGabor Horvath template <> f(long)853bd24f94SGabor Horvathvoid f<long>(long) { 863bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void f(long)$27$clang_analyzer_hashDump(5);$Category}} 873bd24f94SGabor Horvath } 883bd24f94SGabor Horvath 893bd24f94SGabor Horvath template <> 903bd24f94SGabor Horvath struct TX<long> { fTX913bd24f94SGabor Horvath void f(long) { 923bd24f94SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void TX<long>::f(long)$29$clang_analyzer_hashDump(5);$Category}} 933bd24f94SGabor Horvath } 943bd24f94SGabor Horvath }; 953bd24f94SGabor Horvath 963bd24f94SGabor Horvath template <typename T> 973bd24f94SGabor Horvath struct TTX { 983bd24f94SGabor Horvath template<typename S> fTTX993bd24f94SGabor Horvath void f(T, S) { 100404fcd30SGabor Horvath clang_analyzer_hashDump(5); // expected-warning {{debug.ExprInspection$void TTX::f(T, S)$29$clang_analyzer_hashDump(5);$Category}} 1013bd24f94SGabor Horvath } 1023bd24f94SGabor Horvath }; 1033bd24f94SGabor Horvath g()1043bd24f94SGabor Horvathvoid g() { 105404fcd30SGabor Horvath // TX<int> and TX<double> is instantiated from the same code with the same 106404fcd30SGabor Horvath // source locations. The same error happining in both of the instantiations 107404fcd30SGabor Horvath // should share the common hash. This means we should not include the 108404fcd30SGabor Horvath // template argument for these types in the function signature. 109404fcd30SGabor Horvath // Note that, we still want the hash to be different for explicit 110404fcd30SGabor Horvath // specializations. 1113bd24f94SGabor Horvath TX<int> x; 1123bd24f94SGabor Horvath TX<double> y; 1133bd24f94SGabor Horvath TX<long> xl; 1143bd24f94SGabor Horvath x.f(1); 1153bd24f94SGabor Horvath xl.f(1); 1163bd24f94SGabor Horvath f(5); 1173bd24f94SGabor Horvath f(3.0); 1183bd24f94SGabor Horvath y.f(2); 1193bd24f94SGabor Horvath TTX<int> z; 1203bd24f94SGabor Horvath z.f<int>(5, 5); 1213bd24f94SGabor Horvath f(5l); 1223bd24f94SGabor Horvath } 123