Skip to content

Commit c5a1009

Browse files
author
joaosaffran
committed
Merge branch 'metadata/add-versioning-support' into metadata/descriptor-table
2 parents fefe820 + 746c54a commit c5a1009

File tree

820 files changed

+42968
-11786
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

820 files changed

+42968
-11786
lines changed

.github/new-prs-labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,10 @@ backend:NVPTX:
777777
- 'llvm/**/*nvptx*/**'
778778
- 'llvm/**/*NVPTX*/**'
779779

780+
backend:MIPS:
781+
- '**/*mips*'
782+
- '**/*Mips*'
783+
780784
backend:RISC-V:
781785
- clang/**/*riscv*
782786
- clang/**/*RISCV*

.github/workflows/libcxx-restart-preempted-jobs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
with:
3434
script: |
3535
const failure_regex = /Process completed with exit code 1./
36-
const preemption_regex = /The runner has received a shutdown signal/
36+
const preemption_regex = /(The runner has received a shutdown signal)|(The operation was canceled)/
3737
3838
const wf_run = context.payload.workflow_run
3939
core.notice(`Running on "${wf_run.display_title}" by @${wf_run.actor.login} (event: ${wf_run.event})\nWorkflow run URL: ${wf_run.html_url}`)

clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule STATIC
3333
RvalueReferenceParamNotMovedCheck.cpp
3434
SlicingCheck.cpp
3535
SpecialMemberFunctionsCheck.cpp
36+
UseEnumClassCheck.cpp
3637
VirtualClassDestructorCheck.cpp
3738

3839
LINK_LIBS

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "RvalueReferenceParamNotMovedCheck.h"
4949
#include "SlicingCheck.h"
5050
#include "SpecialMemberFunctionsCheck.h"
51+
#include "UseEnumClassCheck.h"
5152
#include "VirtualClassDestructorCheck.h"
5253

5354
namespace clang::tidy {
@@ -131,6 +132,8 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
131132
CheckFactories.registerCheck<SlicingCheck>("cppcoreguidelines-slicing");
132133
CheckFactories.registerCheck<modernize::UseDefaultMemberInitCheck>(
133134
"cppcoreguidelines-use-default-member-init");
135+
CheckFactories.registerCheck<UseEnumClassCheck>(
136+
"cppcoreguidelines-use-enum-class");
134137
CheckFactories.registerCheck<misc::UnconventionalAssignOperatorCheck>(
135138
"cppcoreguidelines-c-copy-assignment-signature");
136139
CheckFactories.registerCheck<VirtualClassDestructorCheck>(
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//===--- UseEnumClassCheck.cpp - clang-tidy -------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "UseEnumClassCheck.h"
10+
#include "clang/ASTMatchers/ASTMatchFinder.h"
11+
12+
using namespace clang::ast_matchers;
13+
14+
namespace clang::tidy::cppcoreguidelines {
15+
16+
UseEnumClassCheck::UseEnumClassCheck(StringRef Name, ClangTidyContext *Context)
17+
: ClangTidyCheck(Name, Context),
18+
IgnoreUnscopedEnumsInClasses(
19+
Options.get("IgnoreUnscopedEnumsInClasses", false)) {}
20+
21+
void UseEnumClassCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
22+
Options.store(Opts, "IgnoreUnscopedEnumsInClasses",
23+
IgnoreUnscopedEnumsInClasses);
24+
}
25+
26+
void UseEnumClassCheck::registerMatchers(MatchFinder *Finder) {
27+
auto EnumDecl =
28+
IgnoreUnscopedEnumsInClasses
29+
? enumDecl(unless(isScoped()), unless(hasParent(recordDecl())))
30+
: enumDecl(unless(isScoped()));
31+
Finder->addMatcher(EnumDecl.bind("unscoped_enum"), this);
32+
}
33+
34+
void UseEnumClassCheck::check(const MatchFinder::MatchResult &Result) {
35+
const auto *UnscopedEnum = Result.Nodes.getNodeAs<EnumDecl>("unscoped_enum");
36+
37+
diag(UnscopedEnum->getLocation(),
38+
"enum %0 is unscoped, use 'enum class' instead")
39+
<< UnscopedEnum;
40+
}
41+
42+
} // namespace clang::tidy::cppcoreguidelines
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===--- UseEnumClassCheck.h - clang-tidy -----------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_USEENUMCLASSCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_USEENUMCLASSCHECK_H
11+
12+
#include "../ClangTidyCheck.h"
13+
14+
namespace clang::tidy::cppcoreguidelines {
15+
16+
/// Finds unscoped (non-class) enum declarations and suggests using enum class
17+
/// instead.
18+
///
19+
/// For the user-facing documentation see:
20+
/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/use-enum-class.html
21+
class UseEnumClassCheck : public ClangTidyCheck {
22+
public:
23+
UseEnumClassCheck(StringRef Name, ClangTidyContext *Context);
24+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
25+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
26+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
27+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
28+
return LangOpts.CPlusPlus11;
29+
}
30+
std::optional<TraversalKind> getCheckTraversalKind() const override {
31+
return TraversalKind::TK_IgnoreUnlessSpelledInSource;
32+
}
33+
34+
private:
35+
const bool IgnoreUnscopedEnumsInClasses;
36+
};
37+
38+
} // namespace clang::tidy::cppcoreguidelines
39+
40+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_USEENUMCLASSCHECK_H

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ New checks
136136
Finds unintended character output from ``unsigned char`` and ``signed char``
137137
to an ``ostream``.
138138

139+
- New :doc:`cppcoreguidelines-use-enum-class
140+
<clang-tidy/checks/cppcoreguidelines/use-enum-class>` check.
141+
142+
Finds unscoped (non-class) ``enum`` declarations and suggests using
143+
``enum class`` instead.
144+
139145
- New :doc:`portability-avoid-pragma-once
140146
<clang-tidy/checks/portability/avoid-pragma-once>` check.
141147

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.. title:: clang-tidy - cppcoreguidelines-use-enum-class
2+
3+
cppcoreguidelines-use-enum-class
4+
================================
5+
6+
Finds unscoped (non-class) ``enum`` declarations and suggests using
7+
``enum class`` instead.
8+
9+
This check implements `Enum.3
10+
<https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-class>`_
11+
from the C++ Core Guidelines."
12+
13+
Example:
14+
15+
.. code-block:: c++
16+
17+
enum E {}; // use "enum class E {};" instead
18+
enum class E {}; // OK
19+
20+
struct S {
21+
enum E {}; // use "enum class E {};" instead
22+
// OK with option IgnoreUnscopedEnumsInClasses
23+
};
24+
25+
namespace N {
26+
enum E {}; // use "enum class E {};" instead
27+
}
28+
29+
Options
30+
-------
31+
32+
.. option:: IgnoreUnscopedEnumsInClasses
33+
34+
When `true`, ignores unscoped ``enum`` declarations in classes.
35+
Default is `false`.

clang-tools-extra/docs/clang-tidy/checks/list.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ Clang-Tidy Checks
212212
:doc:`cppcoreguidelines-rvalue-reference-param-not-moved <cppcoreguidelines/rvalue-reference-param-not-moved>`,
213213
:doc:`cppcoreguidelines-slicing <cppcoreguidelines/slicing>`,
214214
:doc:`cppcoreguidelines-special-member-functions <cppcoreguidelines/special-member-functions>`,
215+
:doc:`cppcoreguidelines-use-enum-class <cppcoreguidelines/use-enum-class>`,
215216
:doc:`cppcoreguidelines-virtual-class-destructor <cppcoreguidelines/virtual-class-destructor>`, "Yes"
216217
:doc:`darwin-avoid-spinlock <darwin/avoid-spinlock>`,
217218
:doc:`darwin-dispatch-once-nonstatic <darwin/dispatch-once-nonstatic>`, "Yes"

clang-tools-extra/docs/clang-tidy/checks/performance/enum-size.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependent).
3434
.. code-block:: c++
3535

3636
// AFTER
37-
enum Color : std:int8_t {
37+
enum Color : std::int8_t {
3838
RED = -1,
3939
GREEN = 0,
4040
BLUE = 1

0 commit comments

Comments
 (0)