[PATCH] D40787: [clang-tidy] Replace the usage of std::uncaught_exception with std::uncaught_exceptions
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 22 12:09:21 PST 2018
aaron.ballman added inline comments.
================
Comment at: clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp:45
+
+ if ((C = Result.Nodes.getNodeAs<CallExpr>("call_expr"))) {
+ BeginLoc = C->getLocStart();
----------------
Can remove spurious parens.
================
Comment at: docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst:7
+This check will warn on calls to ``std::uncaught_exception`` and replace them with
+calls to ``std::uncaught_exceptions``, since std::uncaught_exception was deprecated
+in C++17.
----------------
Backtick the use of `std::uncaught_exception`.
================
Comment at: docs/clang-tidy/checks/modernize-use-uncaught-exceptions.rst:65
+ }
\ No newline at end of file
----------------
Please add the newline to the end of the file.
================
Comment at: test/clang-tidy/modernize-use-uncaught-exceptions.cpp:43
+ // CHECK-MESSAGES: [[@LINE-1]]:9: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+ // CHECK-FIXES: res = std::uncaught_exceptions() > 0;
+
----------------
This is not ideal (the implicit conversion here would do the correct thing).
================
Comment at: test/clang-tidy/modernize-use-uncaught-exceptions.cpp:45
+
+ using std::uncaught_exception;
+ // CHECK-MESSAGES: [[@LINE-1]]:14: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
----------------
I'd like to see this, and the other examples that require it, moved into its own function body (to segregate it from cases we don't want to see the diagnostics).
================
Comment at: test/clang-tidy/modernize-use-uncaught-exceptions.cpp:64
+ // CHECK-MESSAGES: [[@LINE-1]]:10: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+ // CHECK-FIXES: foo = &uncaught_exceptions;
+
----------------
Applying this fix will break the code so that it no longer compiles.
================
Comment at: test/clang-tidy/modernize-use-uncaught-exceptions.cpp:68
+ // CHECK-MESSAGES: [[@LINE-1]]:22: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
+ // CHECK-FIXES: res = doSomething2<uncaught_exceptions>();
+
----------------
This fix seems bad. If the user accepts the fix, then the code will diagnose because there's no longer a matching call to `doSomething2()`.
https://reviews.llvm.org/D40787
More information about the cfe-commits
mailing list