Whenever we complain about a failed initialization of a function or
method parameter, provide a note pointing at the parameter itself so
the user does not have to manually look for the function/method being
called and match up parameters to arguments. For example, we now get:

t.c:4:5: warning: incompatible pointer types passing 'long *' to
parameter of
      type 'int *' [-pedantic]
  f(long_ptr);
    ^~~~~~~~
t.c:1:13: note: passing argument to parameter 'x' here
void f(int *x);
            ^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102038 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index eb53d6c..aad880a 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2077,7 +2077,10 @@
   "use @dynamic or provide a method implementation in category">;
 def note_property_impl_required : Note<
   "implementation is here">;
-
+def note_parameter_named_here : Note<
+  "passing argument to parameter %0 here">;
+def note_parameter_here : Note<
+  "passing argument to parameter here">;
 
 // C++ casts
 // These messages adhere to the TryCast pattern: %0 is an int specifying the
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index a284803..5333684 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -4076,7 +4076,8 @@
   bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
                                 SourceLocation Loc,
                                 QualType DstType, QualType SrcType,
-                                Expr *SrcExpr, AssignmentAction Action);
+                                Expr *SrcExpr, AssignmentAction Action,
+                                bool *Complained = 0);
 
   /// CheckAssignmentConstraints - Perform type checking for assignment,
   /// argument passing, variable initialization, and function return values.
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 265f44c..3621f70 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -7036,7 +7036,11 @@
 bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
                                     SourceLocation Loc,
                                     QualType DstType, QualType SrcType,
-                                    Expr *SrcExpr, AssignmentAction Action) {
+                                    Expr *SrcExpr, AssignmentAction Action,
+                                    bool *Complained) {
+  if (Complained)
+    *Complained = false;
+
   // Decode the result (notice that AST's are still created for extensions).
   bool isInvalid = false;
   unsigned DiagKind;
@@ -7121,6 +7125,8 @@
   
   Diag(Loc, DiagKind) << FirstType << SecondType << Action
     << SrcExpr->getSourceRange() << Hint;
+  if (Complained)
+    *Complained = true;
   return isInvalid;
 }
 
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 6a9efbd..eae5f63 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -3308,6 +3308,20 @@
                                  move_arg(ConstructorArgs));
 }
 
+void InitializationSequence::PrintInitLocationNote(Sema &S,
+                                              const InitializedEntity &Entity) {
+  if (Entity.getKind() == InitializedEntity::EK_Parameter && Entity.getDecl()) {
+    if (Entity.getDecl()->getLocation().isInvalid())
+      return;
+
+    if (Entity.getDecl()->getDeclName())
+      S.Diag(Entity.getDecl()->getLocation(), diag::note_parameter_named_here)
+        << Entity.getDecl()->getDeclName();
+    else
+      S.Diag(Entity.getDecl()->getLocation(), diag::note_parameter_here);
+  }
+}
+
 Action::OwningExprResult 
 InitializationSequence::Perform(Sema &S,
                                 const InitializedEntity &Entity,
@@ -3474,6 +3488,7 @@
         S.Diag(Kind.getLocation(), diag::err_reference_bind_to_vector_element)
           << Entity.getType().isVolatileQualified()
           << CurInitExpr->getSourceRange();
+        PrintInitLocationNote(S, Entity);
         return S.ExprError();
       }
         
@@ -3695,10 +3710,16 @@
             == Sema::Compatible)
         ConvTy = Sema::Compatible;
 
+      bool Complained;
       if (S.DiagnoseAssignmentResult(ConvTy, Kind.getLocation(),
                                      Step->Type, SourceType,
-                                     CurInitExpr, getAssignmentAction(Entity)))
+                                     CurInitExpr, 
+                                     getAssignmentAction(Entity),
+                                     &Complained)) {
+        PrintInitLocationNote(S, Entity);
         return S.ExprError();
+      } else if (Complained)
+        PrintInitLocationNote(S, Entity);
 
       CurInit.release();
       CurInit = S.Owned(CurInitExpr);
@@ -3972,6 +3993,7 @@
     break;
   }
   
+  PrintInitLocationNote(S, Entity);
   return true;
 }
 
diff --git a/lib/Sema/SemaInit.h b/lib/Sema/SemaInit.h
index ba11470..5f2592f 100644
--- a/lib/Sema/SemaInit.h
+++ b/lib/Sema/SemaInit.h
@@ -542,7 +542,11 @@
   
   /// \brief The candidate set created when initialization failed.
   OverloadCandidateSet FailedCandidateSet;
-  
+
+  /// \brief Prints a follow-up note that highlights the location of
+  /// the initialized entity, if it's remote.
+  void PrintInitLocationNote(Sema &S, const InitializedEntity &Entity);
+
 public:
   /// \brief Try to perform initialization of the given entity, creating a 
   /// record of the steps required to perform the initialization.
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
index f9bac40..3039396 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
@@ -36,7 +36,7 @@
     double d;
   };
   Number zero(0.0f);
-  void g(Number);
+  void g(Number); // expected-note 2{{passing argument to parameter here}}
 }
 
 void test2() {
diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
index 3581f79..c51c2ca 100644
--- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
+++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
@@ -12,7 +12,8 @@
   test<1> foo(class foo);
 
   namespace A {
-    test<2> foo(class ::foo); // expected-note {{candidate}}
+    test<2> foo(class ::foo); // expected-note {{candidate}} \
+    // expected-note{{passing argument to parameter here}}
 
     void test0() {
       using ::foo;
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp
index 7ee052c..3100e56 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp
@@ -2,7 +2,8 @@
 
 float global_f;
 
-void f0(int *ip = &global_f); // expected-error{{cannot initialize}}
+void f0(int *ip = &global_f); // expected-error{{cannot initialize}} \
+// expected-note{{passing argument to parameter 'ip' here}}
 
 // Example from C++03 standard
 int a = 1; 
diff --git a/test/PCH/functions.c b/test/PCH/functions.c
index 5d7849e..23becb6 100644
--- a/test/PCH/functions.c
+++ b/test/PCH/functions.c
@@ -6,7 +6,7 @@
 // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s 
 
 int f0(int x0, int y0, ...) { return x0 + y0; }
-
+// expected-note{{passing argument to parameter here}}
 float *test_f1(int val, double x, double y) {
   if (val > 5)
     return f1(x, y);
diff --git a/test/PCH/functions.h b/test/PCH/functions.h
index 3972430..f57400f 100644
--- a/test/PCH/functions.h
+++ b/test/PCH/functions.h
@@ -1,6 +1,9 @@
 /* For use with the functions.c test */
 
-int f0(int x, int y, ...);
+
+
+
+int f0(int x, int y, ...); 
 float *f1(float x, float y);
 
 void g0(int *);
diff --git a/test/Sema/array-constraint.c b/test/Sema/array-constraint.c
index 8b577fa..9fcac25 100644
--- a/test/Sema/array-constraint.c
+++ b/test/Sema/array-constraint.c
@@ -43,7 +43,7 @@
 static int I;
 typedef int TA[I]; // expected-error {{variable length array declaration not allowed at file scope}}
 
-void strFunc(char *);
+void strFunc(char *); // expected-note{{passing argument to parameter here}}
 const char staticAry[] = "test";
 void checkStaticAry() { 
   strFunc(staticAry); // expected-warning{{passing 'char const [5]' to parameter of type 'char *' discards qualifiers}}
diff --git a/test/Sema/attr-format.c b/test/Sema/attr-format.c
index 0fadf98..a223e08 100644
--- a/test/Sema/attr-format.c
+++ b/test/Sema/attr-format.c
@@ -45,7 +45,7 @@
 // FreeBSD usage
 #define __printf0like(fmt,va) __attribute__((__format__(__printf0__,fmt,va)))
 void null(int i, const char *a, ...) __printf0like(2,0); // no-error
-void null(int i, const char *a, ...) {
+void null(int i, const char *a, ...) { // expected-note{{passing argument to parameter 'a' here}}
   if (a)
     (void)0/* vprintf(...) would go here */;
 }
diff --git a/test/Sema/block-misc.c b/test/Sema/block-misc.c
index e31cdb5..accd4ba 100644
--- a/test/Sema/block-misc.c
+++ b/test/Sema/block-misc.c
@@ -139,7 +139,7 @@
 
 enum { LESS };
 
-void foo(long (^comp)()) {
+void foo(long (^comp)()) { // expected-note{{passing argument to parameter 'comp' here}}
 }
 
 void (^test15f)(void);
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index dcc4c35..bdc2bb0 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -4,7 +4,7 @@
 typedef __typeof(sizeof(int)) size_t;
 typedef struct _FILE FILE;
 int fprintf(FILE *, const char *restrict, ...);
-int printf(const char *restrict, ...);
+int printf(const char *restrict, ...); // expected-note{{passing argument to parameter here}}
 int snprintf(char *restrict, size_t, const char *restrict, ...);
 int sprintf(char *restrict, const char *restrict, ...);
 int vasprintf(char **, const char *, va_list);
@@ -12,7 +12,7 @@
 int vfprintf(FILE *, const char *restrict, va_list);
 int vprintf(const char *restrict, va_list);
 int vsnprintf(char *, size_t, const char *, va_list);
-int vsprintf(char *restrict, const char *restrict, va_list);
+int vsprintf(char *restrict, const char *restrict, va_list); // expected-note{{passing argument to parameter here}}
 
 char * global_fmt;
 
diff --git a/test/Sema/incompatible-sign.c b/test/Sema/incompatible-sign.c
index b3c1e9a..6249feb 100644
--- a/test/Sema/incompatible-sign.c
+++ b/test/Sema/incompatible-sign.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only
 
-int a(int* x);
+int a(int* x); // expected-note{{passing argument to parameter 'x' here}}
 int b(unsigned* y) { return a(y); } // expected-warning {{passing 'unsigned int *' to parameter of type 'int *' converts between pointers to integer types with different sign}}
 
diff --git a/test/Sema/predefined-function.c b/test/Sema/predefined-function.c
index 74bc86f..1c40b6e 100644
--- a/test/Sema/predefined-function.c
+++ b/test/Sema/predefined-function.c
@@ -4,7 +4,8 @@
 enum Test {A=-1};
 char *funk(enum Test x);
 
-int eli(float b); // expected-note {{previous declaration is here}}
+int eli(float b); // expected-note {{previous declaration is here}} \
+// expected-note{{passing argument to parameter 'b' here}}
 int b(int c) {return 1;}
 
 int foo();
diff --git a/test/Sema/transparent-union.c b/test/Sema/transparent-union.c
index 03f6a53..cdfc850 100644
--- a/test/Sema/transparent-union.c
+++ b/test/Sema/transparent-union.c
@@ -4,7 +4,7 @@
   float *fp;
 } TU __attribute__((transparent_union));
 
-void f(TU);
+void f(TU); // expected-note{{passing argument to parameter here}}
 
 void g(int *ip, float *fp, char *cp) {
   f(ip);
diff --git a/test/Sema/vector-assign.c b/test/Sema/vector-assign.c
index e060729..05fc3b1 100644
--- a/test/Sema/vector-assign.c
+++ b/test/Sema/vector-assign.c
@@ -47,7 +47,7 @@
 typedef long long __attribute__((__vector_size__(2 * sizeof(long long))))
 longlongvec;
 
-void test3a(longlongvec *);
+void test3a(longlongvec *); // expected-note{{passing argument to parameter here}}
 void test3(const unsigned *src) {
   test3a(src);  // expected-warning {{incompatible pointer types passing 'unsigned int const *' to parameter of type 'longlongvec *'}}
 }
diff --git a/test/Sema/vector-cast.c b/test/Sema/vector-cast.c
index e655147..a717e86 100644
--- a/test/Sema/vector-cast.c
+++ b/test/Sema/vector-cast.c
@@ -30,7 +30,7 @@
 }
 
 
-void f2(t2 X);
+void f2(t2 X); // expected-note{{passing argument to parameter 'X' here}}
 
 void f3(t3 Y) {
   f2(Y);  // expected-warning {{incompatible vector types passing 't3' to parameter of type 't2'}}
diff --git a/test/SemaCXX/default1.cpp b/test/SemaCXX/default1.cpp
index 790208a..e9d8a2f 100644
--- a/test/SemaCXX/default1.cpp
+++ b/test/SemaCXX/default1.cpp
@@ -14,7 +14,8 @@
        int n);// expected-error {{missing default argument on parameter 'n'}}
 
 struct S { } s;
-void i(int = s) { } // expected-error {{no viable conversion}}
+void i(int = s) { } // expected-error {{no viable conversion}} \
+// expected-note{{passing argument to parameter here}}
 
 struct X { 
   X(int);
@@ -26,6 +27,8 @@
   explicit Y(int);
 };
 
-void k(Y y = 17); // expected-error{{no viable conversion}}
+void k(Y y = 17); // expected-error{{no viable conversion}} \
+// expected-note{{passing argument to parameter 'y' here}}
 
-void kk(Y = 17); // expected-error{{no viable conversion}}
+void kk(Y = 17); // expected-error{{no viable conversion}} \
+// expected-note{{passing argument to parameter here}}
diff --git a/test/SemaCXX/default2.cpp b/test/SemaCXX/default2.cpp
index a0999c0..d9f1edf 100644
--- a/test/SemaCXX/default2.cpp
+++ b/test/SemaCXX/default2.cpp
@@ -102,7 +102,8 @@
 struct ZZ {
   static ZZ g(int = 17);
 
-  void f(ZZ z = g()); // expected-error{{no matching constructor for initialization}}
+  void f(ZZ z = g()); // expected-error{{no matching constructor for initialization}} \
+  // expected-note{{passing argument to parameter 'z' here}}
 
   ZZ(ZZ&, int = 17); // expected-note{{candidate constructor}}
 };
diff --git a/test/SemaCXX/elaborated-type-specifier.cpp b/test/SemaCXX/elaborated-type-specifier.cpp
index 3cd3a1b..2d0b571 100644
--- a/test/SemaCXX/elaborated-type-specifier.cpp
+++ b/test/SemaCXX/elaborated-type-specifier.cpp
@@ -22,7 +22,7 @@
     void test_elab2(struct S4 *s4);
   };
 
-  void X::test_elab2(S4 *s4) { }
+  void X::test_elab2(S4 *s4) { } // expected-note{{passing argument to parameter 's4' here}}
 }
 
 void test_X_elab(NS::X x) {
diff --git a/test/SemaCXX/member-location.cpp b/test/SemaCXX/member-location.cpp
index c3099d2..6f7e1f5 100644
--- a/test/SemaCXX/member-location.cpp
+++ b/test/SemaCXX/member-location.cpp
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // PR4103: Make sure we have a location for the error
-class A { float a(int *); int b(); };
+class A { 
+  float a(int *); // expected-note{{passing argument to parameter here}}
+  int b(); 
+};
 int A::b() { return a(a((int*)0)); } // expected-error {{cannot initialize a parameter of type 'int *' with an rvalue of type 'float'}}
 
diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp
index 472e805..feec9df 100644
--- a/test/SemaCXX/overload-call.cpp
+++ b/test/SemaCXX/overload-call.cpp
@@ -425,7 +425,7 @@
 namespace PR6177 {
   struct String { String(char const*); };
 
-  void f(bool const volatile&);
+  void f(bool const volatile&); // expected-note{{passing argument to parameter here}}
   void f(String);
 
   void g() { f(""); } // expected-error{{volatile lvalue reference to type 'bool const volatile' cannot bind to a value of unrelated type 'char const [1]'}}
diff --git a/test/SemaCXX/ref-init-ambiguous.cpp b/test/SemaCXX/ref-init-ambiguous.cpp
index 8844162..a8e95a3 100644
--- a/test/SemaCXX/ref-init-ambiguous.cpp
+++ b/test/SemaCXX/ref-init-ambiguous.cpp
@@ -17,7 +17,7 @@
   const E2 &e2 = c; // expected-error {{reference initialization of type 'E2 const &' with initializer of type 'C' is ambiguous}}
 }
 
-void foo(const E2 &);
+void foo(const E2 &);// expected-note{{passing argument to parameter here}}
 
 const E2 & re(C c) {
     foo(c); // expected-error {{reference initialization of type 'E2 const &' with initializer of type 'C' is ambiguous}}
diff --git a/test/SemaObjC/argument-checking.m b/test/SemaObjC/argument-checking.m
index 19caf32..9019a0f 100644
--- a/test/SemaObjC/argument-checking.m
+++ b/test/SemaObjC/argument-checking.m
@@ -2,14 +2,15 @@
 
 struct S { int a; };
 
-extern int charStarFunc(char *);
-extern int charFunc(char);
+extern int charStarFunc(char *); // expected-note{{passing argument to parameter here}}
+extern int charFunc(char); // expected-note{{passing argument to parameter here}}
 
 @interface Test
 +alloc;
--(int)charStarMeth:(char *)s;
--structMeth:(struct S)s;
--structMeth:(struct S)s :(struct S)s2;
+-(int)charStarMeth:(char *)s; // expected-note{{passing argument to parameter 's' here}}
+-structMeth:(struct S)s; // expected-note{{passing argument to parameter 's' here}}
+-structMeth:(struct S)s 
+   :(struct S)s2; // expected-note{{passing argument to parameter 's2' here}}
 @end
 
 void test() {
diff --git a/test/SemaObjC/block-type-safety.m b/test/SemaObjC/block-type-safety.m
index 2b31cac..402a658 100644
--- a/test/SemaObjC/block-type-safety.m
+++ b/test/SemaObjC/block-type-safety.m
@@ -4,7 +4,7 @@
 @interface Super  @end
 @interface Sub : Super @end
 
-void f2(void(^f)(Super *)) {
+void f2(void(^f)(Super *)) { // expected-note{{passing argument to parameter 'f' here}}
     Super *o;
     f(o);
 }
@@ -18,7 +18,7 @@
      Super *o = f();
 }
 
-void r1(Sub* (^f)()) {
+void r1(Sub* (^f)()) { // expected-note{{passing argument to parameter 'f' here}}
     Sub *o = f();
 }
 
@@ -95,7 +95,7 @@
 @end
 
 @protocol P, P2;
-void f4(void (^f)(id<P> x)) {
+void f4(void (^f)(id<P> x)) { // expected-note{{passing argument to parameter 'f' here}}
     NSArray<P2> *b;
     f(b);	// expected-warning {{passing 'NSArray<P2> *' to parameter of incompatible type 'id<P>'}}
 }
diff --git a/test/SemaObjC/blocks.m b/test/SemaObjC/blocks.m
index 10239e5..15aa581 100644
--- a/test/SemaObjC/blocks.m
+++ b/test/SemaObjC/blocks.m
@@ -21,7 +21,7 @@
     return bar4(objectCreationBlock);
 }
 
-void bar5(id(^)(void));
+void bar5(id(^)(void)); // expected-note{{passing argument to parameter here}}
 void foo5(id (^objectCreationBlock)(int)) {
     return bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(int)' to parameter of type 'id (^)(void)'}}
 }
diff --git a/test/SemaObjC/class-method-self.m b/test/SemaObjC/class-method-self.m
index ec0edf1..ba70644 100644
--- a/test/SemaObjC/class-method-self.m
+++ b/test/SemaObjC/class-method-self.m
@@ -3,7 +3,7 @@
 typedef struct objc_class *Class;
 @interface XX
 
-- (void)addObserver:(XX*)o;
+- (void)addObserver:(XX*)o; // expected-note 2{{passing argument to parameter 'o' here}}
 
 @end
 
diff --git a/test/SemaObjC/compatible-protocol-qualified-types.m b/test/SemaObjC/compatible-protocol-qualified-types.m
index 1c9cc2c..0342622 100644
--- a/test/SemaObjC/compatible-protocol-qualified-types.m
+++ b/test/SemaObjC/compatible-protocol-qualified-types.m
@@ -44,7 +44,7 @@
 
 @interface NSTextStorage : NSObject
 
-- (void)setDelegate:(id <NSTextStorageDelegate>)delegate;
+- (void)setDelegate:(id <NSTextStorageDelegate>)delegate; // expected-note{{passing argument to parameter 'delegate' here}}
 - (id <NSTextStorageDelegate>)delegate;
 
 @end
diff --git a/test/SemaObjC/comptypes-legal.m b/test/SemaObjC/comptypes-legal.m
index e318d33..d83d559 100644
--- a/test/SemaObjC/comptypes-legal.m
+++ b/test/SemaObjC/comptypes-legal.m
@@ -26,7 +26,7 @@
 typedef id FuncSignature (NSObject *arg1, Derived *arg2);
 
 @interface Derived: NSObject
-+ (void)registerFunc:(FuncSignature *)function;
++ (void)registerFunc:(FuncSignature *)function; // expected-note{{passing argument to parameter 'function' here}}
 @end
 
 void foo(void)
diff --git a/test/SemaObjC/incompatible-protocol-qualified-types.m b/test/SemaObjC/incompatible-protocol-qualified-types.m
index 23cb50a..494d23e 100644
--- a/test/SemaObjC/incompatible-protocol-qualified-types.m
+++ b/test/SemaObjC/incompatible-protocol-qualified-types.m
@@ -8,7 +8,7 @@
 
 @interface INTF @end
 
-INTF <MyProto1> * Func(INTF <MyProto1, MyProto2> *p2)
+INTF <MyProto1> * Func(INTF <MyProto1, MyProto2> *p2) // expected-note{{passing argument to parameter 'p2' here}}
 {
 	return p2;
 }
diff --git a/test/SemaObjC/method-arg-qualifier-warning.m b/test/SemaObjC/method-arg-qualifier-warning.m
index a064a7d..463fb7f 100644
--- a/test/SemaObjC/method-arg-qualifier-warning.m
+++ b/test/SemaObjC/method-arg-qualifier-warning.m
@@ -3,7 +3,7 @@
 typedef signed char BOOL;
 
 @interface NSString
-- (BOOL)isEqualToString:(NSString *)aString;
+- (BOOL)isEqualToString:(NSString *)aString; // expected-note 2{{passing argument to parameter 'aString' here}}
 @end
 
 static const NSString * Identifier1 =   @"Identifier1";
diff --git a/test/SemaObjC/protocol-id-test-3.m b/test/SemaObjC/protocol-id-test-3.m
index 89f11c3..624bab0 100644
--- a/test/SemaObjC/protocol-id-test-3.m
+++ b/test/SemaObjC/protocol-id-test-3.m
@@ -8,7 +8,7 @@
 
 @interface INTF @end
 
-id<MyProto1> Func(INTF <MyProto1, MyProto2> *p2)
+id<MyProto1> Func(INTF <MyProto1, MyProto2> *p2) // expected-note 2{{passing argument to parameter 'p2' here}}
 {
 	return p2;
 }
diff --git a/test/SemaObjC/protocol-typecheck.m b/test/SemaObjC/protocol-typecheck.m
index 3d98df8..4eb1b26 100644
--- a/test/SemaObjC/protocol-typecheck.m
+++ b/test/SemaObjC/protocol-typecheck.m
@@ -9,7 +9,7 @@
 @interface XX
 
 - (void)setFlexElement:(NSObject <PWhatever, XCElementP> *)flexer;
-- (void)setFlexElement2:(NSObject <PWhatever, XCElementSpacerP> *)flexer;
+- (void)setFlexElement2:(NSObject <PWhatever, XCElementSpacerP> *)flexer; // expected-note{{passing argument to parameter 'flexer' here}}
 
 @end
 
diff --git a/test/SemaObjC/warn-incompatible-builtin-types.m b/test/SemaObjC/warn-incompatible-builtin-types.m
index 8806d63..79c8cea 100644
--- a/test/SemaObjC/warn-incompatible-builtin-types.m
+++ b/test/SemaObjC/warn-incompatible-builtin-types.m
@@ -2,7 +2,7 @@
 // rdar 7634850
 
 @interface Foo
-- (void)foo:(Class)class;
+- (void)foo:(Class)class; // expected-note{{passing argument to parameter 'class' here}}
 @end
 
 void FUNC() {
diff --git a/test/SemaObjC/warn-superclass-method-mismatch.m b/test/SemaObjC/warn-superclass-method-mismatch.m
index a4005ad..5205473 100644
--- a/test/SemaObjC/warn-superclass-method-mismatch.m
+++ b/test/SemaObjC/warn-superclass-method-mismatch.m
@@ -9,7 +9,7 @@
 @interface Base : Root
 -(void) method: (int*) x; // expected-note {{previous declaration is here}}
 -(void) method1: (Base*) x; // expected-note {{previous declaration is here}}
--(void) method2: (Sub*) x;
+-(void) method2: (Sub*) x; // expected-note{{passing argument to parameter 'x' here}}
 + method3: (int)x1 : (Base *)x2 : (float)x3; // expected-note {{previous declaration is here}}
 + mathod4: (id)x1;
 - method5: (int) x : (double) d; // expected-note {{previous declaration is here}}
diff --git a/test/SemaObjCXX/message.mm b/test/SemaObjCXX/message.mm
index 97ee499..b75608e 100644
--- a/test/SemaObjCXX/message.mm
+++ b/test/SemaObjCXX/message.mm
@@ -84,9 +84,11 @@
 
 // C++-specific parameter types
 @interface I5
-- method:(const String&)str1 other:(String&)str2;
+- method:(const String&)str1 
+   other:(String&)str2; // expected-note{{passing argument to parameter 'str2' here}}
 @end
 
 void test_I5(I5 *i5, String s) {
   [i5 method:"hello" other:s];
+  [i5 method:s other:"world"]; // expected-error{{non-const lvalue reference to type 'String' cannot bind to a value of unrelated type 'char const [6]'}}
 }
diff --git a/test/SemaObjCXX/objc-pointer-conv.mm b/test/SemaObjCXX/objc-pointer-conv.mm
index 2504dce..cc3264f 100644
--- a/test/SemaObjCXX/objc-pointer-conv.mm
+++ b/test/SemaObjCXX/objc-pointer-conv.mm
@@ -26,7 +26,7 @@
 @end
 
 @interface I
-- (void) Meth : (I*) Arg;
+- (void) Meth : (I*) Arg; // expected-note{{passing argument to parameter 'Arg' here}}
 @end
 
 void Func (I* arg);  // expected-note {{candidate function not viable: no known conversion from 'I const *' to 'I *' for 1st argument}}
diff --git a/test/SemaTemplate/default-expr-arguments.cpp b/test/SemaTemplate/default-expr-arguments.cpp
index d2cc45b..40b7f2b 100644
--- a/test/SemaTemplate/default-expr-arguments.cpp
+++ b/test/SemaTemplate/default-expr-arguments.cpp
@@ -7,7 +7,8 @@
 
 struct S { }; // expected-note 3 {{candidate constructor (the implicit copy constructor)}}
 
-template<typename T> void f1(T a, T b = 10) { } // expected-error{{no viable conversion}}
+template<typename T> void f1(T a, T b = 10) { } // expected-error{{no viable conversion}} \
+// expected-note{{passing argument to parameter 'b' here}}
 
 template<typename T> void f2(T a, T b = T()) { }
 
@@ -25,8 +26,10 @@
 }
 
 template<typename T> struct F {
-  F(T t = 10); // expected-error{{no viable conversion}}
-  void f(T t = 10); // expected-error{{no viable conversion}}
+  F(T t = 10); // expected-error{{no viable conversion}} \
+  // expected-note{{passing argument to parameter 't' here}}
+  void f(T t = 10); // expected-error{{no viable conversion}} \
+  // expected-note{{passing argument to parameter 't' here}}
 };
 
 struct FD : F<int> { };
@@ -99,7 +102,8 @@
 // PR5283
 namespace PR5283 {
 template<typename T> struct A {
-  A(T = 1); // expected-error 3 {{cannot initialize a parameter of type 'int *' with an rvalue of type 'int'}}
+  A(T = 1); // expected-error 3 {{cannot initialize a parameter of type 'int *' with an rvalue of type 'int'}} \
+  // expected-note 3{{passing argument to parameter here}}
 };
 
 struct B : A<int*> { 
diff --git a/test/SemaTemplate/instantiate-member-template.cpp b/test/SemaTemplate/instantiate-member-template.cpp
index c1260cf..ae8425e 100644
--- a/test/SemaTemplate/instantiate-member-template.cpp
+++ b/test/SemaTemplate/instantiate-member-template.cpp
@@ -44,7 +44,7 @@
   
   template<typename U>
   struct Inner3 {
-    void f0(T t, U u) {
+    void f0(T t, U u) { // expected-note{{passing argument to parameter 't' here}}
       (void)(t + u); // expected-error{{invalid operands}}
     }