Skip to content

Commit 7ebf225

Browse files
committed
Merge from 'main' to 'sycl-web' (100 commits)
CONFLICT (content): Merge conflict in clang/lib/CodeGen/CGExprScalar.cpp
2 parents 8e961dd + 8f11f98 commit 7ebf225

File tree

419 files changed

+15134
-11785
lines changed

Some content is hidden

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

419 files changed

+15134
-11785
lines changed

.github/workflows/docs.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ on:
2121
- 'libcxx/docs/**'
2222
- 'libc/docs/**'
2323
- 'lld/docs/**'
24+
- 'openmp/docs/**'
25+
- 'polly/docs/**'
2426
pull_request:
2527
paths:
2628
- 'llvm/docs/**'
@@ -31,6 +33,8 @@ on:
3133
- 'libcxx/docs/**'
3234
- 'libc/docs/**'
3335
- 'lld/docs/**'
36+
- 'openmp/docs/**'
37+
- 'polly/docs/**'
3438

3539
jobs:
3640
check-docs-build:
@@ -67,6 +71,10 @@ jobs:
6771
- 'libc/docs/**'
6872
lld:
6973
- 'lld/docs/**'
74+
openmp:
75+
- 'openmp/docs/**'
76+
polly:
77+
- 'polly/docs/**'
7078
- name: Fetch LLVM sources (PR)
7179
if: ${{ github.event_name == 'pull_request' }}
7280
uses: actions/checkout@v4
@@ -125,4 +133,14 @@ jobs:
125133
run: |
126134
cmake -B lld-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="lld" -DLLVM_ENABLE_SPHINX=ON ./llvm
127135
TZ=UTC ninja -C lld-build docs-lld-html
136+
- name: Build OpenMP docs
137+
if: steps.docs-changed-subprojects.outputs.openmp_any_changed == 'true'
138+
run: |
139+
cmake -B openmp-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;openmp" -DLLVM_ENABLE_SPHINX=ON ./llvm
140+
TZ=UTC ninja -C openmp-build docs-openmp-html
141+
- name: Build Polly docs
142+
if: steps.docs-changed-subprojects.outputs.polly_any_changed == 'true'
143+
run: |
144+
cmake -B polly-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="polly" -DLLVM_ENABLE_SPHINX=ON ./llvm
145+
TZ=UTC ninja -C polly-build docs-polly-html docs-polly-man
128146

clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ SourceRange getTypeRange(const ParmVarDecl &Param) {
2121
return {Param.getBeginLoc(), Param.getLocation().getLocWithOffset(-1)};
2222
}
2323

24+
// Finds the location of the qualifying `const` token in the `ParmValDecl`'s
25+
// return type. Returns `std::nullopt` when the parm type is not
26+
// `const`-qualified like when the type is an alias or a macro.
27+
static std::optional<Token>
28+
findConstToRemove(const ParmVarDecl &Param,
29+
const MatchFinder::MatchResult &Result) {
30+
31+
CharSourceRange FileRange = Lexer::makeFileCharRange(
32+
CharSourceRange::getTokenRange(getTypeRange(Param)),
33+
*Result.SourceManager, Result.Context->getLangOpts());
34+
35+
if (FileRange.isInvalid())
36+
return std::nullopt;
37+
38+
return tidy::utils::lexer::getQualifyingToken(
39+
tok::kw_const, FileRange, *Result.Context, *Result.SourceManager);
40+
}
41+
2442
} // namespace
2543

2644
void AvoidConstParamsInDecls::storeOptions(ClangTidyOptions::OptionMap &Opts) {
@@ -30,11 +48,10 @@ void AvoidConstParamsInDecls::storeOptions(ClangTidyOptions::OptionMap &Opts) {
3048
void AvoidConstParamsInDecls::registerMatchers(MatchFinder *Finder) {
3149
const auto ConstParamDecl =
3250
parmVarDecl(hasType(qualType(isConstQualified()))).bind("param");
33-
Finder->addMatcher(
34-
functionDecl(unless(isDefinition()),
35-
has(typeLoc(forEach(ConstParamDecl))))
36-
.bind("func"),
37-
this);
51+
Finder->addMatcher(functionDecl(unless(isDefinition()),
52+
has(typeLoc(forEach(ConstParamDecl))))
53+
.bind("func"),
54+
this);
3855
}
3956

4057
void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) {
@@ -50,7 +67,10 @@ void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) {
5067
return;
5168
}
5269

53-
auto Diag = diag(Param->getBeginLoc(),
70+
const auto Tok = findConstToRemove(*Param, Result);
71+
const auto ConstLocation = Tok ? Tok->getLocation() : Param->getBeginLoc();
72+
73+
auto Diag = diag(ConstLocation,
5474
"parameter %0 is const-qualified in the function "
5575
"declaration; const-qualification of parameters only has an "
5676
"effect in function definitions");
@@ -70,18 +90,9 @@ void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) {
7090
// from a macro.
7191
return;
7292
}
73-
74-
CharSourceRange FileRange = Lexer::makeFileCharRange(
75-
CharSourceRange::getTokenRange(getTypeRange(*Param)),
76-
*Result.SourceManager, getLangOpts());
77-
78-
if (!FileRange.isValid())
79-
return;
80-
81-
auto Tok = tidy::utils::lexer::getQualifyingToken(
82-
tok::kw_const, FileRange, *Result.Context, *Result.SourceManager);
8393
if (!Tok)
8494
return;
95+
8596
Diag << FixItHint::CreateRemoval(
8697
CharSourceRange::getTokenRange(Tok->getLocation(), Tok->getLocation()));
8798
}

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ Changes in existing checks
369369
<clang-tidy/checks/readability/braces-around-statements>` check to
370370
ignore false-positive for ``if constexpr`` in lambda expression.
371371

372+
- Improved :doc:`readability-avoid-const-params-in-decls
373+
<clang-tidy/checks/readability/avoid-const-params-in-decls>` diagnositics to
374+
highlight the const location
375+
372376
- Improved :doc:`readability-container-size-empty
373377
<clang-tidy/checks/readability/container-size-empty>` check to
374378
detect comparison between string and empty string literals and support

clang-tools-extra/test/clang-tidy/checkers/readability/avoid-const-params-in-decls.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ void F1(const int i);
99
// CHECK-FIXES: void F1(int i);
1010

1111
void F2(const int *const i);
12-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
12+
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: parameter 'i' is const-qualified
1313
// CHECK-FIXES: void F2(const int *i);
1414

1515
void F3(int const i);
16-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
16+
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: parameter 'i' is const-qualified
1717
// CHECK-FIXES: void F3(int i);
1818

1919
void F4(alias_type const i);
20-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
20+
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: parameter 'i' is const-qualified
2121
// CHECK-FIXES: void F4(alias_type i);
2222

2323
void F5(const int);
2424
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 1 is const-qualified
2525
// CHECK-FIXES: void F5(int);
2626

2727
void F6(const int *const);
28-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 1 is const-qualified
28+
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: parameter 1 is const-qualified
2929
// CHECK-FIXES: void F6(const int *);
3030

3131
void F7(int, const int);
@@ -42,7 +42,7 @@ void F9(const int long_name);
4242
// CHECK-FIXES: void F9(int long_name);
4343

4444
void F10(const int *const *const long_name);
45-
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'long_name'
45+
// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: parameter 'long_name'
4646
// CHECK-FIXES: void F10(const int *const *long_name);
4747

4848
void F11(const unsigned int /*v*/);
@@ -71,11 +71,11 @@ void F15(const A<const int> Named);
7171
// CHECK-FIXES: void F15(A<const int> Named);
7272

7373
void F16(const A<const int> *const);
74-
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 1 is const-qualified
74+
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: parameter 1 is const-qualified
7575
// CHECK-FIXES: void F16(const A<const int> *);
7676

7777
void F17(const A<const int> *const Named);
78-
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'Named' is const-qualified
78+
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: parameter 'Named' is const-qualified
7979
// CHECK-FIXES: void F17(const A<const int> *Named);
8080

8181
struct Foo {

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ clang-format
820820
------------
821821
- Add ``AllowBreakBeforeNoexceptSpecifier`` option.
822822
- Add ``AllowShortCompoundRequirementOnASingleLine`` option.
823+
- Change ``BreakAfterAttributes`` from ``Never`` to ``Leave`` in LLVM style.
823824

824825
libclang
825826
--------

clang/docs/StandardCPlusPlusModules.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ the above example could be rewritten into:
365365
366366
$ clang++ -std=c++20 M.cppm --precompile -fmodule-file=M:interface_part=M-interface_part.pcm -fmodule-file=M:impl_part=M-impl_part.pcm -o M.pcm
367367
368+
When there are multiple ``-fmodule-file=<module-name>=`` options for the same
369+
``<module-name>``, the last ``-fmodule-file=<module-name>=`` will override the previous
370+
``-fmodule-file=<module-name>=`` options.
371+
368372
``-fprebuilt-module-path`` is more convenient and ``-fmodule-file`` is faster since
369373
it saves time for file lookup.
370374

clang/include/clang/Basic/LangStandard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum class Language : uint8_t {
4343
HLSL,
4444
///@}
4545
};
46+
StringRef languageToString(Language L);
4647

4748
enum LangFeatures {
4849
LineComment = (1 << 0),

clang/lib/AST/Interp/ByteCodeStmtGen.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ bool ByteCodeStmtGen<Emitter>::visitStmt(const Stmt *S) {
255255
return visitAsmStmt(cast<AsmStmt>(S));
256256
case Stmt::AttributedStmtClass:
257257
return visitAttributedStmt(cast<AttributedStmt>(S));
258+
case Stmt::CXXTryStmtClass:
259+
return visitCXXTryStmt(cast<CXXTryStmt>(S));
258260
case Stmt::NullStmtClass:
259261
return true;
260262
default: {
@@ -643,6 +645,12 @@ bool ByteCodeStmtGen<Emitter>::visitAttributedStmt(const AttributedStmt *S) {
643645
return this->visitStmt(S->getSubStmt());
644646
}
645647

648+
template <class Emitter>
649+
bool ByteCodeStmtGen<Emitter>::visitCXXTryStmt(const CXXTryStmt *S) {
650+
// Ignore all handlers.
651+
return this->visitStmt(S->getTryBlock());
652+
}
653+
646654
namespace clang {
647655
namespace interp {
648656

clang/lib/AST/Interp/ByteCodeStmtGen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class ByteCodeStmtGen final : public ByteCodeExprGen<Emitter> {
6565
bool visitDefaultStmt(const DefaultStmt *S);
6666
bool visitAsmStmt(const AsmStmt *S);
6767
bool visitAttributedStmt(const AttributedStmt *S);
68+
bool visitCXXTryStmt(const CXXTryStmt *S);
6869

6970
bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
7071

clang/lib/AST/Interp/IntegralAP.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ template <bool Signed> class IntegralAP final {
124124
bool isNegative() const { return !V.isNonNegative(); }
125125
bool isMin() const { return V.isMinValue(); }
126126
bool isMax() const { return V.isMaxValue(); }
127-
static bool isSigned() { return Signed; }
127+
static constexpr bool isSigned() { return Signed; }
128128
bool isMinusOne() const { return Signed && V == -1; }
129129

130130
unsigned countLeadingZeros() const { return V.countl_zero(); }

clang/lib/Basic/LangStandards.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,39 @@
1313
#include "llvm/TargetParser/Triple.h"
1414
using namespace clang;
1515

16+
StringRef clang::languageToString(Language L) {
17+
switch (L) {
18+
case Language::Unknown:
19+
return "Unknown";
20+
case Language::Asm:
21+
return "Asm";
22+
case Language::LLVM_IR:
23+
return "LLVM IR";
24+
case Language::C:
25+
return "C";
26+
case Language::CXX:
27+
return "C++";
28+
case Language::ObjC:
29+
return "Objective-C";
30+
case Language::ObjCXX:
31+
return "Objective-C++";
32+
case Language::OpenCL:
33+
return "OpenCL";
34+
case Language::OpenCLCXX:
35+
return "OpenCLC++";
36+
case Language::CUDA:
37+
return "CUDA";
38+
case Language::RenderScript:
39+
return "RenderScript";
40+
case Language::HIP:
41+
return "HIP";
42+
case Language::HLSL:
43+
return "HLSL";
44+
}
45+
46+
llvm_unreachable("unhandled language kind");
47+
}
48+
1649
#define LANGSTANDARD(id, name, lang, desc, features) \
1750
static const LangStandard Lang_##id = {name, desc, features, Language::lang};
1851
#include "clang/Basic/LangStandards.def"

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,6 @@ llvm::Value *CodeGenFunction::EmitLifetimeStart(llvm::TypeSize Size,
13941394
"Pointer should be in alloca address space");
13951395
llvm::Value *SizeV = llvm::ConstantInt::get(
13961396
Int64Ty, Size.isScalable() ? -1 : Size.getFixedValue());
1397-
Addr = Builder.CreateBitCast(Addr, AllocaInt8PtrTy);
13981397
llvm::CallInst *C =
13991398
Builder.CreateCall(CGM.getLLVMLifetimeStartFn(), {SizeV, Addr});
14001399
C->setDoesNotThrow();
@@ -1405,7 +1404,6 @@ void CodeGenFunction::EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr) {
14051404
assert(Addr->getType()->getPointerAddressSpace() ==
14061405
CGM.getDataLayout().getAllocaAddrSpace() &&
14071406
"Pointer should be in alloca address space");
1408-
Addr = Builder.CreateBitCast(Addr, AllocaInt8PtrTy);
14091407
llvm::CallInst *C =
14101408
Builder.CreateCall(CGM.getLLVMLifetimeEndFn(), {Size, Addr});
14111409
C->setDoesNotThrow();

clang/lib/CodeGen/CGExprCXX.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,9 +1106,7 @@ void CodeGenFunction::EmitNewArrayInitializer(
11061106
// element. TODO: some of these stores can be trivially
11071107
// observed to be unnecessary.
11081108
if (EndOfInit.isValid()) {
1109-
auto FinishedPtr =
1110-
Builder.CreateBitCast(CurPtr.getPointer(), BeginPtr.getType());
1111-
Builder.CreateStore(FinishedPtr, EndOfInit);
1109+
Builder.CreateStore(CurPtr.getPointer(), EndOfInit);
11121110
}
11131111
// FIXME: If the last initializer is an incomplete initializer list for
11141112
// an array, and we have an array filler, we can fold together the two

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,10 +2110,10 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
21102110
Src = Builder.CreateAddrSpaceCast(
21112111
Src,
21122112
llvm::PointerType::get(VMContext, DstTy->getPointerAddressSpace()));
2113-
else if (SrcTy->isPtrOrPtrVectorTy() && DstTy->isPtrOrPtrVectorTy() &&
2114-
SrcTy->getPointerAddressSpace() != DstTy->getPointerAddressSpace())
2115-
llvm_unreachable("wrong cast for pointers in different address spaces"
2116-
"(must be an address space cast)!");
2113+
assert(
2114+
(!SrcTy->isPtrOrPtrVectorTy() || !DstTy->isPtrOrPtrVectorTy() ||
2115+
SrcTy->getPointerAddressSpace() == DstTy->getPointerAddressSpace()) &&
2116+
"Address-space cast must be used to convert address spaces");
21172117

21182118
if (CGF.SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
21192119
if (auto *PT = DestTy->getAs<PointerType>()) {

clang/lib/CodeGen/CGNonTrivialStruct.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,6 @@ template <class Derived> struct GenFuncBase {
367367
CGF.Builder.CreateNUWMul(BaseEltSizeVal, NumElts);
368368
llvm::Value *DstArrayEnd = CGF.Builder.CreateInBoundsGEP(
369369
CGF.Int8Ty, DstAddr.getPointer(), SizeInBytes);
370-
DstArrayEnd = CGF.Builder.CreateBitCast(
371-
DstArrayEnd, CGF.CGM.Int8PtrPtrTy, "dstarray.end");
372370
llvm::BasicBlock *PreheaderBB = CGF.Builder.GetInsertBlock();
373371

374372
// Create the header block and insert the phi instructions.

0 commit comments

Comments
 (0)