diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 77ba81c58c5d63..76b8266cae87c4 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -125,3 +125,6 @@ clang/test/AST/Interp/ @tbaederr
/llvm/**/TextAPI/ @cyndyishida
/clang/**/InstallAPI/ @cyndyishida
/clang/tools/clang-installapi/ @cyndyishida
+
+# ExtractAPI
+/clang/**/ExtractAPI @daniel-grumberg
diff --git a/.github/workflows/email-check.yaml b/.github/workflows/email-check.yaml
index ac53b5e527b094..8f32d020975f5d 100644
--- a/.github/workflows/email-check.yaml
+++ b/.github/workflows/email-check.yaml
@@ -1,7 +1,7 @@
name: "Check for private emails used in PRs"
on:
- pull_request_target:
+ pull_request:
types:
- opened
@@ -10,8 +10,6 @@ permissions:
jobs:
validate_email:
- permissions:
- pull-requests: write
runs-on: ubuntu-latest
if: github.repository == 'llvm/llvm-project'
steps:
@@ -25,20 +23,24 @@ jobs:
run: |
git log -1
echo "EMAIL=$(git show -s --format='%ae' HEAD~0)" >> $GITHUB_OUTPUT
+ # Create empty comment file
+ echo "[]" > comments
- name: Validate author email
if: ${{ endsWith(steps.author.outputs.EMAIL, 'noreply.github.com') }}
- uses: actions/github-script@v6
env:
- EMAIL: ${{ steps.author.outputs.EMAIL }}
+ COMMENT: >-
+ ⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
+ Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account.
+ See [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information.
+ run: |
+ cat << EOF > comments
+ [{"body" : "$COMMENT"}]
+ EOF
+
+ - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
+ if: always()
with:
- script: |
- const { EMAIL } = process.env
- await github.rest.issues.createComment({
- issue_number: context.issue.number,
- owner: context.repo.owner,
- repo: context.repo.repo,
- body: `⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
- Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account.
- See [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information.
- `})
+ name: workflow-args
+ path: |
+ comments
diff --git a/.github/workflows/issue-write.yml b/.github/workflows/issue-write.yml
index 02a5f7c213e898..e003be006c4e15 100644
--- a/.github/workflows/issue-write.yml
+++ b/.github/workflows/issue-write.yml
@@ -2,7 +2,9 @@ name: Comment on an issue
on:
workflow_run:
- workflows: ["Check code formatting"]
+ workflows:
+ - "Check code formatting"
+ - "Check for private emails used in PRs"
types:
- completed
@@ -31,7 +33,7 @@ jobs:
script: |
var fs = require('fs');
const comments = JSON.parse(fs.readFileSync('./comments'));
- if (!comments) {
+ if (!comments || comments.length == 0) {
return;
}
@@ -77,6 +79,15 @@ jobs:
}
const gql_result = await github.graphql(gql_query, gql_variables);
console.log(gql_result);
+ // If the branch for the PR was deleted before this job has a chance
+ // to run, then the ref will be null. This can happen if someone:
+ // 1. Rebase the PR, which triggers some workflow.
+ // 2. Immediately merges the PR and deletes the branch.
+ // 3. The workflow finishes and triggers this job.
+ if (!gql_result.repository.ref) {
+ console.log("Ref has been deleted");
+ return;
+ }
console.log(gql_result.repository.ref.associatedPullRequests.nodes);
var pr_number = 0;
diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml
index 0bf7386a309840..d5f6fa407b825e 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -32,7 +32,7 @@ jobs:
- name: Fetch code formatting utils
uses: actions/checkout@v4
with:
- reository: ${{ github.repository }}
+ repository: ${{ github.repository }}
ref: ${{ github.base_ref }}
sparse-checkout: |
llvm/utils/git/requirements_formatting.txt
diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h
index 5089f849128010..bc047fefa3151c 100644
--- a/bolt/include/bolt/Core/BinaryFunction.h
+++ b/bolt/include/bolt/Core/BinaryFunction.h
@@ -1168,7 +1168,7 @@ class BinaryFunction {
/// Pass an offset of the entry point in the input binary and a corresponding
/// global symbol to the callback function.
///
- /// Return true of all callbacks returned true, false otherwise.
+ /// Return true if all callbacks returned true, false otherwise.
bool forEachEntryPoint(EntryPointCallbackTy Callback) const;
/// Return MC symbol associated with the end of the function.
diff --git a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
index 5728c9970fb65d..dd772d69202548 100644
--- a/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/readability/CMakeLists.txt
@@ -17,6 +17,7 @@ add_clang_library(clangTidyReadabilityModule
DeleteNullPointerCheck.cpp
DuplicateIncludeCheck.cpp
ElseAfterReturnCheck.cpp
+ EnumInitialValueCheck.cpp
FunctionCognitiveComplexityCheck.cpp
FunctionSizeCheck.cpp
IdentifierLengthCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp b/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp
new file mode 100644
index 00000000000000..8f2841c32259a2
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.cpp
@@ -0,0 +1,200 @@
+//===--- EnumInitialValueCheck.cpp - clang-tidy ---------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "EnumInitialValueCheck.h"
+#include "../utils/LexerUtils.h"
+#include "clang/AST/Decl.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+static bool isNoneEnumeratorsInitialized(const EnumDecl &Node) {
+ return llvm::all_of(Node.enumerators(), [](const EnumConstantDecl *ECD) {
+ return ECD->getInitExpr() == nullptr;
+ });
+}
+
+static bool isOnlyFirstEnumeratorInitialized(const EnumDecl &Node) {
+ bool IsFirst = true;
+ for (const EnumConstantDecl *ECD : Node.enumerators()) {
+ if ((IsFirst && ECD->getInitExpr() == nullptr) ||
+ (!IsFirst && ECD->getInitExpr() != nullptr))
+ return false;
+ IsFirst = false;
+ }
+ return !IsFirst;
+}
+
+static bool areAllEnumeratorsInitialized(const EnumDecl &Node) {
+ return llvm::all_of(Node.enumerators(), [](const EnumConstantDecl *ECD) {
+ return ECD->getInitExpr() != nullptr;
+ });
+}
+
+/// Check if \p Enumerator is initialized with a (potentially negated) \c
+/// IntegerLiteral.
+static bool isInitializedByLiteral(const EnumConstantDecl *Enumerator) {
+ const Expr *const Init = Enumerator->getInitExpr();
+ if (!Init)
+ return false;
+ return Init->isIntegerConstantExpr(Enumerator->getASTContext());
+}
+
+static void cleanInitialValue(DiagnosticBuilder &Diag,
+ const EnumConstantDecl *ECD,
+ const SourceManager &SM,
+ const LangOptions &LangOpts) {
+ const SourceRange InitExprRange = ECD->getInitExpr()->getSourceRange();
+ if (InitExprRange.isInvalid() || InitExprRange.getBegin().isMacroID() ||
+ InitExprRange.getEnd().isMacroID())
+ return;
+ std::optional EqualToken = utils::lexer::findNextTokenSkippingComments(
+ ECD->getLocation(), SM, LangOpts);
+ if (!EqualToken.has_value() ||
+ EqualToken.value().getKind() != tok::TokenKind::equal)
+ return;
+ const SourceLocation EqualLoc{EqualToken->getLocation()};
+ if (EqualLoc.isInvalid() || EqualLoc.isMacroID())
+ return;
+ Diag << FixItHint::CreateRemoval(EqualLoc)
+ << FixItHint::CreateRemoval(InitExprRange);
+ return;
+}
+
+namespace {
+
+AST_MATCHER(EnumDecl, isMacro) {
+ SourceLocation Loc = Node.getBeginLoc();
+ return Loc.isMacroID();
+}
+
+AST_MATCHER(EnumDecl, hasConsistentInitialValues) {
+ return isNoneEnumeratorsInitialized(Node) ||
+ isOnlyFirstEnumeratorInitialized(Node) ||
+ areAllEnumeratorsInitialized(Node);
+}
+
+AST_MATCHER(EnumDecl, hasZeroInitialValueForFirstEnumerator) {
+ const EnumDecl::enumerator_range Enumerators = Node.enumerators();
+ if (Enumerators.empty())
+ return false;
+ const EnumConstantDecl *ECD = *Enumerators.begin();
+ return isOnlyFirstEnumeratorInitialized(Node) &&
+ isInitializedByLiteral(ECD) && ECD->getInitVal().isZero();
+}
+
+/// Excludes bitfields because enumerators initialized with the result of a
+/// bitwise operator on enumeration values or any other expr that is not a
+/// potentially negative integer literal.
+/// Enumerations where it is not directly clear if they are used with
+/// bitmask, evident when enumerators are only initialized with (potentially
+/// negative) integer literals, are ignored. This is also the case when all
+/// enumerators are powers of two (e.g., 0, 1, 2).
+AST_MATCHER(EnumDecl, hasSequentialInitialValues) {
+ const EnumDecl::enumerator_range Enumerators = Node.enumerators();
+ if (Enumerators.empty())
+ return false;
+ const EnumConstantDecl *const FirstEnumerator = *Node.enumerator_begin();
+ llvm::APSInt PrevValue = FirstEnumerator->getInitVal();
+ if (!isInitializedByLiteral(FirstEnumerator))
+ return false;
+ bool AllEnumeratorsArePowersOfTwo = true;
+ for (const EnumConstantDecl *Enumerator : llvm::drop_begin(Enumerators)) {
+ const llvm::APSInt NewValue = Enumerator->getInitVal();
+ if (NewValue != ++PrevValue)
+ return false;
+ if (!isInitializedByLiteral(Enumerator))
+ return false;
+ PrevValue = NewValue;
+ AllEnumeratorsArePowersOfTwo &= NewValue.isPowerOf2();
+ }
+ return !AllEnumeratorsArePowersOfTwo;
+}
+
+} // namespace
+
+EnumInitialValueCheck::EnumInitialValueCheck(StringRef Name,
+ ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context),
+ AllowExplicitZeroFirstInitialValue(
+ Options.get("AllowExplicitZeroFirstInitialValue", true)),
+ AllowExplicitSequentialInitialValues(
+ Options.get("AllowExplicitSequentialInitialValues", true)) {}
+
+void EnumInitialValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
+ Options.store(Opts, "AllowExplicitZeroFirstInitialValue",
+ AllowExplicitZeroFirstInitialValue);
+ Options.store(Opts, "AllowExplicitSequentialInitialValues",
+ AllowExplicitSequentialInitialValues);
+}
+
+void EnumInitialValueCheck::registerMatchers(MatchFinder *Finder) {
+ Finder->addMatcher(
+ enumDecl(unless(isMacro()), unless(hasConsistentInitialValues()))
+ .bind("inconsistent"),
+ this);
+ if (!AllowExplicitZeroFirstInitialValue)
+ Finder->addMatcher(
+ enumDecl(hasZeroInitialValueForFirstEnumerator()).bind("zero_first"),
+ this);
+ if (!AllowExplicitSequentialInitialValues)
+ Finder->addMatcher(enumDecl(unless(isMacro()), hasSequentialInitialValues())
+ .bind("sequential"),
+ this);
+}
+
+void EnumInitialValueCheck::check(const MatchFinder::MatchResult &Result) {
+ if (const auto *Enum = Result.Nodes.getNodeAs("inconsistent")) {
+ DiagnosticBuilder Diag =
+ diag(Enum->getBeginLoc(),
+ "inital values in enum %0 are not consistent, consider explicit "
+ "initialization of all, none or only the first enumerator")
+ << Enum;
+ for (const EnumConstantDecl *ECD : Enum->enumerators())
+ if (ECD->getInitExpr() == nullptr) {
+ const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
+ ECD->getLocation(), 0, *Result.SourceManager, getLangOpts());
+ if (EndLoc.isMacroID())
+ continue;
+ llvm::SmallString<8> Str{" = "};
+ ECD->getInitVal().toString(Str);
+ Diag << FixItHint::CreateInsertion(EndLoc, Str);
+ }
+ return;
+ }
+
+ if (const auto *Enum = Result.Nodes.getNodeAs("zero_first")) {
+ const EnumConstantDecl *ECD = *Enum->enumerator_begin();
+ const SourceLocation Loc = ECD->getLocation();
+ if (Loc.isInvalid() || Loc.isMacroID())
+ return;
+ DiagnosticBuilder Diag = diag(Loc, "zero initial value for the first "
+ "enumerator in %0 can be disregarded")
+ << Enum;
+ cleanInitialValue(Diag, ECD, *Result.SourceManager, getLangOpts());
+ return;
+ }
+ if (const auto *Enum = Result.Nodes.getNodeAs("sequential")) {
+ DiagnosticBuilder Diag =
+ diag(Enum->getBeginLoc(),
+ "sequential initial value in %0 can be ignored")
+ << Enum;
+ for (const EnumConstantDecl *ECD : llvm::drop_begin(Enum->enumerators()))
+ cleanInitialValue(Diag, ECD, *Result.SourceManager, getLangOpts());
+ return;
+ }
+}
+
+} // namespace clang::tidy::readability
diff --git a/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.h b/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.h
new file mode 100644
index 00000000000000..66087e4ee170da
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/readability/EnumInitialValueCheck.h
@@ -0,0 +1,38 @@
+//===--- EnumInitialValueCheck.h - clang-tidy -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_ENUMINITIALVALUECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_ENUMINITIALVALUECHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::readability {
+
+/// Enforces consistent style for enumerators' initialization, covering three
+/// styles: none, first only, or all initialized explicitly.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/readability/enum-initial-value.html
+class EnumInitialValueCheck : public ClangTidyCheck {
+public:
+ EnumInitialValueCheck(StringRef Name, ClangTidyContext *Context);
+ void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+ void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+ void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+ std::optional getCheckTraversalKind() const override {
+ return TK_IgnoreUnlessSpelledInSource;
+ }
+
+private:
+ const bool AllowExplicitZeroFirstInitialValue;
+ const bool AllowExplicitSequentialInitialValues;
+};
+
+} // namespace clang::tidy::readability
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_ENUMINITIALVALUECHECK_H
diff --git a/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
index bca2c425111f6c..376b84683df74e 100644
--- a/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -22,6 +22,7 @@
#include "DeleteNullPointerCheck.h"
#include "DuplicateIncludeCheck.h"
#include "ElseAfterReturnCheck.h"
+#include "EnumInitialValueCheck.h"
#include "FunctionCognitiveComplexityCheck.h"
#include "FunctionSizeCheck.h"
#include "IdentifierLengthCheck.h"
@@ -92,6 +93,8 @@ class ReadabilityModule : public ClangTidyModule {
"readability-duplicate-include");
CheckFactories.registerCheck(
"readability-else-after-return");
+ CheckFactories.registerCheck(
+ "readability-enum-initial-value");
CheckFactories.registerCheck(
"readability-function-cognitive-complexity");
CheckFactories.registerCheck(
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 78b09d23d4427f..309b844615a121 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -123,6 +123,12 @@ New checks
Finds initializer lists for aggregate types that could be
written as designated initializers instead.
+- New :doc:`readability-enum-initial-value
+ ` check.
+
+ Enforces consistent style for enumerators' initialization, covering three
+ styles: none, first only, or all initialized explicitly.
+
- New :doc:`readability-use-std-min-max
` check.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 79e81dd174e4f3..188a42bfddd383 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -352,6 +352,7 @@ Clang-Tidy Checks
:doc:`readability-delete-null-pointer `, "Yes"
:doc:`readability-duplicate-include `, "Yes"
:doc:`readability-else-after-return `, "Yes"
+ :doc:`readability-enum-initial-value `, "Yes"
:doc:`readability-function-cognitive-complexity `,
:doc:`readability-function-size `,
:doc:`readability-identifier-length `,
diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability/enum-initial-value.rst b/clang-tools-extra/docs/clang-tidy/checks/readability/enum-initial-value.rst
new file mode 100644
index 00000000000000..660efc1eaff3e5
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/readability/enum-initial-value.rst
@@ -0,0 +1,75 @@
+.. title:: clang-tidy - readability-enum-initial-value
+
+readability-enum-initial-value
+==============================
+
+Enforces consistent style for enumerators' initialization, covering three
+styles: none, first only, or all initialized explicitly.
+
+When adding new enumerations, inconsistent initial value will cause potential
+enumeration value conflicts.
+
+In an enumeration, the following three cases are accepted.
+1. none of enumerators are explicit initialized.
+2. the first enumerator is explicit initialized.
+3. all of enumerators are explicit initialized.
+
+.. code-block:: c++
+
+ // valid, none of enumerators are initialized.
+ enum A {
+ e0,
+ e1,
+ e2,
+ };
+
+ // valid, the first enumerator is initialized.
+ enum A {
+ e0 = 0,
+ e1,
+ e2,
+ };
+
+ // valid, all of enumerators are initialized.
+ enum A {
+ e0 = 0,
+ e1 = 1,
+ e2 = 2,
+ };
+
+ // invalid, e1 is not explicit initialized.
+ enum A {
+ e0 = 0,
+ e1,
+ e2 = 2,
+ };
+
+Options
+-------
+
+.. option:: AllowExplicitZeroFirstInitialValue
+
+ If set to `false`, the first enumerator must not be explicitly initialized.
+ See examples below. Default is `true`.
+
+ .. code-block:: c++
+
+ enum A {
+ e0 = 0, // not allowed if AllowExplicitZeroFirstInitialValue is false
+ e1,
+ e2,
+ };
+
+
+.. option:: AllowExplicitSequentialInitialValues
+
+ If set to `false`, sequential initializations are not allowed.
+ See examples below. Default is `true`.
+
+ .. code-block:: c++
+
+ enum A {
+ e0 = 1, // not allowed if AllowExplicitSequentialInitialValues is false
+ e1 = 2,
+ e2 = 3,
+ };
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/enum-initial-value.c b/clang-tools-extra/test/clang-tidy/checkers/readability/enum-initial-value.c
new file mode 100644
index 00000000000000..c66288cbe3e957
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/checkers/readability/enum-initial-value.c
@@ -0,0 +1,80 @@
+// RUN: %check_clang_tidy %s readability-enum-initial-value %t
+// RUN: %check_clang_tidy -check-suffix=ENABLE %s readability-enum-initial-value %t -- \
+// RUN: -config='{CheckOptions: { \
+// RUN: readability-enum-initial-value.AllowExplicitZeroFirstInitialValue: false, \
+// RUN: readability-enum-initial-value.AllowExplicitSequentialInitialValues: false, \
+// RUN: }}'
+
+enum EError {
+ // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: inital values in enum 'EError' are not consistent
+ // CHECK-MESSAGES-ENABLE: :[[@LINE-2]]:1: warning: inital values in enum 'EError' are not consistent
+ EError_a = 1,
+ EError_b,
+ // CHECK-FIXES: EError_b = 2,
+ EError_c = 3,
+};
+
+enum ENone {
+ ENone_a,
+ ENone_b,
+ EENone_c,
+};
+
+enum EFirst {
+ EFirst_a = 1,
+ EFirst_b,
+ EFirst_c,
+};
+
+enum EAll {
+ EAll_a = 1,
+ EAll_b = 2,
+ EAll_c = 4,
+};
+
+#define ENUMERATOR_1 EMacro1_b
+enum EMacro1 {
+ // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: inital values in enum 'EMacro1' are not consistent
+ // CHECK-MESSAGES-ENABLE: :[[@LINE-2]]:1: warning: inital values in enum 'EMacro1' are not consistent
+ EMacro1_a = 1,
+ ENUMERATOR_1,
+ // CHECK-FIXES: ENUMERATOR_1 = 2,
+ EMacro1_c = 3,
+};
+
+
+#define ENUMERATOR_2 EMacro2_b = 2
+enum EMacro2 {
+ // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: inital values in enum 'EMacro2' are not consistent
+ // CHECK-MESSAGES-ENABLE: :[[@LINE-2]]:1: warning: inital values in enum 'EMacro2' are not consistent
+ EMacro2_a = 1,
+ ENUMERATOR_2,
+ EMacro2_c,
+ // CHECK-FIXES: EMacro2_c = 3,
+};
+
+enum EnumZeroFirstInitialValue {
+ EnumZeroFirstInitialValue_0 = 0,
+ // CHECK-MESSAGES-ENABLE: :[[@LINE-1]]:3: warning: zero initial value for the first enumerator in 'EnumZeroFirstInitialValue' can be disregarded
+ // CHECK-FIXES-ENABLE: EnumZeroFirstInitialValue_0 ,
+ EnumZeroFirstInitialValue_1,
+ EnumZeroFirstInitialValue_2,
+};
+
+enum EnumZeroFirstInitialValueWithComment {
+ EnumZeroFirstInitialValueWithComment_0 = /* == */ 0,
+ // CHECK-MESSAGES-ENABLE: :[[@LINE-1]]:3: warning: zero initial value for the first enumerator in 'EnumZeroFirstInitialValueWithComment' can be disregarded
+ // CHECK-FIXES-ENABLE: EnumZeroFirstInitialValueWithComment_0 /* == */ ,
+ EnumZeroFirstInitialValueWithComment_1,
+ EnumZeroFirstInitialValueWithComment_2,
+};
+
+enum EnumSequentialInitialValue {
+ // CHECK-MESSAGES-ENABLE: :[[@LINE-1]]:1: warning: sequential initial value in 'EnumSequentialInitialValue' can be ignored
+ EnumSequentialInitialValue_0 = 2,
+ // CHECK-FIXES-ENABLE: EnumSequentialInitialValue_0 = 2,
+ EnumSequentialInitialValue_1 = 3,
+ // CHECK-FIXES-ENABLE: EnumSequentialInitialValue_1 ,
+ EnumSequentialInitialValue_2 = 4,
+ // CHECK-FIXES-ENABLE: EnumSequentialInitialValue_2 ,
+};
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/enum-initial-value.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/enum-initial-value.cpp
new file mode 100644
index 00000000000000..3c4ba970372a07
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/checkers/readability/enum-initial-value.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s readability-enum-initial-value %t
+
+enum class EError {
+ // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: inital values in enum 'EError' are not consistent
+ EError_a = 1,
+ EError_b,
+ // CHECK-FIXES: EError_b = 2,
+ EError_c = 3,
+};
+
+enum class ENone {
+ ENone_a,
+ ENone_b,
+ EENone_c,
+};
+
+enum class EFirst {
+ EFirst_a = 1,
+ EFirst_b,
+ EFirst_c,
+};
+
+enum class EAll {
+ EAll_a = 1,
+ EAll_b = 2,
+ EAll_c = 3,
+};
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
index d0efc5ca763753..57d930b26e64c0 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp
@@ -25,7 +25,7 @@
// RUN: not clang-tidy -checks='-*,modernize-use-override' %T/diagnostics/input.cpp -- -DCOMPILATION_ERROR 2>&1 | FileCheck -check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE -std=c++20 | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined,clang-diagnostic-literal-conversion' %s -- -DMACRO_FROM_COMMAND_LINE -std=c++20 -Wno-macro-redefined | FileCheck --check-prefix=CHECK7 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: not clang-tidy -checks='-*,modernize-use-override' %s -- -std=c++20 -DPR64602 | FileCheck -check-prefix=CHECK8 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,modernize-use-override' %s -- -std=c++20 -DPR64602
// CHECK1: error: no input files [clang-diagnostic-error]
// CHECK1: error: no such file or directory: '{{.*}}nonexistent.cpp' [clang-diagnostic-error]
@@ -68,6 +68,4 @@ auto S<>::foo(auto)
{
return 1;
}
-// CHECK8: error: conflicting types for 'foo' [clang-diagnostic-error]
-// CHECK8: note: previous declaration is here
#endif
diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake
index df69d7d0dd414b..393d97a4cf1a33 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -71,6 +71,8 @@ set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH
Python3_LIBRARIES
Python3_INCLUDE_DIRS
Python3_RPATH
+ SWIG_DIR
+ SWIG_EXECUTABLE
CMAKE_FIND_PACKAGE_PREFER_CONFIG
CMAKE_SYSROOT
CMAKE_MODULE_LINKER_FLAGS
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 2ee36f24d7ce4b..39f7cded36edbf 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3295,6 +3295,21 @@ the configuration (without a prefix: ``Auto``).
+.. _BreakFunctionDefinitionParameters:
+
+**BreakFunctionDefinitionParameters** (``Boolean``) :versionbadge:`clang-format 19` :ref:`¶ `
+ If ``true``, clang-format will always break before function definition
+ parameters.
+
+ .. code-block:: c++
+
+ true:
+ void functionDefinition(
+ int A, int B) {}
+
+ false:
+ void functionDefinition(int A, int B) {}
+
.. _BreakInheritanceList:
**BreakInheritanceList** (``BreakInheritanceListStyle``) :versionbadge:`clang-format 7` :ref:`¶ `
diff --git a/clang/docs/HLSL/FunctionCalls.rst b/clang/docs/HLSL/FunctionCalls.rst
index 7317de2163f897..6d65fe6e3fb20b 100644
--- a/clang/docs/HLSL/FunctionCalls.rst
+++ b/clang/docs/HLSL/FunctionCalls.rst
@@ -157,22 +157,23 @@ Clang Implementation
of the changes in the prototype implementation are restoring Clang-3.7 code
that was previously modified to its original state.
-The implementation in clang depends on two new AST nodes and minor extensions to
-Clang's existing support for Objective-C write-back arguments. The goal of this
-design is to capture the semantic details of HLSL function calls in the AST, and
-minimize the amount of magic that needs to occur during IR generation.
-
-The two new AST nodes are ``HLSLArrayTemporaryExpr`` and ``HLSLOutParamExpr``,
-which respectively represent the temporaries used for passing arrays by value
-and the temporaries created for function outputs.
+The implementation in clang adds a new non-decaying array type, a new AST node
+to represent output parameters, and minor extensions to Clang's existing support
+for Objective-C write-back arguments. The goal of this design is to capture the
+semantic details of HLSL function calls in the AST, and minimize the amount of
+magic that needs to occur during IR generation.
Array Temporaries
-----------------
-The ``HLSLArrayTemporaryExpr`` represents temporary values for input
-constant-sized array arguments. This applies for all constant-sized array
-arguments regardless of whether or not the parameter is constant-sized or
-unsized.
+The new ``ArrayParameterType`` is a sub-class of ``ConstantArrayType``
+inheriting all the behaviors and methods of the parent except that it does not
+decay to a pointer during overload resolution or template type deduction.
+
+An argument of ``ConstantArrayType`` can be implicitly converted to an
+equivalent non-decayed ``ArrayParameterType`` if the underlying canonical
+``ConstantArrayType`` is the same. This occurs during overload resolution
+instead of array to pointer decay.
.. code-block:: c++
@@ -193,7 +194,7 @@ In the example above, the following AST is generated for the call to
CallExpr 'void'
|-ImplicitCastExpr 'void (*)(float [4])'
| `-DeclRefExpr 'void (float [4])' lvalue Function 'SizedArray' 'void (float [4])'
- `-HLSLArrayTemporaryExpr 'float [4]'
+ `-ImplicitCastExpr 'float [4]'
`-DeclRefExpr 'float [4]' lvalue Var 'arr' 'float [4]'
In the example above, the following AST is generated for the call to
@@ -204,7 +205,7 @@ In the example above, the following AST is generated for the call to
CallExpr 'void'
|-ImplicitCastExpr 'void (*)(float [])'
| `-DeclRefExpr 'void (float [])' lvalue Function 'UnsizedArray' 'void (float [])'
- `-HLSLArrayTemporaryExpr 'float [4]'
+ `-ImplicitCastExpr 'float [4]'
`-DeclRefExpr 'float [4]' lvalue Var 'arr' 'float [4]'
In both of these cases the argument expression is of known array size so we can
@@ -236,7 +237,7 @@ An expected AST should be something like:
CallExpr 'void'
|-ImplicitCastExpr 'void (*)(float [])'
| `-DeclRefExpr 'void (float [])' lvalue Function 'UnsizedArray' 'void (float [])'
- `-HLSLArrayTemporaryExpr 'float [4]'
+ `-ImplicitCastExpr 'float [4]'
`-DeclRefExpr 'float [4]' lvalue Var 'arr' 'float [4]'
Out Parameter Temporaries
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 76eaf0bf11c303..3237842fa1ceb1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -253,6 +253,21 @@ Attribute Changes in Clang
added a new extension query ``__has_extension(swiftcc)`` corresponding to the
``__attribute__((swiftcc))`` attribute.
+- The ``_Nullable`` and ``_Nonnull`` family of type attributes can now apply
+ to certain C++ class types, such as smart pointers:
+ ``void useObject(std::unique_ptr