[PATCH] D80514: [clang-tidy] modernize-use-trailing-return-type support for C++20 concepts and decltype

Bernhard Manfred Gruber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 25 03:42:29 PDT 2020


bernhardmgruber created this revision.
bernhardmgruber added reviewers: aaron.ballman, JonasToth, Eugene.Zelenko, lebedev.ri.
bernhardmgruber added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
bernhardmgruber updated this revision to Diff 265993.
bernhardmgruber edited the summary of this revision.
bernhardmgruber marked 3 inline comments as done.
bernhardmgruber added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp:285-302
+    SourceLocation End =
+        expandIfMacroId(ReturnLoc.getSourceRange().getEnd(), SM);
+    SourceLocation BeginNameF = expandIfMacroId(F.getLocation(), SM);
+
+    // Extend the ReturnTypeRange until the last token before the function
+    // name.
+    std::pair<FileID, unsigned> Loc = SM.getDecomposedLoc(End);
----------------
Is there an easier way to get the token previous to the function name?


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/modernize-use-trailing-return-type.rst:22
+  virtual float f3() const && = delete;    virtual auto f3() const && -> float = delete;
+======================================== ===============================================
 
----------------
I tried 2 online rst editors and they failed to format the code blocks inside the tables. Will this work with the clang documentation?


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp:550
+
+#if __cplusplus > 201703L /* C++2a and later */
+
----------------
How do you want to handle these tests which require C++20? I have seen other checks use a separate file for tests which require a different language version.


- fixed flags in RUN declaration in lit test
- added tests for C++20 concepts and requires clause
- added manual tokenization for AutoType return types which are not plain 'auto' to find source range
  - 'const auto'
  - 'Concept<int> auto'
  - 'decltype(auto)'
- improved formatting of documentation
- support for 'decltype(...)'
- added test for bug 44206, which seems to be fixed


https://reviews.llvm.org/D80514

Files:
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-trailing-return-type.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80514.265993.patch
Type: text/x-patch
Size: 15924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200525/fb074aaa/attachment-0001.bin>


More information about the cfe-commits mailing list