Skip to content

Commit f04d8d9

Browse files
authored
merge main into amd-staging (llvm#1400)
2 parents 411ee79 + be5d122 commit f04d8d9

File tree

431 files changed

+56499
-51117
lines changed

Some content is hidden

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

431 files changed

+56499
-51117
lines changed

bolt/include/bolt/Core/Relocation.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class Relocation {
5757
uint32_t Type;
5858

5959
private:
60-
/// Relocations added by optimizations can be optional.
60+
/// Relocations added by optimizations can be optional, meaning they can be
61+
/// omitted under certain circumstances.
6162
bool Optional = false;
6263

6364
public:
@@ -72,10 +73,10 @@ class Relocation {
7273
/// Return size in bytes of the given relocation \p Type.
7374
static size_t getSizeForType(uint32_t Type);
7475

75-
/// Some relocations added by optimizations are optional, meaning they can be
76-
/// omitted under certain circumstances.
7776
void setOptional() { Optional = true; }
7877

78+
bool isOptional() { return Optional; }
79+
7980
/// Return size of this relocation.
8081
size_t getSize() const { return getSizeForType(Type); }
8182

clang-tools-extra/clang-doc/HTMLGenerator.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,11 @@ static llvm::Error serializeIndex(ClangDocContext &CDCtx) {
10781078
std::replace(RootPathEscaped.begin(), RootPathEscaped.end(), '\\', '/');
10791079
OS << "var RootPath = \"" << RootPathEscaped << "\";\n";
10801080

1081+
llvm::SmallString<128> Base(CDCtx.Base);
1082+
std::string BaseEscaped = Base.str().str();
1083+
std::replace(BaseEscaped.begin(), BaseEscaped.end(), '\\', '/');
1084+
OS << "var Base = \"" << BaseEscaped << "\";\n";
1085+
10811086
CDCtx.Idx.sort();
10821087
llvm::json::OStream J(OS, 2);
10831088
std::function<void(Index)> IndexToJSON = [&](const Index &I) {

clang-tools-extra/clang-doc/Representation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,10 @@ void Index::sort() {
367367
ClangDocContext::ClangDocContext(tooling::ExecutionContext *ECtx,
368368
StringRef ProjectName, bool PublicOnly,
369369
StringRef OutDirectory, StringRef SourceRoot,
370-
StringRef RepositoryUrl,
370+
StringRef RepositoryUrl, StringRef Base,
371371
std::vector<std::string> UserStylesheets)
372372
: ECtx(ECtx), ProjectName(ProjectName), PublicOnly(PublicOnly),
373-
OutDirectory(OutDirectory), UserStylesheets(UserStylesheets) {
373+
OutDirectory(OutDirectory), UserStylesheets(UserStylesheets), Base(Base) {
374374
llvm::SmallString<128> SourceRootDir(SourceRoot);
375375
if (SourceRoot.empty())
376376
// If no SourceRoot was provided the current path is used as the default

clang-tools-extra/clang-doc/Representation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ struct ClangDocContext {
507507
ClangDocContext() = default;
508508
ClangDocContext(tooling::ExecutionContext *ECtx, StringRef ProjectName,
509509
bool PublicOnly, StringRef OutDirectory, StringRef SourceRoot,
510-
StringRef RepositoryUrl,
510+
StringRef RepositoryUrl, StringRef Base,
511511
std::vector<std::string> UserStylesheets);
512512
tooling::ExecutionContext *ECtx;
513513
std::string ProjectName; // Name of project clang-doc is documenting.
@@ -523,6 +523,7 @@ struct ClangDocContext {
523523
std::vector<std::string> UserStylesheets;
524524
// JavaScript files that will be imported in all HTML files.
525525
std::vector<std::string> JsScripts;
526+
StringRef Base;
526527
Index Idx;
527528
};
528529

clang-tools-extra/clang-doc/assets/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
function genLink(Ref) {
22
// we treat the file paths different depending on if we're
33
// serving via a http server or viewing from a local
4-
var Path = window.location.protocol.startsWith("file") ?
5-
`${window.location.protocol}//${RootPath}/${Ref.Path}` :
6-
`${window.location.protocol}//${window.location.host}/${Ref.Path}`;
4+
var Path = window.location.protocol.startsWith("file")
5+
? `${window.location.protocol}//${RootPath}/${Ref.Path}`
6+
: `${window.location.protocol}//${window.location.host}/${
7+
Base}/${Ref.Path}`;
78
if (Ref.RefType === "namespace") {
89
Path = `${Path}/index.html`
910
} else if (Ref.Path === "") {

clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ static llvm::cl::opt<std::string>
6767
llvm::cl::desc("Directory for outputting generated files."),
6868
llvm::cl::init("docs"), llvm::cl::cat(ClangDocCategory));
6969

70+
static llvm::cl::opt<std::string>
71+
BaseDirectory("base",
72+
llvm::cl::desc(R"(Base Directory for generated documentation.
73+
URLs will be rooted at this directory for HTML links.)"),
74+
llvm::cl::init(""), llvm::cl::cat(ClangDocCategory));
75+
7076
static llvm::cl::opt<bool>
7177
PublicOnly("public", llvm::cl::desc("Document only public declarations."),
7278
llvm::cl::init(false), llvm::cl::cat(ClangDocCategory));
@@ -141,8 +147,7 @@ llvm::Error getAssetFiles(clang::doc::ClangDocContext &CDCtx) {
141147
using DirIt = llvm::sys::fs::directory_iterator;
142148
std::error_code FileErr;
143149
llvm::SmallString<128> FilePath(UserAssetPath);
144-
for (DirIt DirStart = DirIt(UserAssetPath, FileErr),
145-
DirEnd;
150+
for (DirIt DirStart = DirIt(UserAssetPath, FileErr), DirEnd;
146151
!FileErr && DirStart != DirEnd; DirStart.increment(FileErr)) {
147152
FilePath = DirStart->path();
148153
if (llvm::sys::fs::is_regular_file(FilePath)) {
@@ -268,8 +273,8 @@ Example usage for a project using a compile commands database:
268273
OutDirectory,
269274
SourceRoot,
270275
RepositoryUrl,
271-
{UserStylesheets.begin(), UserStylesheets.end()}
272-
};
276+
BaseDirectory,
277+
{UserStylesheets.begin(), UserStylesheets.end()}};
273278

274279
if (Format == "html") {
275280
if (auto Err = getHtmlAssetFiles(argv[0], CDCtx)) {

clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ void UseInternalLinkageCheck::registerMatchers(MatchFinder *Finder) {
130130
isMain())))
131131
.bind("fn"),
132132
this);
133-
Finder->addMatcher(varDecl(Common, hasGlobalStorage()).bind("var"), this);
133+
Finder->addMatcher(
134+
varDecl(Common, hasGlobalStorage(), unless(hasThreadStorageDuration()))
135+
.bind("var"),
136+
this);
134137
}
135138

136139
static constexpr StringRef Message =

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ Changes in existing checks
159159

160160
- Improved :doc:`misc-use-internal-linkage
161161
<clang-tidy/checks/misc/use-internal-linkage>` check by fix false positives
162-
for function or variable in header file which contains macro expansion.
162+
for function or variable in header file which contains macro expansion and
163+
excluding variables with ``thread_local`` storage class specifier from being
164+
matched.
163165

164166
- Improved :doc:`modernize-use-default-member-init
165167
<clang-tidy/checks/modernize/use-default-member-init>` check by matching

clang-tools-extra/docs/clang-tidy/checks/bugprone/argument-comment.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@ Options
2424

2525
.. option:: StrictMode
2626

27-
When `false` (default value), the check will ignore leading and trailing
27+
When `false`, the check will ignore leading and trailing
2828
underscores and case when comparing names -- otherwise they are taken into
29-
account.
29+
account. Default is `false`.
3030

3131
.. option:: IgnoreSingleArgument
3232

33-
When `true`, the check will ignore the single argument.
33+
When `true`, the check will ignore the single argument. Default is `false`.
3434

3535
.. option:: CommentBoolLiterals
3636

3737
When `true`, the check will add argument comments in the format
3838
``/*ParameterName=*/`` right before the boolean literal argument.
39+
Default is `false`.
3940

4041
Before:
4142

@@ -55,8 +56,9 @@ After:
5556

5657
.. option:: CommentIntegerLiterals
5758

58-
When true, the check will add argument comments in the format
59+
When `true`, the check will add argument comments in the format
5960
``/*ParameterName=*/`` right before the integer literal argument.
61+
Default is `false`.
6062

6163
Before:
6264

@@ -76,8 +78,9 @@ After:
7678

7779
.. option:: CommentFloatLiterals
7880

79-
When true, the check will add argument comments in the format
81+
When `true`, the check will add argument comments in the format
8082
``/*ParameterName=*/`` right before the float/double literal argument.
83+
Default is `false`.
8184

8285
Before:
8386

@@ -97,8 +100,9 @@ After:
97100

98101
.. option:: CommentStringLiterals
99102

100-
When true, the check will add argument comments in the format
103+
When `true`, the check will add argument comments in the format
101104
``/*ParameterName=*/`` right before the string literal argument.
105+
Default is `false`.
102106

103107
Before:
104108

@@ -122,8 +126,9 @@ After:
122126

123127
.. option:: CommentCharacterLiterals
124128

125-
When true, the check will add argument comments in the format
129+
When `true`, the check will add argument comments in the format
126130
``/*ParameterName=*/`` right before the character literal argument.
131+
Default is `false`.
127132

128133
Before:
129134

@@ -143,8 +148,9 @@ After:
143148

144149
.. option:: CommentUserDefinedLiterals
145150

146-
When true, the check will add argument comments in the format
151+
When `true`, the check will add argument comments in the format
147152
``/*ParameterName=*/`` right before the user defined literal argument.
153+
Default is `false`.
148154

149155
Before:
150156

@@ -168,8 +174,9 @@ After:
168174

169175
.. option:: CommentNullPtrs
170176

171-
When true, the check will add argument comments in the format
177+
When `true`, the check will add argument comments in the format
172178
``/*ParameterName=*/`` right before the nullptr literal argument.
179+
Default is `false`.
173180

174181
Before:
175182

clang-tools-extra/test/clang-doc/assets.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: rm -rf %t && mkdir %t
2-
// RUN: clang-doc --format=html --output=%t --asset=%S/Inputs/test-assets --executor=standalone %s
2+
// RUN: clang-doc --format=html --output=%t --asset=%S/Inputs/test-assets --executor=standalone %s --base base_dir
33
// RUN: FileCheck %s -input-file=%t/index.html -check-prefix=INDEX
44
// RUN: FileCheck %s -input-file=%t/test.css -check-prefix=CSS
55
// RUN: FileCheck %s -input-file=%t/test.js -check-prefix=JS
@@ -19,4 +19,4 @@
1919
// CSS-NEXT: padding: 0;
2020
// CSS-NEXT: }
2121

22-
// JS: console.log("Hello, world!");
22+
// JS: console.log("Hello, world!");
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: rm -rf %t && mkdir -p %t
2-
// RUN: clang-doc --format=html --executor=standalone %s --output=%t
2+
// RUN: clang-doc --format=html --executor=standalone %s --output=%t --base base_dir
33
// RUN: FileCheck %s -input-file=%t/index_json.js -check-prefix=JSON-INDEX
44

55
// JSON-INDEX: var RootPath = "{{.*}}test-path-abs.cpp.tmp";
6+
// JSON-INDEX-NEXT: var Base = "base_dir";
7+

clang-tools-extra/test/clang-tidy/checkers/misc/use-internal-linkage-var.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ extern int global_extern;
3131

3232
static int global_static;
3333

34+
thread_local int global_thread_local;
35+
3436
namespace {
3537
static int global_anonymous_ns;
3638
namespace NS {
@@ -41,6 +43,7 @@ static int global_anonymous_ns;
4143
static void f(int para) {
4244
int local;
4345
static int local_static;
46+
thread_local int local_thread_local;
4447
}
4548

4649
struct S {

clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ std::unique_ptr<Generator> getHTMLGenerator() {
2828

2929
ClangDocContext
3030
getClangDocContext(std::vector<std::string> UserStylesheets = {},
31-
StringRef RepositoryUrl = "") {
32-
ClangDocContext CDCtx{
33-
{}, "test-project", {}, {}, {}, RepositoryUrl, UserStylesheets};
31+
StringRef RepositoryUrl = "", StringRef Base = "") {
32+
ClangDocContext CDCtx{{}, "test-project", {}, {},
33+
{}, RepositoryUrl, Base, UserStylesheets};
3434
CDCtx.UserStylesheets.insert(
3535
CDCtx.UserStylesheets.begin(),
3636
"../share/clang/clang-doc-default-stylesheet.css");

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ Miscellaneous Bug Fixes
389389
Miscellaneous Clang Crashes Fixed
390390
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
391391

392+
- Fixed crash when ``-print-stats`` is enabled in compiling IR files. (#GH131608)
393+
392394
OpenACC Specific Changes
393395
------------------------
394396

clang/include/clang/Basic/Builtins.td

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4869,7 +4869,7 @@ def HLSLWaveReadLaneAt : LangBuiltin<"HLSL_LANG"> {
48694869

48704870
def HLSLClamp : LangBuiltin<"HLSL_LANG"> {
48714871
let Spellings = ["__builtin_hlsl_elementwise_clamp"];
4872-
let Attributes = [NoThrow, Const];
4872+
let Attributes = [NoThrow, Const, CustomTypeChecking];
48734873
let Prototype = "void(...)";
48744874
}
48754875

@@ -4881,13 +4881,13 @@ def HLSLCross: LangBuiltin<"HLSL_LANG"> {
48814881

48824882
def HLSLDegrees : LangBuiltin<"HLSL_LANG"> {
48834883
let Spellings = ["__builtin_hlsl_elementwise_degrees"];
4884-
let Attributes = [NoThrow, Const];
4884+
let Attributes = [NoThrow, Const, CustomTypeChecking];
48854885
let Prototype = "void(...)";
48864886
}
48874887

48884888
def HLSLDotProduct : LangBuiltin<"HLSL_LANG"> {
48894889
let Spellings = ["__builtin_hlsl_dot"];
4890-
let Attributes = [NoThrow, Const];
4890+
let Attributes = [NoThrow, Const, CustomTypeChecking];
48914891
let Prototype = "void(...)";
48924892
}
48934893

@@ -4917,7 +4917,7 @@ def HLSLFirstBitLow : LangBuiltin<"HLSL_LANG"> {
49174917

49184918
def HLSLFrac : LangBuiltin<"HLSL_LANG"> {
49194919
let Spellings = ["__builtin_hlsl_elementwise_frac"];
4920-
let Attributes = [NoThrow, Const];
4920+
let Attributes = [NoThrow, Const, CustomTypeChecking];
49214921
let Prototype = "void(...)";
49224922
}
49234923

@@ -4929,7 +4929,7 @@ def HLSLIsinf : LangBuiltin<"HLSL_LANG"> {
49294929

49304930
def HLSLLerp : LangBuiltin<"HLSL_LANG"> {
49314931
let Spellings = ["__builtin_hlsl_lerp"];
4932-
let Attributes = [NoThrow, Const];
4932+
let Attributes = [NoThrow, Const, CustomTypeChecking];
49334933
let Prototype = "void(...)";
49344934
}
49354935

@@ -4941,25 +4941,25 @@ def HLSLMad : LangBuiltin<"HLSL_LANG"> {
49414941

49424942
def HLSLNormalize : LangBuiltin<"HLSL_LANG"> {
49434943
let Spellings = ["__builtin_hlsl_normalize"];
4944-
let Attributes = [NoThrow, Const];
4944+
let Attributes = [NoThrow, Const, CustomTypeChecking];
49454945
let Prototype = "void(...)";
49464946
}
49474947

49484948
def HLSLRcp : LangBuiltin<"HLSL_LANG"> {
49494949
let Spellings = ["__builtin_hlsl_elementwise_rcp"];
4950-
let Attributes = [NoThrow, Const];
4950+
let Attributes = [NoThrow, Const, CustomTypeChecking];
49514951
let Prototype = "void(...)";
49524952
}
49534953

49544954
def HLSLRSqrt : LangBuiltin<"HLSL_LANG"> {
49554955
let Spellings = ["__builtin_hlsl_elementwise_rsqrt"];
4956-
let Attributes = [NoThrow, Const];
4956+
let Attributes = [NoThrow, Const, CustomTypeChecking];
49574957
let Prototype = "void(...)";
49584958
}
49594959

49604960
def HLSLSaturate : LangBuiltin<"HLSL_LANG"> {
49614961
let Spellings = ["__builtin_hlsl_elementwise_saturate"];
4962-
let Attributes = [NoThrow, Const];
4962+
let Attributes = [NoThrow, Const, CustomTypeChecking];
49634963
let Prototype = "void(...)";
49644964
}
49654965

@@ -4983,7 +4983,7 @@ def HLSLStep: LangBuiltin<"HLSL_LANG"> {
49834983

49844984
def HLSLRadians : LangBuiltin<"HLSL_LANG"> {
49854985
let Spellings = ["__builtin_hlsl_elementwise_radians"];
4986-
let Attributes = [NoThrow, Const];
4986+
let Attributes = [NoThrow, Const, CustomTypeChecking];
49874987
let Prototype = "void(...)";
49884988
}
49894989

@@ -5001,7 +5001,7 @@ def HLSLSplitDouble: LangBuiltin<"HLSL_LANG"> {
50015001

50025002
def HLSLClip: LangBuiltin<"HLSL_LANG"> {
50035003
let Spellings = ["__builtin_hlsl_elementwise_clip"];
5004-
let Attributes = [NoThrow, Const];
5004+
let Attributes = [NoThrow, Const, CustomTypeChecking];
50055005
let Prototype = "void(...)";
50065006
}
50075007

clang/include/clang/Basic/LangOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,11 @@ class LangOptions : public LangOptionsBase {
838838
return FPExceptionModeKind::FPE_Ignore;
839839
return EM;
840840
}
841+
842+
/// True when compiling for an offloading target device.
843+
bool isTargetDevice() const {
844+
return OpenMPIsTargetDevice || CUDAIsDevice || SYCLIsDevice;
845+
}
841846
};
842847

843848
/// Floating point control options

clang/include/clang/Driver/ToolChain.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ class ToolChain {
524524
StringRef Component,
525525
FileType Type = ToolChain::FT_Static) const;
526526

527+
// Returns Triple without the OSs version.
528+
llvm::Triple getTripleWithoutOSVersion() const;
529+
527530
// Returns the target specific runtime path if it exists.
528531
std::optional<std::string> getRuntimePath() const;
529532

0 commit comments

Comments
 (0)