<div dir="ltr">Hello Alexander,<br><br>Couple of our builders do not like this commit:<br><br>Failing Tests:<br><br>    Clang Tools :: clang-tidy/modernize-use-noexcept-opt.cpp<br>    Clang Tools :: clang-tidy/modernize-use-noexcept.cpp<br><br><a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/12431">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/12431</a><br><a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast</a><br><br>Please have a look at this?<br><br>Thanks<br><br>Galina<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 8, 2017 at 7:04 AM, Alexander Kornienko via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: alexfh<br>
Date: Thu Jun  8 09:04:16 2017<br>
New Revision: 304977<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=304977&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=304977&view=rev</a><br>
Log:<br>
[clang-tidy] New checker to replace dynamic exception specifications<br>
<br>
Summary:<br>
New checker to replace dynamic exception<br>
specifications<br>
<br>
This is an alternative to D18575 which relied on reparsing the decl to<br>
find the location of dynamic exception specifications, but couldn't<br>
deal with preprocessor conditionals correctly without reparsing the<br>
entire file.<br>
<br>
This approach uses D20428 to find dynamic exception specification<br>
locations and handles all cases correctly.<br>
<br>
Reviewers: aaron.ballman, alexfh<br>
<br>
Reviewed By: aaron.ballman, alexfh<br>
<br>
Subscribers: xazax.hun, mgehre, malcolm.parsons, mgorny, JDevlieghere, cfe-commits, Eugene.Zelenko, etienneb<br>
<br>
Patch by Don Hinton!<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D20693" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D20693</a><br>
<br>
Added:<br>
    clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>UseNoexceptCheck.cpp<br>
    clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>UseNoexceptCheck.h<br>
    clang-tools-extra/trunk/docs/<wbr>clang-tidy/checks/modernize-<wbr>use-noexcept.rst<br>
    clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept-macro.cpp<br>
    clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept-opt.cpp<br>
    clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept.cpp<br>
Modified:<br>
    clang-tools-extra/trunk/clang-<wbr>tidy/modernize/CMakeLists.txt<br>
    clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>ModernizeTidyModule.cpp<br>
    clang-tools-extra/trunk/docs/<wbr>ReleaseNotes.rst<br>
    clang-tools-extra/trunk/docs/<wbr>clang-tidy/checks/list.rst<br>
<br>
Modified: clang-tools-extra/trunk/clang-<wbr>tidy/modernize/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=304977&r1=304976&r2=304977&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/clang-tidy/modernize/<wbr>CMakeLists.txt?rev=304977&r1=<wbr>304976&r2=304977&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/clang-<wbr>tidy/modernize/CMakeLists.txt (original)<br>
+++ clang-tools-extra/trunk/clang-<wbr>tidy/modernize/CMakeLists.txt Thu Jun  8 09:04:16 2017<br>
@@ -22,6 +22,7 @@ add_clang_library(<wbr>clangTidyModernizeModu<br>
   UseEmplaceCheck.cpp<br>
   UseEqualsDefaultCheck.cpp<br>
   UseEqualsDeleteCheck.cpp<br>
+  UseNoexceptCheck.cpp<br>
   UseNullptrCheck.cpp<br>
   UseOverrideCheck.cpp<br>
   UseTransparentFunctorsCheck.<wbr>cpp<br>
<br>
Modified: clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>ModernizeTidyModule.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=304977&r1=304976&r2=304977&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/clang-tidy/modernize/<wbr>ModernizeTidyModule.cpp?rev=<wbr>304977&r1=304976&r2=304977&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>ModernizeTidyModule.cpp (original)<br>
+++ clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>ModernizeTidyModule.cpp Thu Jun  8 09:04:16 2017<br>
@@ -28,6 +28,7 @@<br>
 #include "UseEmplaceCheck.h"<br>
 #include "UseEqualsDefaultCheck.h"<br>
 #include "UseEqualsDeleteCheck.h"<br>
+#include "UseNoexceptCheck.h"<br>
 #include "UseNullptrCheck.h"<br>
 #include "UseOverrideCheck.h"<br>
 #include "UseTransparentFunctorsCheck.<wbr>h"<br>
@@ -69,6 +70,7 @@ public:<br>
     CheckFactories.registerCheck<<wbr>UseEqualsDefaultCheck>("<wbr>modernize-use-equals-default")<wbr>;<br>
     CheckFactories.registerCheck<<wbr>UseEqualsDeleteCheck>(<br>
         "modernize-use-equals-delete")<wbr>;<br>
+    CheckFactories.registerCheck<<wbr>UseNoexceptCheck>("modernize-<wbr>use-noexcept");<br>
     CheckFactories.registerCheck<<wbr>UseNullptrCheck>("modernize-<wbr>use-nullptr");<br>
     CheckFactories.registerCheck<<wbr>UseOverrideCheck>("modernize-<wbr>use-override");<br>
     CheckFactories.registerCheck<<wbr>UseTransparentFunctorsCheck>(<br>
<br>
Added: clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>UseNoexceptCheck.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.cpp?rev=304977&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/clang-tidy/modernize/<wbr>UseNoexceptCheck.cpp?rev=<wbr>304977&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>UseNoexceptCheck.cpp (added)<br>
+++ clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>UseNoexceptCheck.cpp Thu Jun  8 09:04:16 2017<br>
@@ -0,0 +1,114 @@<br>
+//===--- UseNoexceptCheck.cpp - clang-tidy--------------------<wbr>-------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#include "UseNoexceptCheck.h"<br>
+#include "clang/AST/ASTContext.h"<br>
+#include "clang/Lex/Lexer.h"<br>
+<br>
+using namespace clang::ast_matchers;<br>
+<br>
+namespace clang {<br>
+namespace tidy {<br>
+namespace modernize {<br>
+<br>
+UseNoexceptCheck::<wbr>UseNoexceptCheck(StringRef Name, ClangTidyContext *Context)<br>
+    : ClangTidyCheck(Name, Context),<br>
+      NoexceptMacro(Options.get("<wbr>ReplacementString", "")),<br>
+      UseNoexceptFalse(Options.get("<wbr>UseNoexceptFalse", true)) {}<br>
+<br>
+void UseNoexceptCheck::<wbr>storeOptions(ClangTidyOptions:<wbr>:OptionMap &Opts) {<br>
+  Options.store(Opts, "ReplacementString", NoexceptMacro);<br>
+  Options.store(Opts, "UseNoexceptFalse", UseNoexceptFalse);<br>
+}<br>
+<br>
+void UseNoexceptCheck::<wbr>registerMatchers(MatchFinder *Finder) {<br>
+  if (!getLangOpts().CPlusPlus11)<br>
+    return;<br>
+<br>
+  Finder->addMatcher(<br>
+      functionDecl(<br>
+          cxxMethodDecl(<br>
+              hasTypeLoc(loc(<wbr>functionProtoType(<wbr>hasDynamicExceptionSpec()))),<br>
+              anyOf(<wbr>hasOverloadedOperatorName("<wbr>delete[]"),<br>
+                    hasOverloadedOperatorName("<wbr>delete"), cxxDestructorDecl()))<br>
+              .bind("del-dtor"))<br>
+          .bind("funcDecl"),<br>
+      this);<br>
+<br>
+  Finder->addMatcher(<br>
+      functionDecl(<br>
+          hasTypeLoc(loc(<wbr>functionProtoType(<wbr>hasDynamicExceptionSpec()))),<br>
+          unless(anyOf(<wbr>hasOverloadedOperatorName("<wbr>delete[]"),<br>
+                       hasOverloadedOperatorName("<wbr>delete"),<br>
+                       cxxDestructorDecl())))<br>
+          .bind("funcDecl"),<br>
+      this);<br>
+<br>
+  Finder->addMatcher(<br>
+      parmVarDecl(anyOf(hasType(<wbr>pointerType(pointee(parenType(<wbr>innerType(<br>
+                            functionProtoType(<wbr>hasDynamicExceptionSpec())))))<wbr>),<br>
+                        hasType(memberPointerType(<wbr>pointee(parenType(innerType(<br>
+                            functionProtoType(<wbr>hasDynamicExceptionSpec())))))<wbr>)))<br>
+          .bind("parmVarDecl"),<br>
+      this);<br>
+}<br>
+<br>
+void UseNoexceptCheck::check(const MatchFinder::MatchResult &Result) {<br>
+  const FunctionProtoType *FnTy = nullptr;<br>
+  bool DtorOrOperatorDel = false;<br>
+  SourceRange Range;<br>
+<br>
+  if (const auto *FuncDecl = Result.Nodes.getNodeAs<<wbr>FunctionDecl>("funcDecl")) {<br>
+    DtorOrOperatorDel = Result.Nodes.getNodeAs<<wbr>FunctionDecl>("del-dtor");<br>
+    FnTy = FuncDecl->getType()->getAs<<wbr>FunctionProtoType>();<br>
+    if (const auto *TSI = FuncDecl->getTypeSourceInfo())<br>
+      Range =<br>
+          TSI->getTypeLoc().castAs<<wbr>FunctionTypeLoc>().<wbr>getExceptionSpecRange();<br>
+  } else if (const auto *ParmDecl =<br>
+                 Result.Nodes.getNodeAs<<wbr>ParmVarDecl>("parmVarDecl")) {<br>
+    FnTy = ParmDecl->getType()<br>
+               ->getAs<Type>()<br>
+               ->getPointeeType()<br>
+               ->getAs<FunctionProtoType>();<br>
+<br>
+    if (const auto *TSI = ParmDecl->getTypeSourceInfo())<br>
+      Range = TSI->getTypeLoc()<br>
+                  .getNextTypeLoc()<br>
+                  .IgnoreParens()<br>
+                  .castAs<FunctionProtoTypeLoc>(<wbr>)<br>
+                  .getExceptionSpecRange();<br>
+  }<br>
+  CharSourceRange CRange = Lexer::makeFileCharRange(<br>
+      CharSourceRange::<wbr>getTokenRange(Range), *Result.SourceManager,<br>
+      Result.Context->getLangOpts())<wbr>;<br>
+<br>
+  assert(FnTy && "FunctionProtoType is null.");<br>
+  bool IsNoThrow = FnTy->isNothrow(*Result.<wbr>Context);<br>
+  StringRef ReplacementStr =<br>
+      IsNoThrow<br>
+          ? NoexceptMacro.empty() ? "noexcept" : NoexceptMacro.c_str()<br>
+          : NoexceptMacro.empty()<br>
+                ? (DtorOrOperatorDel || UseNoexceptFalse) ? "noexcept(false)"<br>
+                                                          : ""<br>
+                : "";<br>
+<br>
+  FixItHint FixIt;<br>
+  if ((IsNoThrow || NoexceptMacro.empty()) && CRange.isValid())<br>
+    FixIt = FixItHint::CreateReplacement(<wbr>CRange, ReplacementStr);<br>
+<br>
+  diag(Range.getBegin(), "dynamic exception specification '%0' is deprecated; "<br>
+                         "consider %select{using '%2'|removing it}1 instead")<br>
+      << Lexer::getSourceText(CRange, *Result.SourceManager,<br>
+                              Result.Context->getLangOpts())<br>
+      << ReplacementStr.empty() << ReplacementStr << FixIt;<br>
+}<br>
+<br>
+} // namespace modernize<br>
+} // namespace tidy<br>
+} // namespace clang<br>
<br>
Added: clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>UseNoexceptCheck.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNoexceptCheck.h?rev=304977&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/clang-tidy/modernize/<wbr>UseNoexceptCheck.h?rev=304977&<wbr>view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>UseNoexceptCheck.h (added)<br>
+++ clang-tools-extra/trunk/clang-<wbr>tidy/modernize/<wbr>UseNoexceptCheck.h Thu Jun  8 09:04:16 2017<br>
@@ -0,0 +1,49 @@<br>
+//===--- UseNoexceptCheck.h - clang-tidy--------------------<wbr>-----*- C++ -*-===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_<wbr>TIDY_MODERNIZE_USE_NOEXCEPT_H<br>
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_<wbr>TIDY_MODERNIZE_USE_NOEXCEPT_H<br>
+<br>
+#include "../ClangTidy.h"<br>
+<br>
+namespace clang {<br>
+namespace tidy {<br>
+namespace modernize {<br>
+<br>
+/// \brief Replace dynamic exception specifications, with<br>
+/// `noexcept` (or user-defined macro) or `noexcept(false)`.<br>
+/// \code<br>
+///   void foo() throw();<br>
+///   void bar() throw(int);<br>
+/// \endcode<br>
+/// Is converted to:<br>
+/// \code<br>
+///   void foo() ;<br>
+//    void bar() noexcept(false);<br>
+/// \endcode<br>
+///<br>
+/// For the user-facing documentation see:<br>
+/// <a href="http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-noexcept.html" rel="noreferrer" target="_blank">http://clang.llvm.org/extra/<wbr>clang-tidy/checks/modernize-<wbr>use-noexcept.html</a><br>
+class UseNoexceptCheck : public ClangTidyCheck {<br>
+public:<br>
+  UseNoexceptCheck(StringRef Name, ClangTidyContext *Context);<br>
+  void storeOptions(ClangTidyOptions:<wbr>:OptionMap &Opts) override;<br>
+  void registerMatchers(ast_matchers:<wbr>:MatchFinder *Finder) override;<br>
+  void check(const ast_matchers::MatchFinder::<wbr>MatchResult &Result) override;<br>
+<br>
+private:<br>
+  const std::string NoexceptMacro;<br>
+  bool UseNoexceptFalse;<br>
+};<br>
+<br>
+} // namespace modernize<br>
+} // namespace tidy<br>
+} // namespace clang<br>
+<br>
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_<wbr>TIDY_MODERNIZE_USE_NOEXCEPT_H<br>
<br>
Modified: clang-tools-extra/trunk/docs/<wbr>ReleaseNotes.rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=304977&r1=304976&r2=304977&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/docs/ReleaseNotes.rst?<wbr>rev=304977&r1=304976&r2=<wbr>304977&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/docs/<wbr>ReleaseNotes.rst (original)<br>
+++ clang-tools-extra/trunk/docs/<wbr>ReleaseNotes.rst Thu Jun  8 09:04:16 2017<br>
@@ -100,6 +100,11 @@ Improvements to clang-tidy<br>
   to remove user-defined make functions from ``push_back`` calls on containers<br>
   of custom tuple-like types by providing `TupleTypes` and `TupleMakeFunctions`.<br>
<br>
+ - New `modernize-use-noexcept<br>
+   <<a href="http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-noexcept.html" rel="noreferrer" target="_blank">http://clang.llvm.org/extra/<wbr>clang-tidy/checks/modernize-<wbr>use-noexcept.html</a>>`_ check<br>
+<br>
+   Replaces dynamic exception specifications with ``noexcept`` or a user defined macro.<br>
+<br>
 - New `performance-inefficient-<wbr>vector-operation<br>
   <<a href="http://clang.llvm.org/extra/clang-tidy/checks/performance-inefficient-vector-operation.html" rel="noreferrer" target="_blank">http://clang.llvm.org/extra/<wbr>clang-tidy/checks/performance-<wbr>inefficient-vector-operation.<wbr>html</a>>`_ check<br>
<br>
<br>
Modified: clang-tools-extra/trunk/docs/<wbr>clang-tidy/checks/list.rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=304977&r1=304976&r2=304977&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/docs/clang-tidy/checks/<wbr>list.rst?rev=304977&r1=304976&<wbr>r2=304977&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/docs/<wbr>clang-tidy/checks/list.rst (original)<br>
+++ clang-tools-extra/trunk/docs/<wbr>clang-tidy/checks/list.rst Thu Jun  8 09:04:16 2017<br>
@@ -135,6 +135,7 @@ Clang-Tidy Checks<br>
    modernize-use-emplace<br>
    modernize-use-equals-default<br>
    modernize-use-equals-delete<br>
+   modernize-use-noexcept<br>
    modernize-use-nullptr<br>
    modernize-use-override<br>
    modernize-use-transparent-<wbr>functors<br>
<br>
Added: clang-tools-extra/trunk/docs/<wbr>clang-tidy/checks/modernize-<wbr>use-noexcept.rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-noexcept.rst?rev=304977&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/docs/clang-tidy/checks/<wbr>modernize-use-noexcept.rst?<wbr>rev=304977&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/docs/<wbr>clang-tidy/checks/modernize-<wbr>use-noexcept.rst (added)<br>
+++ clang-tools-extra/trunk/docs/<wbr>clang-tidy/checks/modernize-<wbr>use-noexcept.rst Thu Jun  8 09:04:16 2017<br>
@@ -0,0 +1,90 @@<br>
+.. title:: clang-tidy - modernize-use-noexcept<br>
+<br>
+modernize-use-noexcept<br>
+======================<br>
+<br>
+This check replaces deprecated dynamic exception specifications with<br>
+the appropriate noexcept specification (introduced in C++11).  By<br>
+default this check will replace ``throw()`` with ``noexcept``,<br>
+and ``throw(<exception>[,...])`` or ``throw(...)`` with<br>
+``noexcept(false)``.<br>
+<br>
+Example<br>
+-------<br>
+<br>
+.. code-block:: c++<br>
+<br>
+  void foo() throw();<br>
+       void bar() throw(int) {}<br>
+<br>
+transforms to:<br>
+<br>
+.. code-block:: c++<br>
+<br>
+  void foo() noexcept;<br>
+       void bar() noexcept(false) {}<br>
+<br>
+Options<br>
+-------<br>
+<br>
+.. option:: ReplacementString<br>
+<br>
+Users can use :option:`ReplacementString` to specify a macro to use<br>
+instead of ``noexcept``.  This is useful when maintaining source code<br>
+that uses custom exception specification marking other than<br>
+``noexcept``.  Fix-it hints will only be generated for non-throwing<br>
+specifications.<br>
+<br>
+Example<br>
+^^^^^^^<br>
+<br>
+.. code-block:: c++<br>
+<br>
+  void bar() throw(int);<br>
+  void foo() throw();<br>
+<br>
+transforms to:<br>
+<br>
+.. code-block:: c++<br>
+<br>
+  void bar() throw(int);  // No fix-it generated.<br>
+  void foo() NOEXCEPT;<br>
+<br>
+if the :option:`ReplacementString` option is set to `NOEXCEPT`.<br>
+<br>
+.. option:: UseNoexceptFalse<br>
+<br>
+Enabled by default, disabling will generate fix-it hints that remove<br>
+throwing dynamic exception specs, e.g., ``throw(<something>)``,<br>
+completely without providing a replacement text, except for<br>
+destructors and delete operators that are ``noexcept(true)`` by<br>
+default.<br>
+<br>
+Example<br>
+^^^^^^^<br>
+<br>
+.. code-block:: c++<br>
+<br>
+  void foo() throw(int) {}<br>
+<br>
+  struct bar {<br>
+    void foobar() throw(int);<br>
+    void operator delete(void *ptr) throw(int);<br>
+    void operator delete[](void *ptr) throw(int);<br>
+    ~bar() throw(int);<br>
+  }<br>
+<br>
+transforms to:<br>
+<br>
+.. code-block:: c++<br>
+<br>
+  void foo() {}<br>
+<br>
+  struct bar {<br>
+    void foobar();<br>
+    void operator delete(void *ptr) noexcept(false);<br>
+    void operator delete[](void *ptr) noexcept(false);<br>
+    ~bar() noexcept(false);<br>
+  }<br>
+<br>
+if the :option:`UseNoexceptFalse` option is set to `0`.<br>
<br>
Added: clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept-macro.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp?rev=304977&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/test/clang-tidy/<wbr>modernize-use-noexcept-macro.<wbr>cpp?rev=304977&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept-macro.cpp (added)<br>
+++ clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept-macro.cpp Thu Jun  8 09:04:16 2017<br>
@@ -0,0 +1,36 @@<br>
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \<br>
+// RUN:   -config="{CheckOptions: [{key: modernize-use-noexcept.<wbr>ReplacementString, value: 'NOEXCEPT'}]}" \<br>
+// RUN:   -- -std=c++11<br>
+<br>
+// Example definition of NOEXCEPT -- simplified test to see if noexcept is supported.<br>
+#if (__has_feature(cxx_noexcept))<br>
+#define NOEXCEPT noexcept<br>
+#else<br>
+#define NOEXCEPT throw()<br>
+#endif<br>
+<br>
+void bar() throw() {}<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'NOEXCEPT' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void bar() NOEXCEPT {}<br>
+<br>
+// Should not trigger a FixItHint, since macros only support noexcept, and this<br>
+// case throws.<br>
+class A {};<br>
+class B {};<br>
+void foobar() throw(A, B);<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+<br>
+// Should not trigger a replacement.<br>
+void foo() noexcept(true);<br>
+<br>
+struct Z {<br>
+  void operator delete(void *ptr) throw();<br>
+  void operator delete[](void *ptr) throw(int);<br>
+  ~Z() throw(int) {}<br>
+};<br>
+// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'NOEXCEPT' instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void operator delete(void *ptr) NOEXCEPT;<br>
+// CHECK-FIXES: void operator delete[](void *ptr) throw(int);<br>
+// CHECK-FIXES: ~Z() throw(int) {}<br>
<br>
Added: clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept-opt.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp?rev=304977&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/test/clang-tidy/<wbr>modernize-use-noexcept-opt.<wbr>cpp?rev=304977&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept-opt.cpp (added)<br>
+++ clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept-opt.cpp Thu Jun  8 09:04:16 2017<br>
@@ -0,0 +1,88 @@<br>
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \<br>
+// RUN:   -config="{CheckOptions: [{key: modernize-use-noexcept.<wbr>UseNoexceptFalse, value: 0}]}" \<br>
+// RUN:   -- -std=c++11<br>
+<br>
+class A {};<br>
+class B {};<br>
+<br>
+void foo() throw();<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void foo() noexcept;<br>
+<br>
+void bar() throw(...);<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw(...)' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void bar() ;<br>
+<br>
+void k() throw(int(int));<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void k() ;<br>
+<br>
+void foobar() throw(A, B)<br>
+{}<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void foobar()<br>
+<br>
+void baz(int = (throw A(), 0)) throw(A, B) {}<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void baz(int = (throw A(), 0)) {}<br>
+<br>
+void g(void (*fp)(void) throw());<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void g(void (*fp)(void) noexcept);<br>
+<br>
+void f(void (*fp)(void) throw(int)) throw(char);<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw(int)' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'throw(char)' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void f(void (*fp)(void) ) ;<br>
+<br>
+#define THROW throw<br>
+void h(void (*fp)(void) THROW(int)) THROW(char);<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'THROW(int)' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'THROW(char)' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void h(void (*fp)(void) ) ;<br>
+<br>
+void j() throw(int(int) throw(void(void) throw(int)));<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' is deprecated; consider removing it instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void j() ;<br>
+<br>
+class Y {<br>
+  Y() throw() = default;<br>
+};<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: Y() noexcept = default;<br>
+<br>
+struct Z {<br>
+  void operator delete(void *ptr) throw();<br>
+  void operator delete[](void *ptr) throw(int);<br>
+  ~Z() throw(int) {}<br>
+};<br>
+// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void operator delete(void *ptr) noexcept;<br>
+// CHECK-FIXES: void operator delete[](void *ptr) noexcept(false);<br>
+// CHECK-FIXES: ~Z() noexcept(false) {}<br>
+<br>
+struct S {<br>
+  void f() throw();<br>
+};<br>
+void f(void (S::*)() throw());<br>
+// CHECK-MESSAGES: :[[@LINE-3]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:22: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void f() noexcept;<br>
+// CHECK-FIXES: void f(void (S::*)() noexcept);<br>
+<br>
+typedef void (*fp)(void (*fp2)(int) throw());<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: typedef void (*fp)(void (*fp2)(int) noexcept);<br>
+<br>
+// Should not trigger a replacement.<br>
+void titi() noexcept {}<br>
+void toto() noexcept(true) {}<br>
+<br>
+// Should not trigger a replacement.<br>
+void bad()<br>
+#if !__has_feature(cxx_noexcept)<br>
+    throw()<br>
+#endif<br>
+  ;<br>
<br>
Added: clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp?rev=304977&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/test/clang-tidy/<wbr>modernize-use-noexcept.cpp?<wbr>rev=304977&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept.cpp (added)<br>
+++ clang-tools-extra/trunk/test/<wbr>clang-tidy/modernize-use-<wbr>noexcept.cpp Thu Jun  8 09:04:16 2017<br>
@@ -0,0 +1,104 @@<br>
+// RUN: %check_clang_tidy %s modernize-use-noexcept %t -- \<br>
+// RUN:   -- -std=c++11<br>
+<br>
+class A {};<br>
+class B {};<br>
+<br>
+void foo() throw();<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void foo() noexcept;<br>
+<br>
+template <typename T><br>
+void foo() throw();<br>
+void footest() { foo<int>(); foo<double>(); }<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void foo() noexcept;<br>
+<br>
+void bar() throw(...);<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw(...)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void bar() noexcept(false);<br>
+<br>
+void k() throw(int(int));<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void k() noexcept(false);<br>
+<br>
+void foobar() throw(A, B)<br>
+{}<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void foobar() noexcept(false)<br>
+<br>
+void baz(int = (throw A(), 0)) throw(A, B) {}<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void baz(int = (throw A(), 0)) noexcept(false) {}<br>
+<br>
+void g(void (*fp)(void) throw());<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void g(void (*fp)(void) noexcept);<br>
+<br>
+void f(void (*fp)(void) throw(int)) throw(char);<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'throw(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void f(void (*fp)(void) noexcept(false)) noexcept(false);<br>
+<br>
+#define THROW throw<br>
+void h(void (*fp)(void) THROW(int)) THROW(char);<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'THROW(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'THROW(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void h(void (*fp)(void) noexcept(false)) noexcept(false);<br>
+<br>
+void j() throw(int(int) throw(void(void) throw(int)));<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void j() noexcept(false);<br>
+<br>
+class Y {<br>
+  Y() throw() = default;<br>
+};<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: Y() noexcept = default;<br>
+<br>
+struct Z {<br>
+  void operator delete(void *ptr) throw();<br>
+  void operator delete[](void *ptr) throw(int);<br>
+  ~Z() throw(int) {}<br>
+};<br>
+// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void operator delete(void *ptr) noexcept;<br>
+// CHECK-FIXES: void operator delete[](void *ptr) noexcept(false);<br>
+// CHECK-FIXES: ~Z() noexcept(false) {}<br>
+<br>
+struct S {<br>
+  void f() throw();<br>
+};<br>
+void f(void (S::*)() throw());<br>
+// CHECK-MESSAGES: :[[@LINE-3]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:22: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void f() noexcept;<br>
+// CHECK-FIXES: void f(void (S::*)() noexcept);<br>
+<br>
+template <typename T><br>
+struct ST {<br>
+  void foo() throw();<br>
+};<br>
+template <typename T><br>
+void ft(void (ST<T>::*)() throw());<br>
+// CHECK-MESSAGES: :[[@LINE-4]]:14: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-MESSAGES: :[[@LINE-2]]:27: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: void foo() noexcept;<br>
+// CHECK-FIXES: void ft(void (ST<T>::*)() noexcept);<br>
+<br>
+typedef void (*fp)(void (*fp2)(int) throw());<br>
+// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]<br>
+// CHECK-FIXES: typedef void (*fp)(void (*fp2)(int) noexcept);<br>
+<br>
+// Should not trigger a replacement.<br>
+void titi() noexcept {}<br>
+void toto() noexcept(true) {}<br>
+<br>
+// Should not trigger a replacement.<br>
+void bad()<br>
+#if !__has_feature(cxx_noexcept)<br>
+    throw()<br>
+#endif<br>
+  ;<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>