Parcourir la source

Documentation comment parsing: when checking if we have typedef to something
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

Dmitri Gribenko il y a 11 ans
Parent
commit
bd28dd97f6
2 fichiers modifiés avec 17 ajouts et 0 suppressions
  1. 5 0
      lib/AST/Comment.cpp
  2. 12 0
      test/Sema/warn-documentation.cpp

+ 5 - 0
lib/AST/Comment.cpp

@@ -251,6 +251,11 @@ void DeclInfo::fill() {
         TL = PointerTL.getPointeeLoc().getUnqualifiedLoc();
         TL = PointerTL.getPointeeLoc().getUnqualifiedLoc();
         continue;
         continue;
       }
       }
+      // Look through reference types.
+      if (ReferenceTypeLoc ReferenceTL = TL.getAs<ReferenceTypeLoc>()) {
+        TL = ReferenceTL.getPointeeLoc().getUnqualifiedLoc();
+        continue;
+      }
       // Look through adjusted types.
       // Look through adjusted types.
       if (AdjustedTypeLoc ATL = TL.getAs<AdjustedTypeLoc>()) {
       if (AdjustedTypeLoc ATL = TL.getAs<AdjustedTypeLoc>()) {
         TL = ATL.getOriginalLoc();
         TL = ATL.getOriginalLoc();

+ 12 - 0
test/Sema/warn-documentation.cpp

@@ -326,6 +326,18 @@ typedef foo::function_wrapper<int (int aaa, int ccc)> test_function_like_typedef
 /// \returns aaa.
 /// \returns aaa.
 typedef foo::function_wrapper<int (int aaa, int ccc)> *test_function_like_typedef6;
 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);
 typedef int (*test_not_function_like_typedef1)(int aaa);