]> granicus.if.org Git - clang/commitdiff
Documentation comment parsing: when checking if we have typedef to something
authorDmitri Gribenko <gribozavr@gmail.com>
Tue, 17 Dec 2013 22:22:14 +0000 (22:22 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Tue, 17 Dec 2013 22:22:14 +0000 (22:22 +0000)
that we consider a function for the purposes of checking \param and \returns,
look through reference types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197530 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Comment.cpp
test/Sema/warn-documentation.cpp

index 292129b9602af8344fea052f68ad470912c01029..be0a29fc8fb66c00aa9c0e761cfc78a69bc0cbf1 100644 (file)
@@ -251,6 +251,11 @@ void DeclInfo::fill() {
         TL = PointerTL.getPointeeLoc().getUnqualifiedLoc();
         continue;
       }
+      // Look through reference types.
+      if (ReferenceTypeLoc ReferenceTL = TL.getAs<ReferenceTypeLoc>()) {
+        TL = ReferenceTL.getPointeeLoc().getUnqualifiedLoc();
+        continue;
+      }
       // Look through adjusted types.
       if (AdjustedTypeLoc ATL = TL.getAs<AdjustedTypeLoc>()) {
         TL = ATL.getOriginalLoc();
index 00c56015b6ca9b25a4a1cd8acb0835beb2e282bc..ad7ab181a78a8ee98bc0fcb53c69020d86fb1997 100644 (file)
@@ -326,6 +326,18 @@ typedef foo::function_wrapper<int (int aaa, int ccc)> test_function_like_typedef
 /// \returns aaa.
 typedef foo::function_wrapper<int (int aaa, int ccc)> *test_function_like_typedef6;
 
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+typedef foo::function_wrapper<int (int aaa, int ccc)> &test_function_like_typedef7;
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+typedef foo::function_wrapper<int (int aaa, int ccc)> &&test_function_like_typedef8;
+
 
 typedef int (*test_not_function_like_typedef1)(int aaa);