Skip to content

Commit 5326e7b

Browse files
committed
Merge from 'main' to 'sycl-web' (77 commits)
CONFLICT (content): Merge conflict in clang/lib/Basic/Targets/NVPTX.cpp
2 parents 1ce5b05 + bed7005 commit 5326e7b

File tree

761 files changed

+6455
-3702
lines changed

Some content is hidden

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

761 files changed

+6455
-3702
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions

clang-tools-extra/clangd/IncludeCleaner.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ clangd::Range getDiagnosticRange(llvm::StringRef Code, unsigned HashOffset) {
7878
return Result;
7979
}
8080

81-
8281
bool isFilteredByConfig(const Config &Cfg, llvm::StringRef HeaderPath) {
8382
// Convert the path to Unix slashes and try to match against the filter.
8483
llvm::SmallString<64> NormalizedPath(HeaderPath);
@@ -390,15 +389,17 @@ IncludeCleanerFindings computeIncludeCleanerFindings(ParsedAST &AST) {
390389
Ref.RT != include_cleaner::RefType::Explicit)
391390
return;
392391

393-
auto &Tokens = AST.getTokens();
394-
auto SpelledForExpanded =
395-
Tokens.spelledForExpanded(Tokens.expandedTokens(Ref.RefLocation));
396-
if (!SpelledForExpanded)
397-
return;
398-
399-
auto Range = syntax::Token::range(SM, SpelledForExpanded->front(),
400-
SpelledForExpanded->back());
401-
MissingIncludeDiagInfo DiagInfo{Ref.Target, Range, Providers};
392+
// We actually always want to map usages to their spellings, but
393+
// spelling locations can point into preamble section. Using these
394+
// offsets could lead into crashes in presence of stale preambles. Hence
395+
// we use "getFileLoc" instead to make sure it always points into main
396+
// file.
397+
// FIXME: Use presumed locations to map such usages back to patched
398+
// locations safely.
399+
auto Loc = SM.getFileLoc(Ref.RefLocation);
400+
const auto *Token = AST.getTokens().spelledTokenAt(Loc);
401+
MissingIncludeDiagInfo DiagInfo{Ref.Target, Token->range(SM),
402+
Providers};
402403
MissingIncludes.push_back(std::move(DiagInfo));
403404
});
404405
std::vector<const Inclusion *> UnusedIncludes =

clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,27 +178,39 @@ TEST(IncludeCleaner, GenerateMissingHeaderDiags) {
178178
WithContextValue Ctx(Config::Key, std::move(Cfg));
179179
Annotations MainFile(R"cpp(
180180
#include "a.h"
181+
#include "all.h"
181182
$insert_b[[]]#include "baz.h"
182183
#include "dir/c.h"
183-
$insert_d[[]]#include "fuzz.h"
184+
$insert_d[[]]$insert_foo[[]]#include "fuzz.h"
184185
#include "header.h"
185186
$insert_foobar[[]]#include <e.h>
186187
$insert_f[[]]$insert_vector[[]]
187188
188-
void foo() {
189-
$b[[b]]();
189+
#define DEF(X) const Foo *X;
190+
#define BAZ(X) const X x
190191
191-
ns::$bar[[Bar]] bar;
192-
bar.d();
193-
$f[[f]]();
192+
void foo() {
193+
$b[[b]]();
194194
195-
// this should not be diagnosed, because it's ignored in the config
196-
buzz();
195+
ns::$bar[[Bar]] bar;
196+
bar.d();
197+
$f[[f]]();
197198
198-
$foobar[[foobar]]();
199+
// this should not be diagnosed, because it's ignored in the config
200+
buzz();
199201
200-
std::$vector[[vector]] v;
201-
})cpp");
202+
$foobar[[foobar]]();
203+
204+
std::$vector[[vector]] v;
205+
206+
int var = $FOO[[FOO]];
207+
208+
$DEF[[DEF]](a);
209+
210+
$BAR[[BAR]](b);
211+
212+
BAZ($Foo[[Foo]]);
213+
})cpp");
202214

203215
TestTU TU;
204216
TU.Filename = "foo.cpp";
@@ -225,6 +237,13 @@ TEST(IncludeCleaner, GenerateMissingHeaderDiags) {
225237
namespace std { class vector {}; }
226238
)cpp");
227239

240+
TU.AdditionalFiles["all.h"] = guard("#include \"foo.h\"");
241+
TU.AdditionalFiles["foo.h"] = guard(R"cpp(
242+
#define BAR(x) Foo *x
243+
#define FOO 1
244+
struct Foo{};
245+
)cpp");
246+
228247
TU.Code = MainFile.code();
229248
ParsedAST AST = TU.build();
230249

@@ -254,7 +273,23 @@ TEST(IncludeCleaner, GenerateMissingHeaderDiags) {
254273
Diag(MainFile.range("vector"),
255274
"No header providing \"std::vector\" is directly included"),
256275
withFix(Fix(MainFile.range("insert_vector"),
257-
"#include <vector>\n", "#include <vector>")))));
276+
"#include <vector>\n", "#include <vector>"))),
277+
AllOf(Diag(MainFile.range("FOO"),
278+
"No header providing \"FOO\" is directly included"),
279+
withFix(Fix(MainFile.range("insert_foo"),
280+
"#include \"foo.h\"\n", "#include \"foo.h\""))),
281+
AllOf(Diag(MainFile.range("DEF"),
282+
"No header providing \"Foo\" is directly included"),
283+
withFix(Fix(MainFile.range("insert_foo"),
284+
"#include \"foo.h\"\n", "#include \"foo.h\""))),
285+
AllOf(Diag(MainFile.range("BAR"),
286+
"No header providing \"BAR\" is directly included"),
287+
withFix(Fix(MainFile.range("insert_foo"),
288+
"#include \"foo.h\"\n", "#include \"foo.h\""))),
289+
AllOf(Diag(MainFile.range("Foo"),
290+
"No header providing \"Foo\" is directly included"),
291+
withFix(Fix(MainFile.range("insert_foo"),
292+
"#include \"foo.h\"\n", "#include \"foo.h\"")))));
258293
}
259294

260295
TEST(IncludeCleaner, IWYUPragmas) {

clang-tools-extra/include-cleaner/lib/Analysis.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ void walkUsed(llvm::ArrayRef<Decl *> ASTRoots,
3636
tooling::stdlib::Recognizer Recognizer;
3737
for (auto *Root : ASTRoots) {
3838
walkAST(*Root, [&](SourceLocation Loc, NamedDecl &ND, RefType RT) {
39-
if (!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)))
39+
auto FID = SM.getFileID(SM.getSpellingLoc(Loc));
40+
if (FID != SM.getMainFileID() && FID != SM.getPreambleFileID())
4041
return;
41-
// FIXME: Most of the work done here is repetative. It might be useful to
42+
// FIXME: Most of the work done here is repetitive. It might be useful to
4243
// have a cache/batching.
4344
SymbolReference SymRef{Loc, ND, RT};
4445
return CB(SymRef, headersForSymbol(ND, SM, PI));

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ Improvements to Clang's diagnostics
186186
by prioritizing ``-Wunreachable-code-fallthrough``.
187187
- Clang now correctly diagnoses statement attributes ``[[clang::always_inine]]`` and
188188
``[[clang::noinline]]`` when used on a statement with dependent call expressions.
189+
- Clang now checks for completeness of the second and third arguments in the
190+
conditional operator.
191+
(`#59718 <https://github.com/llvm/llvm-project/issues/59718>`_)
189192

190193
Bug Fixes in This Version
191194
-------------------------
@@ -363,6 +366,8 @@ clang-format
363366
Compared to ``NextLine`` style, ``NextLineOnly`` style will not try to
364367
put the initializers on the current line first, instead, it will try to
365368
put the initializers on the next line only.
369+
- Add additional Qualifier Ordering support for special cases such
370+
as templates, requires clauses, long qualified names.
366371

367372
libclang
368373
--------

clang/include/clang/Basic/AttrDocs.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3807,7 +3807,7 @@ implicitly inherit this attribute.
38073807

38083808
def RISCVInterruptDocs : Documentation {
38093809
let Category = DocCatFunction;
3810-
let Heading = "interrupt (RISCV)";
3810+
let Heading = "interrupt (RISC-V)";
38113811
let Content = [{
38123812
Clang supports the GNU style ``__attribute__((interrupt))`` attribute on RISCV
38133813
targets. This attribute may be attached to a function definition and instructs

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def m_wasm_Features_Driver_Group : OptionGroup<"<wasm driver features group>">,
190190
def m_x86_Features_Group : OptionGroup<"<x86 features group>">,
191191
Group<m_Group>, Flags<[CoreOption]>, DocName<"X86">;
192192
def m_riscv_Features_Group : OptionGroup<"<riscv features group>">,
193-
Group<m_Group>, DocName<"RISCV">;
193+
Group<m_Group>, DocName<"RISC-V">;
194194

195195
def m_libc_Group : OptionGroup<"<m libc group>">, Group<m_mips_Features_Group>,
196196
Flags<[HelpHidden]>;
@@ -4067,6 +4067,8 @@ defm zvector : BoolFOption<"zvector",
40674067
def mzvector : Flag<["-"], "mzvector">, Alias<fzvector>;
40684068
def mno_zvector : Flag<["-"], "mno-zvector">, Alias<fno_zvector>;
40694069

4070+
def mxcoff_build_id_EQ : Joined<["-"], "mxcoff-build-id=">, Group<Link_Group>, MetaVarName<"<0xHEXSTRING>">,
4071+
HelpText<"On AIX, request creation of a build-id string, \"0xHEXSTRING\", in the string table of the loader section inside the linked binary">;
40704072
def mignore_xcoff_visibility : Flag<["-"], "mignore-xcoff-visibility">, Group<m_Group>,
40714073
HelpText<"Not emit the visibility attribute for asm in AIX OS or give all symbols 'unspecified' visibility in XCOFF object file">,
40724074
Flags<[CC1Option]>;

clang/lib/AST/ASTImporter.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,6 +2515,22 @@ ASTNodeImporter::VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias) {
25152515
QualType FromUT = D->getUnderlyingType();
25162516
QualType FoundUT = FoundTypedef->getUnderlyingType();
25172517
if (Importer.IsStructurallyEquivalent(FromUT, FoundUT)) {
2518+
// If the underlying declarations are unnamed records these can be
2519+
// imported as different types. We should create a distinct typedef
2520+
// node in this case.
2521+
// If we found an existing underlying type with a record in a
2522+
// different context (than the imported), this is already reason for
2523+
// having distinct typedef nodes for these.
2524+
// Again this can create situation like
2525+
// 'typedef int T; typedef int T;' but this is hard to avoid without
2526+
// a rename strategy at import.
2527+
if (!FromUT.isNull() && !FoundUT.isNull()) {
2528+
RecordDecl *FromR = FromUT->getAsRecordDecl();
2529+
RecordDecl *FoundR = FoundUT->getAsRecordDecl();
2530+
if (FromR && FoundR &&
2531+
!hasSameVisibilityContextAndLinkage(FoundR, FromR))
2532+
continue;
2533+
}
25182534
// If the "From" context has a complete underlying type but we
25192535
// already have a complete underlying type then return with that.
25202536
if (!FromUT->isIncompleteType() && !FoundUT->isIncompleteType())

clang/lib/Basic/Targets/NVPTX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
170170
MacroBuilder &Builder) const {
171171
Builder.defineMacro("__PTX__");
172172
Builder.defineMacro("__NVPTX__");
173-
if (Opts.CUDAIsDevice || Opts.OpenMPIsDevice || Opts.SYCLIsDevice) {
173+
if (Opts.CUDAIsDevice || Opts.OpenMPIsDevice || Opts.SYCLIsDevice ||
174+
!HostTarget) {
174175
// Set __CUDA_ARCH__ or __SYCL_CUDA_ARCH__ for the GPU specified.
175176
// The SYCL-specific macro is used to distinguish the SYCL and CUDA APIs.
176177
std::string CUDAArchCode = [this] {

clang/lib/Basic/Targets/RISCV.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//===--- RISCV.cpp - Implement RISCV target feature support ---------------===//
1+
//===--- RISCV.cpp - Implement RISC-V target feature support --------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file implements RISCV TargetInfo objects.
9+
// This file implements RISC-V TargetInfo objects.
1010
//
1111
//===----------------------------------------------------------------------===//
1212

clang/lib/Basic/Targets/RISCV.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
//===--- RISCV.h - Declare RISCV target feature support ---------*- C++ -*-===//
1+
//===--- RISCV.h - Declare RISC-V target feature support --------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file declares RISCV TargetInfo objects.
9+
// This file declares RISC-V TargetInfo objects.
1010
//
1111
//===----------------------------------------------------------------------===//
1212

clang/lib/CodeGen/TargetInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11270,7 +11270,7 @@ llvm::Type *CommonSPIRTargetCodeGenInfo::getOpenCLType(CodeGenModule &CGM,
1127011270
return nullptr;
1127111271
}
1127211272
//===----------------------------------------------------------------------===//
11273-
// RISCV ABI Implementation
11273+
// RISC-V ABI Implementation
1127411274
//===----------------------------------------------------------------------===//
1127511275

1127611276
namespace {

clang/lib/Driver/ToolChains/AIX.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,22 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
143143
Args.hasArg(options::OPT_coverage))
144144
CmdArgs.push_back("-bdbg:namedsects:ss");
145145

146+
if (Arg *A =
147+
Args.getLastArg(clang::driver::options::OPT_mxcoff_build_id_EQ)) {
148+
StringRef BuildId = A->getValue();
149+
if (BuildId[0] != '0' || BuildId[1] != 'x' ||
150+
BuildId.find_if_not(llvm::isHexDigit, 2) != StringRef::npos)
151+
ToolChain.getDriver().Diag(diag::err_drv_unsupported_option_argument)
152+
<< A->getSpelling() << BuildId;
153+
else {
154+
std::string LinkerFlag = "-bdbg:ldrinfo:xcoff_binary_id:0x";
155+
if (BuildId.size() % 2) // Prepend a 0 if odd number of digits.
156+
LinkerFlag += "0";
157+
LinkerFlag += BuildId.drop_front(2).lower();
158+
CmdArgs.push_back(Args.MakeArgString(LinkerFlag));
159+
}
160+
}
161+
146162
// Specify linker output file.
147163
assert((Output.isFilename() || Output.isNothing()) && "Invalid output.");
148164
if (Output.isFilename()) {

clang/lib/Driver/ToolChains/Arch/RISCV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- RISCV.cpp - RISCV Helpers for Tools --------------------*- C++ -*-===//
1+
//===--- RISCV.cpp - RISC-V Helpers for Tools -------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

clang/lib/Driver/ToolChains/Arch/RISCV.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- RISCV.h - RISCV-specific Tool Helpers ------------------*- C++ -*-===//
1+
//===--- RISCV.h - RISC-V-specific Tool Helpers -----------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

clang/lib/Driver/ToolChains/RISCVToolchain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- RISCVToolchain.cpp - RISCV ToolChain Implementations ---*- C++ -*-===//
1+
//===--- RISCVToolchain.cpp - RISC-V ToolChain Implementations --*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -46,7 +46,7 @@ bool RISCVToolChain::hasGCCToolchain(const Driver &D,
4646
return llvm::sys::fs::exists(GCCDir);
4747
}
4848

49-
/// RISCV Toolchain
49+
/// RISC-V Toolchain
5050
RISCVToolChain::RISCVToolChain(const Driver &D, const llvm::Triple &Triple,
5151
const ArgList &Args)
5252
: Generic_ELF(D, Triple, Args) {

clang/lib/Driver/ToolChains/RISCVToolchain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- RISCVToolchain.h - RISCV ToolChain Implementations -----*- C++ -*-===//
1+
//===--- RISCVToolchain.h - RISC-V ToolChain Implementations ----*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

0 commit comments

Comments
 (0)