Skip to content

Commit a514392

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#2355)
2 parents 16ad33e + 3cd0f86 commit a514392

File tree

177 files changed

+571
-376
lines changed

Some content is hidden

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

177 files changed

+571
-376
lines changed

.ci/metrics/metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
# name.
3030
GITHUB_JOB_TO_TRACK = {
3131
"github_llvm_premerge_checks": {
32-
"Build and Test Linux (Test Only - Please Ignore Results)": "premerge_linux",
33-
"Build and Test Windows (Test Only - Please Ignore Results)": "premerge_windows",
32+
"Build and Test Linux": "premerge_linux",
33+
"Build and Test Windows": "premerge_windows",
3434
}
3535
}
3636

.github/workflows/premerge.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ on:
1616
- closed
1717
push:
1818
branches:
19-
- 'main'
2019
- 'release/**'
2120

2221
concurrency:
@@ -25,7 +24,7 @@ concurrency:
2524

2625
jobs:
2726
premerge-checks-linux:
28-
name: Build and Test Linux (Test Only - Please Ignore Results)
27+
name: Build and Test Linux
2928
if: >-
3029
github.repository_owner == 'llvm' &&
3130
(github.event_name != 'pull_request' || github.event.action != 'closed')
@@ -43,9 +42,6 @@ jobs:
4342
# Mark the job as a success even if the step fails so that people do
4443
# not get notified while the new premerge pipeline is in an
4544
# experimental state.
46-
# TODO(boomanaiden154): Remove this once the pipeline is stable and we
47-
# are ready for people to start recieving notifications.
48-
continue-on-error: true
4945
run: |
5046
git config --global --add safe.directory '*'
5147
@@ -74,7 +70,7 @@ jobs:
7470
include-hidden-files: 'true'
7571

7672
premerge-checks-windows:
77-
name: Build and Test Windows (Test Only - Please Ignore Results)
73+
name: Build and Test Windows
7874
if: >-
7975
github.repository_owner == 'llvm' &&
8076
(github.event_name != 'pull_request' || github.event.action != 'closed')
@@ -110,9 +106,6 @@ jobs:
110106
# Mark the job as a success even if the step fails so that people do
111107
# not get notified while the new premerge pipeline is in an
112108
# experimental state.
113-
# TODO(boomanaiden154): Remove this once the pipeline is stable and we
114-
# are ready for people to start recieving notifications.
115-
continue-on-error: true
116109
if: ${{ steps.vars.outputs.windows-projects != '' }}
117110
shell: cmd
118111
run: |

bolt/lib/Profile/BoltAddressTranslation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ BoltAddressTranslation::getSecondaryEntryPointId(uint64_t Address,
600600
if (FunctionIt == SecondaryEntryPointsMap.end())
601601
return 0;
602602
const std::vector<uint32_t> &Offsets = FunctionIt->second;
603-
auto OffsetIt = std::find(Offsets.begin(), Offsets.end(), Offset);
603+
auto OffsetIt = llvm::find(Offsets, Offset);
604604
if (OffsetIt == Offsets.end())
605605
return 0;
606606
// Adding one here because main entry point is not stored in BAT, and
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//===--- AvoidPragmaOnceCheck.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 "AvoidPragmaOnceCheck.h"
10+
11+
#include "clang/Basic/SourceManager.h"
12+
#include "clang/Lex/PPCallbacks.h"
13+
#include "clang/Lex/Preprocessor.h"
14+
#include "llvm/ADT/StringRef.h"
15+
16+
namespace clang::tidy::portability {
17+
18+
class PragmaOnceCallbacks : public PPCallbacks {
19+
public:
20+
PragmaOnceCallbacks(AvoidPragmaOnceCheck *Check, const SourceManager &SM)
21+
: Check(Check), SM(SM) {}
22+
void PragmaDirective(SourceLocation Loc,
23+
PragmaIntroducerKind Introducer) override {
24+
auto Str = llvm::StringRef(SM.getCharacterData(Loc));
25+
if (!Str.consume_front("#"))
26+
return;
27+
Str = Str.trim();
28+
if (!Str.consume_front("pragma"))
29+
return;
30+
Str = Str.trim();
31+
if (Str.starts_with("once"))
32+
Check->diag(Loc,
33+
"avoid 'pragma once' directive; use include guards instead");
34+
}
35+
36+
private:
37+
AvoidPragmaOnceCheck *Check;
38+
const SourceManager &SM;
39+
};
40+
41+
void AvoidPragmaOnceCheck::registerPPCallbacks(const SourceManager &SM,
42+
Preprocessor *PP,
43+
Preprocessor *ModuleExpanderPP) {
44+
PP->addPPCallbacks(std::make_unique<PragmaOnceCallbacks>(this, SM));
45+
}
46+
47+
} // namespace clang::tidy::portability
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//===--- AvoidPragmaOnceCheck.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_PORTABILITY_AVOIDPRAGMAONCECHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_AVOIDPRAGMAONCECHECK_H
11+
12+
#include "../ClangTidyCheck.h"
13+
14+
namespace clang::tidy::portability {
15+
16+
/// Finds uses of ``#pragma once`` and suggests replacing them with standard
17+
/// include guards (``#ifndef``/``#define``/``#endif``) for improved
18+
/// portability.
19+
///
20+
/// For the user-facing documentation see:
21+
/// http://clang.llvm.org/extra/clang-tidy/checks/portability/avoid-pragma-once.html
22+
class AvoidPragmaOnceCheck : public ClangTidyCheck {
23+
public:
24+
AvoidPragmaOnceCheck(StringRef Name, ClangTidyContext *Context)
25+
: ClangTidyCheck(Name, Context) {}
26+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
27+
return LangOpts.CPlusPlus || LangOpts.C99;
28+
}
29+
30+
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
31+
Preprocessor *ModuleExpanderPP) override;
32+
};
33+
34+
} // namespace clang::tidy::portability
35+
36+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PORTABILITY_AVOIDPRAGMAONCECHECK_H

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
55
)
66

77
add_clang_library(clangTidyPortabilityModule STATIC
8+
AvoidPragmaOnceCheck.cpp
89
PortabilityTidyModule.cpp
910
RestrictSystemIncludesCheck.cpp
1011
SIMDIntrinsicsCheck.cpp

clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "../ClangTidy.h"
1010
#include "../ClangTidyModule.h"
1111
#include "../ClangTidyModuleRegistry.h"
12+
#include "AvoidPragmaOnceCheck.h"
1213
#include "RestrictSystemIncludesCheck.h"
1314
#include "SIMDIntrinsicsCheck.h"
1415
#include "StdAllocatorConstCheck.h"
@@ -20,6 +21,8 @@ namespace portability {
2021
class PortabilityModule : public ClangTidyModule {
2122
public:
2223
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
24+
CheckFactories.registerCheck<AvoidPragmaOnceCheck>(
25+
"portability-avoid-pragma-once");
2326
CheckFactories.registerCheck<RestrictSystemIncludesCheck>(
2427
"portability-restrict-system-includes");
2528
CheckFactories.registerCheck<SIMDIntrinsicsCheck>(

clang-tools-extra/clangd/test/path-mappings.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# RUN: rm -rf %t
33
# RUN: cp -r %S/Inputs/path-mappings %t
44
#
5-
# RUN: clangd --path-mappings 'C:\client=%t/server' -lit-test < %s | FileCheck -strict-whitespace %s
5+
# RUN: clangd --clang-tidy=false --path-mappings 'C:\client=%t/server' -lit-test < %s | FileCheck -strict-whitespace %s
66
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
77
---
88
{

clang-tools-extra/clangd/test/system-include-extractor.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
# Bless the mock driver we've just created so that clangd can execute it.
5353
# Note: include clangd's stderr in the FileCheck input with "2>&1" so that we
5454
# can match output lines like "ASTWorker building file"
55-
# RUN: clangd -lit-test -query-driver="**.test,**.sh" < %t.test 2>&1 | FileCheck -strict-whitespace %t.test
55+
# RUN: clangd --clang-tidy=false -lit-test -query-driver="**.test,**.sh" < %t.test 2>&1 | FileCheck -strict-whitespace %t.test
5656
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{}}
5757
---
5858
{
@@ -88,4 +88,4 @@
8888

8989
# Run clangd a second time, to make sure it picks up the driver name from the config file
9090
# Note, we need to pass -enable-config because -lit-test otherwise disables it
91-
# RUN: clangd -lit-test -enable-config -query-driver="**.test,**.sh" < %t.test 2>&1 | FileCheck -strict-whitespace %t.test
91+
# RUN: clangd --clang-tidy=false -lit-test -enable-config -query-driver="**.test,**.sh" < %t.test 2>&1 | FileCheck -strict-whitespace %t.test

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:`portability-avoid-pragma-once
140+
<clang-tidy/checks/portability/avoid-pragma-once>` check.
141+
142+
Finds uses of ``#pragma once`` and suggests replacing them with standard
143+
include guards (``#ifndef``/``#define``/``#endif``) for improved portability.
144+
139145
- New :doc:`readability-ambiguous-smartptr-reset-call
140146
<clang-tidy/checks/readability/ambiguous-smartptr-reset-call>` check.
141147

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ Clang-Tidy Checks
351351
:doc:`performance-type-promotion-in-math-fn <performance/type-promotion-in-math-fn>`, "Yes"
352352
:doc:`performance-unnecessary-copy-initialization <performance/unnecessary-copy-initialization>`, "Yes"
353353
:doc:`performance-unnecessary-value-param <performance/unnecessary-value-param>`, "Yes"
354+
:doc:`portability-avoid-pragma-once <portability/avoid-pragma-once>`,
354355
:doc:`portability-restrict-system-includes <portability/restrict-system-includes>`, "Yes"
355356
:doc:`portability-simd-intrinsics <portability/simd-intrinsics>`,
356357
:doc:`portability-std-allocator-const <portability/std-allocator-const>`,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.. title:: clang-tidy - portability-avoid-pragma-once
2+
3+
portability-avoid-pragma-once
4+
=============================
5+
6+
Finds uses of ``#pragma once`` and suggests replacing them with standard
7+
include guards (``#ifndef``/``#define``/``#endif``) for improved portability.
8+
9+
``#pragma once`` is a non-standard extension, despite being widely supported
10+
by modern compilers. Relying on it can lead to portability issues in
11+
some environments.
12+
13+
Some older or specialized C/C++ compilers, particularly in embedded systems,
14+
may not fully support ``#pragma once``.
15+
16+
It can also fail in certain file system configurations, like network drives
17+
or complex symbolic links, potentially leading to compilation issues.
18+
19+
Consider the following header file:
20+
21+
.. code:: c++
22+
23+
// my_header.h
24+
#pragma once // warning: avoid 'pragma once' directive; use include guards instead
25+
26+
27+
The warning suggests using include guards:
28+
29+
.. code:: c++
30+
31+
// my_header.h
32+
#ifndef PATH_TO_MY_HEADER_H // Good: use include guards.
33+
#define PATH_TO_MY_HEADER_H
34+
35+
#endif // PATH_TO_MY_HEADER_H
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#pragma once
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# pragma once
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# pragma once
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %check_clang_tidy %s portability-avoid-pragma-once %t \
2+
// RUN: -- --header-filter='.*' -- -I%S/Inputs/avoid-pragma-once
3+
4+
// #pragma once
5+
#include "lib0.h"
6+
// CHECK-MESSAGES: lib0.h:1:1: warning: avoid 'pragma once' directive; use include guards instead
7+
8+
9+
// # pragma once
10+
#include "lib1.h"
11+
// CHECK-MESSAGES: lib1.h:1:1: warning: avoid 'pragma once' directive; use include guards instead
12+
13+
// # pragma once
14+
#include "lib2.h"
15+
// CHECK-MESSAGES: lib2.h:1:1: warning: avoid 'pragma once' directive; use include guards instead

clang/include/clang/Analysis/ProgramPoint.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ProgramPointTag {
4242

4343
/// The description of this program point which will be dumped for debugging
4444
/// purposes. Do not use in user-facing output!
45-
virtual StringRef getTagDescription() const = 0;
45+
virtual StringRef getDebugTag() const = 0;
4646

4747
/// Used to implement 'isKind' in subclasses.
4848
const void *getTagKind() const { return TagKind; }
@@ -55,7 +55,7 @@ class SimpleProgramPointTag : public ProgramPointTag {
5555
std::string Desc;
5656
public:
5757
SimpleProgramPointTag(StringRef MsgProvider, StringRef Msg);
58-
StringRef getTagDescription() const override;
58+
StringRef getDebugTag() const override;
5959
};
6060

6161
class ProgramPoint {

clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ KEYWORD(RootSignature) // used only for diagnostic messaging
8080
KEYWORD(RootFlags)
8181
KEYWORD(DescriptorTable)
8282
KEYWORD(RootConstants)
83+
KEYWORD(StaticSampler)
8384

8485
// RootConstants Keywords:
8586
KEYWORD(num32BitConstants)

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class RootSignatureParser {
7777
std::optional<llvm::hlsl::rootsig::DescriptorTable> parseDescriptorTable();
7878
std::optional<llvm::hlsl::rootsig::DescriptorTableClause>
7979
parseDescriptorTableClause();
80+
std::optional<llvm::hlsl::rootsig::StaticSampler> parseStaticSampler();
8081

8182
/// Parameter arguments (eg. `bReg`, `space`, ...) can be specified in any
8283
/// order and only exactly once. The following methods define a
@@ -108,6 +109,11 @@ class RootSignatureParser {
108109
std::optional<ParsedClauseParams>
109110
parseDescriptorTableClauseParams(RootSignatureToken::Kind RegType);
110111

112+
struct ParsedStaticSamplerParams {
113+
std::optional<llvm::hlsl::rootsig::Register> Reg;
114+
};
115+
std::optional<ParsedStaticSamplerParams> parseStaticSamplerParams();
116+
111117
// Common parsing methods
112118
std::optional<uint32_t> parseUIntParam();
113119
std::optional<llvm::hlsl::rootsig::Register> parseRegister();

clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ class BugReporterContext {
758758
/// DataTag::Factory should be friend for every derived class.
759759
class DataTag : public ProgramPointTag {
760760
public:
761-
StringRef getTagDescription() const override { return "Data Tag"; }
761+
StringRef getDebugTag() const override { return "Data Tag"; }
762762

763763
// Manage memory for DataTag objects.
764764
class Factory {
@@ -809,7 +809,7 @@ class NoteTag : public DataTag {
809809
return std::move(Msg);
810810
}
811811

812-
StringRef getTagDescription() const override {
812+
StringRef getDebugTag() const override {
813813
// TODO: Remember a few examples of generated messages
814814
// and display them in the ExplodedGraph dump by
815815
// returning them from this function.

clang/include/clang/StaticAnalyzer/Core/Checker.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ class CheckerBase : public CheckerFrontend, public CheckerBackend {
526526
public:
527527
/// Attached to nodes created by this checker class when the ExplodedGraph is
528528
/// dumped for debugging.
529-
StringRef getTagDescription() const override;
529+
StringRef getDebugTag() const override;
530530
};
531531

532532
/// Simple checker classes that implement one frontend (i.e. checker name)
@@ -547,16 +547,16 @@ class Checker : public CheckerBase, public CHECKs... {
547547
/// callbacks (i.e. classes like `check::PreStmt` or `eval::Call`) as template
548548
/// arguments of `FamilyChecker.`
549549
///
550-
/// NOTE: Classes deriving from `CheckerFamily` must implement the pure
551-
/// virtual method `StringRef getTagDescription()` which is inherited from
552-
/// `ProgramPointTag` and should return the name of the class as a string.
550+
/// NOTE: Classes deriving from `CheckerFamily` must implement the pure virtual
551+
/// method `StringRef getDebugTag()` which is inherited from `ProgramPointTag`
552+
/// and should return the name of the class as a string.
553553
///
554554
/// Obviously, this boilerplate is not a good thing, but unfortunately there is
555555
/// no portable way to stringify the name of a type (e.g. class), so any
556-
/// portable implementation of `getTagDescription` would need to take the
557-
/// name of the class from *somewhere* where it's present as a string -- and
558-
/// then directly placing it in a method override is much simpler than
559-
/// loading it from `Checkers.td`.
556+
/// portable implementation of `getDebugTag` would need to take the name of
557+
/// the class from *somewhere* where it's present as a string -- and then
558+
/// directly placing it in a method override is much simpler than loading it
559+
/// from `Checkers.td`.
560560
///
561561
/// Note that the existing `CLASS` field in `Checkers.td` is not suitable for
562562
/// our goals, because instead of storing the same class name for each

clang/lib/Analysis/ProgramPoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,4 @@ SimpleProgramPointTag::SimpleProgramPointTag(StringRef MsgProvider,
357357
StringRef Msg)
358358
: Desc((MsgProvider + " : " + Msg).str()) {}
359359

360-
StringRef SimpleProgramPointTag::getTagDescription() const { return Desc; }
360+
StringRef SimpleProgramPointTag::getDebugTag() const { return Desc; }

clang/lib/Format/MacroCallReconstructor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,8 @@ MacroCallReconstructor::createUnwrappedLine(const ReconstructedLine &Line,
511511
for (const auto &N : Line.Tokens) {
512512
Result.Tokens.push_back(N->Tok);
513513
UnwrappedLineNode &Current = Result.Tokens.back();
514-
auto NumChildren =
515-
std::count_if(N->Children.begin(), N->Children.end(),
516-
[](const auto &Child) { return !Child->Tokens.empty(); });
514+
auto NumChildren = llvm::count_if(
515+
N->Children, [](const auto &Child) { return !Child->Tokens.empty(); });
517516
if (NumChildren == 1 && Current.Tok->isOneOf(tok::l_paren, tok::comma)) {
518517
// If we only have one child, and the child is due to a macro expansion
519518
// (either attached to a left parenthesis or comma), merge the child into

0 commit comments

Comments
 (0)