[clang-tools-extra] 47dbacb - [clang-tidy] Restrict use-equals-default to c++11-or-later

Alexander Shaposhnikov via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 2 15:19:44 PDT 2022


Author: Alexander Shaposhnikov
Date: 2022-09-02T22:19:11Z
New Revision: 47dbacbc8ae2c13f970096814de8f677d80859af

URL: https://github.com/llvm/llvm-project/commit/47dbacbc8ae2c13f970096814de8f677d80859af
DIFF: https://github.com/llvm/llvm-project/commit/47dbacbc8ae2c13f970096814de8f677d80859af.diff

LOG: [clang-tidy] Restrict use-equals-default to c++11-or-later

Restrict use-equals-default to c++11-or-later.

Test plan: ninja check-all

Differential revision: https://reviews.llvm.org/D132998

Added: 
    clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp

Modified: 
    clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
    clang-tools-extra/docs/ReleaseNotes.rst

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
index a992177522f75..4ffed8c406481 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.h
@@ -38,7 +38,7 @@ class UseEqualsDefaultCheck : public ClangTidyCheck {
 public:
   UseEqualsDefaultCheck(StringRef Name, ClangTidyContext *Context);
   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
-    return LangOpts.CPlusPlus;
+    return LangOpts.CPlusPlus11;
   }
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 55c8c341bff3a..e0907b23c84c7 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -145,7 +145,7 @@ Changes in existing checks
   check.
 
   The check now skips unions since in this case a default constructor with empty body
-  is not equivalent to the explicitly defaulted one.
+  is not equivalent to the explicitly defaulted one. The check is restricted to c++11-or-later.
 
 Removed checks
 ^^^^^^^^^^^^^^

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp
new file mode 100644
index 0000000000000..d43c1e58c2606
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-cxx98.cpp
@@ -0,0 +1,8 @@
+// RUN: %check_clang_tidy -std=c++98 %s modernize-use-equals-default %t
+
+struct S {
+  S() {}
+  // CHECK-FIXES: S() {}
+  ~S() {}
+  // CHECK-FIXES: ~S() {}
+};


        


More information about the cfe-commits mailing list