[PATCH] D18575: [clang-tidy] New checker to replace deprecated throw() specifications

don hinton via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 30 08:58:02 PDT 2016


hintonda added a comment.

Sounds like a good idea. I'll add the additional transformations you mentioned and remove s/noexcept(true)/noexcept/.


================
Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:24
@@ +23,3 @@
+                           char delimiter) {
+  SmallVector<StringRef, 5> Candidates;
+  AllStrings.split(Candidates, ',');
----------------
aaron.ballman wrote:
> Why 5?
No particular reason -- copied basic implementation from utils::parseHeaderFileExtensions() which did something similar.

================
Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:33
@@ +32,3 @@
+
+using namespace lexer_utils;
+
----------------
aaron.ballman wrote:
> This should not be at file scope; if it really clarifies the code, it should be at function scope where needed.
Will remove/refactor -- was just following the examples I found in other checkers.

================
Comment at: clang-tidy/modernize/UseNoexceptCheck.cpp:83
@@ +82,3 @@
+    BeforeThanCompare<SourceLocation> isBefore(SM);
+    while (isBefore(BeginLoc, CurrentLoc)) {
+      SourceLocation Loc = Tok.getLocation();
----------------
aaron.ballman wrote:
> This while loop could use some comments to explain what it is trying to do. As best I can tell, this appears to be looking purely at the text the user wrote to try to determine whether there is a `throw()` or a `noexcept(true)`, but that can be done more clearly with  FunctionType::getExceptionSpecType().
Ah, that helps a lot.  I'll use getExceptionSpecType(), but will still need to get the location of the end of the token sequence for replacement purposes, e.g., throw() is 3 tokens.


http://reviews.llvm.org/D18575





More information about the cfe-commits mailing list