[clang-tools-extra] fc3c693 - [clang-tidy] Added alias llvm-else-after-return.
Nathan James via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 6 06:39:14 PDT 2020
Author: Nathan James
Date: 2020-07-06T14:39:03+01:00
New Revision: fc3c693b617fc5fde8939a3aec7e7372ace07693
URL: https://github.com/llvm/llvm-project/commit/fc3c693b617fc5fde8939a3aec7e7372ace07693
DIFF: https://github.com/llvm/llvm-project/commit/fc3c693b617fc5fde8939a3aec7e7372ace07693.diff
LOG: [clang-tidy] Added alias llvm-else-after-return.
Added an alias llvm-else-after-return from readability-else-after-return to help enforce one of the llvm coding guidelines.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D82825
Added:
clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst
Modified:
clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
index 2aaf07639267..0310a8e07a2d 100644
--- a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
@@ -9,6 +9,7 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
+#include "../readability/ElseAfterReturnCheck.h"
#include "../readability/NamespaceCommentCheck.h"
#include "../readability/QualifiedAutoCheck.h"
#include "HeaderGuardCheck.h"
@@ -24,6 +25,8 @@ namespace llvm_check {
class LLVMModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+ CheckFactories.registerCheck<readability::ElseAfterReturnCheck>(
+ "llvm-else-after-return");
CheckFactories.registerCheck<LLVMHeaderGuardCheck>("llvm-header-guard");
CheckFactories.registerCheck<IncludeOrderCheck>("llvm-include-order");
CheckFactories.registerCheck<readability::NamespaceCommentCheck>(
@@ -40,6 +43,9 @@ class LLVMModule : public ClangTidyModule {
ClangTidyOptions getModuleOptions() override {
ClangTidyOptions Options;
Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0";
+ Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0";
+ Options.CheckOptions["llvm-else-after-return.RefactorConditionVariables"] =
+ "0";
return Options;
}
};
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 7593554d896d..c66d5eb6069e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -192,6 +192,11 @@ New check aliases
:doc:`bugprone-signed-char-misuse
<clang-tidy/checks/bugprone-signed-char-misuse>` was added.
+- New alias :doc:`llvm-else-after-return
+ <clang-tidy/checks/llvm-else-after-return>` to
+ :doc:`readability-else-after-return
+ <clang-tidy/checks/readability-else-after-return>` was added.
+
Changes in existing checks
^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index baa142e28e7f..7356c585d20c 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -423,4 +423,5 @@ Clang-Tidy Checks
`hicpp-use-nullptr <hicpp-use-nullptr.html>`_, `modernize-use-nullptr <modernize-use-nullptr.html>`_, "Yes"
`hicpp-use-override <hicpp-use-override.html>`_, `modernize-use-override <modernize-use-override.html>`_, "Yes"
`hicpp-vararg <hicpp-vararg.html>`_, `cppcoreguidelines-pro-type-vararg <cppcoreguidelines-pro-type-vararg.html>`_,
+ `llvm-else-after-return <llvm-else-after-return.html>`_, `readability-else-after-return <readability-else-after-return.html>`_, "Yes"
`llvm-qualified-auto <llvm-qualified-auto.html>`_, `readability-qualified-auto <readability-qualified-auto.html>`_, "Yes"
diff --git a/clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst b/clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst
new file mode 100644
index 000000000000..f9af610fe50d
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst
@@ -0,0 +1,11 @@
+.. title:: clang-tidy - llvm-else-after-return
+.. meta::
+ :http-equiv=refresh: 5;URL=readability-else-after-return.html
+
+llvm-else-after-return
+======================
+
+The llvm-else-after-return check is an alias, please see
+`readability-else-after-return <readability-else-after-return.html>`_
+for more information.
+
diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst b/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
index fccb01d0e6b2..4adcd7bbfa26 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
@@ -77,3 +77,13 @@ Options
the ``if`` statement is the last statement in its parents scope.
Default value is `true`.
+
+LLVM alias
+----------
+
+There is an alias of this check called llvm-else-after-return.
+In that version the options :option:`WarnOnUnfixable` and
+:option:`WarnOnConditionVariables` are both set to `false` by default.
+
+This check helps to enforce this `LLVM Coding Standards recommendation
+<https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return>`_.
More information about the cfe-commits
mailing list