Skip to content

Commit 5b5ec44

Browse files
committed
merge main into amd-staging
xfail: new test llvm/test/CodeGen/AMDGPU/mcexpr-knownbits-assign-crash-gh-issue-110930.ll Revert: breaks build of libdevice 6e0b003 [clang][OpenCL][CodeGen][AMDGPU] Do not use `private` as the default AS for when `generic` is available (llvm#112442) Change-Id: Id9b4f991e125cf64446a1fb7dc9ace29289b386a
2 parents af4fc56 + 2e0506f commit 5b5ec44

File tree

247 files changed

+11669
-4361
lines changed

Some content is hidden

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

247 files changed

+11669
-4361
lines changed

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
281281
for (auto &Row : TUIndex.getRows()) {
282282
uint64_t Signature = Row.getSignature();
283283
// manually populate TypeUnit to UnitVector
284-
DwarfContext->getTypeUnitForHash(DwarfContext->getMaxVersion(), Signature,
285-
true);
284+
DwarfContext->getTypeUnitForHash(Signature, true);
286285
}
287286
}
288287
const unsigned int CUNum = getCUNum(DwarfContext, isDWO());

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,25 +172,25 @@ void ConstCorrectnessCheck::check(const MatchFinder::MatchResult &Result) {
172172

173173
using namespace utils::fixit;
174174
if (VC == VariableCategory::Value && TransformValues) {
175-
Diag << addQualifierToVarDecl(*Variable, *Result.Context,
176-
DeclSpec::TQ_const, QualifierTarget::Value,
175+
Diag << addQualifierToVarDecl(*Variable, *Result.Context, Qualifiers::Const,
176+
QualifierTarget::Value,
177177
QualifierPolicy::Right);
178178
// FIXME: Add '{}' for default initialization if no user-defined default
179179
// constructor exists and there is no initializer.
180180
return;
181181
}
182182

183183
if (VC == VariableCategory::Reference && TransformReferences) {
184-
Diag << addQualifierToVarDecl(*Variable, *Result.Context,
185-
DeclSpec::TQ_const, QualifierTarget::Value,
184+
Diag << addQualifierToVarDecl(*Variable, *Result.Context, Qualifiers::Const,
185+
QualifierTarget::Value,
186186
QualifierPolicy::Right);
187187
return;
188188
}
189189

190190
if (VC == VariableCategory::Pointer) {
191191
if (WarnPointersAsValues && TransformPointersAsValues) {
192192
Diag << addQualifierToVarDecl(*Variable, *Result.Context,
193-
DeclSpec::TQ_const, QualifierTarget::Value,
193+
Qualifiers::Const, QualifierTarget::Value,
194194
QualifierPolicy::Right);
195195
}
196196
return;

clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ bool ForRangeCopyCheck::handleConstValueCopy(const VarDecl &LoopVar,
9191
<< utils::fixit::changeVarDeclToReference(LoopVar, Context);
9292
if (!LoopVar.getType().isConstQualified()) {
9393
if (std::optional<FixItHint> Fix = utils::fixit::addQualifierToVarDecl(
94-
LoopVar, Context, DeclSpec::TQ::TQ_const))
94+
LoopVar, Context, Qualifiers::Const))
9595
Diagnostic << *Fix;
9696
}
9797
return true;
@@ -129,7 +129,7 @@ bool ForRangeCopyCheck::handleCopyIsOnlyConstReferenced(
129129
"making it a const reference");
130130

131131
if (std::optional<FixItHint> Fix = utils::fixit::addQualifierToVarDecl(
132-
LoopVar, Context, DeclSpec::TQ::TQ_const))
132+
LoopVar, Context, Qualifiers::Const))
133133
Diag << *Fix << utils::fixit::changeVarDeclToReference(LoopVar, Context);
134134

135135
return true;

clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void recordFixes(const VarDecl &Var, ASTContext &Context,
3636
Diagnostic << utils::fixit::changeVarDeclToReference(Var, Context);
3737
if (!Var.getType().isLocalConstQualified()) {
3838
if (std::optional<FixItHint> Fix = utils::fixit::addQualifierToVarDecl(
39-
Var, Context, DeclSpec::TQ::TQ_const))
39+
Var, Context, Qualifiers::Const))
4040
Diagnostic << *Fix;
4141
}
4242
}

clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void UnnecessaryValueParamCheck::handleConstRefFix(const FunctionDecl &Function,
172172
// declaration.
173173
if (!CurrentParam.getType().getCanonicalType().isConstQualified()) {
174174
if (std::optional<FixItHint> Fix = utils::fixit::addQualifierToVarDecl(
175-
CurrentParam, Context, DeclSpec::TQ::TQ_const))
175+
CurrentParam, Context, Qualifiers::Const))
176176
Diag << *Fix;
177177
}
178178
}

clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "clang/AST/ASTContext.h"
1212
#include "clang/AST/ExprCXX.h"
1313
#include "clang/AST/Type.h"
14+
#include "clang/Sema/DeclSpec.h"
1415
#include "clang/Tooling/FixIt.h"
1516
#include <optional>
1617

@@ -71,15 +72,17 @@ static std::optional<FixItHint> fixIfNotDangerous(SourceLocation Loc,
7172

7273
// Build a string that can be emitted as FixIt with either a space in before
7374
// or after the qualifier, either ' const' or 'const '.
74-
static std::string buildQualifier(DeclSpec::TQ Qualifier,
75+
static std::string buildQualifier(Qualifiers::TQ Qualifier,
7576
bool WhitespaceBefore = false) {
7677
if (WhitespaceBefore)
77-
return (llvm::Twine(' ') + DeclSpec::getSpecifierName(Qualifier)).str();
78-
return (llvm::Twine(DeclSpec::getSpecifierName(Qualifier)) + " ").str();
78+
return (llvm::Twine(' ') + Qualifiers::fromCVRMask(Qualifier).getAsString())
79+
.str();
80+
return (llvm::Twine(Qualifiers::fromCVRMask(Qualifier).getAsString()) + " ")
81+
.str();
7982
}
8083

8184
static std::optional<FixItHint> changeValue(const VarDecl &Var,
82-
DeclSpec::TQ Qualifier,
85+
Qualifiers::TQ Qualifier,
8386
QualifierTarget QualTarget,
8487
QualifierPolicy QualPolicy,
8588
const ASTContext &Context) {
@@ -99,7 +102,7 @@ static std::optional<FixItHint> changeValue(const VarDecl &Var,
99102
}
100103

101104
static std::optional<FixItHint> changePointerItself(const VarDecl &Var,
102-
DeclSpec::TQ Qualifier,
105+
Qualifiers::TQ Qualifier,
103106
const ASTContext &Context) {
104107
if (locDangerous(Var.getLocation()))
105108
return std::nullopt;
@@ -112,7 +115,7 @@ static std::optional<FixItHint> changePointerItself(const VarDecl &Var,
112115
}
113116

114117
static std::optional<FixItHint>
115-
changePointer(const VarDecl &Var, DeclSpec::TQ Qualifier, const Type *Pointee,
118+
changePointer(const VarDecl &Var, Qualifiers::TQ Qualifier, const Type *Pointee,
116119
QualifierTarget QualTarget, QualifierPolicy QualPolicy,
117120
const ASTContext &Context) {
118121
// The pointer itself shall be marked as `const`. This is always to the right
@@ -163,7 +166,7 @@ changePointer(const VarDecl &Var, DeclSpec::TQ Qualifier, const Type *Pointee,
163166
}
164167

165168
static std::optional<FixItHint>
166-
changeReferencee(const VarDecl &Var, DeclSpec::TQ Qualifier, QualType Pointee,
169+
changeReferencee(const VarDecl &Var, Qualifiers::TQ Qualifier, QualType Pointee,
167170
QualifierTarget QualTarget, QualifierPolicy QualPolicy,
168171
const ASTContext &Context) {
169172
if (QualPolicy == QualifierPolicy::Left && isValueType(Pointee))
@@ -183,7 +186,7 @@ changeReferencee(const VarDecl &Var, DeclSpec::TQ Qualifier, QualType Pointee,
183186

184187
std::optional<FixItHint> addQualifierToVarDecl(const VarDecl &Var,
185188
const ASTContext &Context,
186-
DeclSpec::TQ Qualifier,
189+
Qualifiers::TQ Qualifier,
187190
QualifierTarget QualTarget,
188191
QualifierPolicy QualPolicy) {
189192
assert((QualPolicy == QualifierPolicy::Left ||

clang-tools-extra/clang-tidy/utils/FixItHintUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "clang/AST/ASTContext.h"
1313
#include "clang/AST/Decl.h"
14-
#include "clang/Sema/DeclSpec.h"
14+
#include "clang/AST/Type.h"
1515
#include <optional>
1616

1717
namespace clang::tidy::utils::fixit {
@@ -41,7 +41,7 @@ enum class QualifierTarget {
4141
/// Requires that `Var` is isolated in written code like in `int foo = 42;`.
4242
std::optional<FixItHint>
4343
addQualifierToVarDecl(const VarDecl &Var, const ASTContext &Context,
44-
DeclSpec::TQ Qualifier,
44+
Qualifiers::TQ Qualifier,
4545
QualifierTarget QualTarget = QualifierTarget::Pointee,
4646
QualifierPolicy QualPolicy = QualifierPolicy::Left);
4747

clang-tools-extra/docs/clang-tidy/checks/bugprone/unchecked-optional-access.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ For example:
7676
}
7777
}
7878
79+
Exception: accessor methods
80+
```````````````````````````
81+
82+
The check assumes *accessor* methods of a class are stable, with a heuristic to
83+
determine which methods are accessors. Specifically, parameter-free ``const``
84+
methods are treated as accessors. Note that this is not guaranteed to be safe
85+
-- but, it is widely used (safely) in practice, and so we have chosen to treat
86+
it as generally safe. Calls to non ``const`` methods are assumed to modify
87+
the state of the object and affect the stability of earlier accessor calls.
88+
7989
Rely on invariants of uncommon APIs
8090
-----------------------------------
8191

clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class ConstTransform : public ClangTidyCheck {
2727
void check(const MatchFinder::MatchResult &Result) override {
2828
const auto *D = Result.Nodes.getNodeAs<VarDecl>("var");
2929
using utils::fixit::addQualifierToVarDecl;
30-
std::optional<FixItHint> Fix = addQualifierToVarDecl(
31-
*D, *Result.Context, DeclSpec::TQ::TQ_const, CT, CP);
30+
std::optional<FixItHint> Fix =
31+
addQualifierToVarDecl(*D, *Result.Context, Qualifiers::Const, CT, CP);
3232
auto Diag = diag(D->getBeginLoc(), "doing const transformation");
3333
if (Fix)
3434
Diag << *Fix;

clang/include/clang/AST/ExprConcepts.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,6 @@ class NestedRequirement : public Requirement {
489489
return R->getKind() == RK_Nested;
490490
}
491491
};
492-
493-
using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
494-
495-
/// \brief create a Requirement::SubstitutionDiagnostic with only a
496-
/// SubstitutedEntity and DiagLoc using Sema's allocator.
497-
Requirement::SubstitutionDiagnostic *
498-
createSubstDiagAt(Sema &S, SourceLocation Location, EntityPrinter Printer);
499-
500492
} // namespace concepts
501493

502494
/// C++2a [expr.prim.req]:

clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "clang/AST/ASTContext.h"
1818
#include "clang/Analysis/CFG.h"
1919
#include "clang/Analysis/FlowSensitive/CFGMatchSwitch.h"
20+
#include "clang/Analysis/FlowSensitive/CachedConstAccessorsLattice.h"
2021
#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
2122
#include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
2223
#include "clang/Analysis/FlowSensitive/NoopLattice.h"
@@ -39,23 +40,28 @@ struct UncheckedOptionalAccessModelOptions {
3940
bool IgnoreSmartPointerDereference = false;
4041
};
4142

43+
using UncheckedOptionalAccessLattice = CachedConstAccessorsLattice<NoopLattice>;
44+
4245
/// Dataflow analysis that models whether optionals hold values or not.
4346
///
4447
/// Models the `std::optional`, `absl::optional`, and `base::Optional` types.
4548
class UncheckedOptionalAccessModel
46-
: public DataflowAnalysis<UncheckedOptionalAccessModel, NoopLattice> {
49+
: public DataflowAnalysis<UncheckedOptionalAccessModel,
50+
UncheckedOptionalAccessLattice> {
4751
public:
4852
UncheckedOptionalAccessModel(ASTContext &Ctx, dataflow::Environment &Env);
4953

5054
/// Returns a matcher for the optional classes covered by this model.
5155
static ast_matchers::DeclarationMatcher optionalClassDecl();
5256

53-
static NoopLattice initialElement() { return {}; }
57+
static UncheckedOptionalAccessLattice initialElement() { return {}; }
5458

55-
void transfer(const CFGElement &Elt, NoopLattice &L, Environment &Env);
59+
void transfer(const CFGElement &Elt, UncheckedOptionalAccessLattice &L,
60+
Environment &Env);
5661

5762
private:
58-
CFGMatchSwitch<TransferState<NoopLattice>> TransferMatchSwitch;
63+
CFGMatchSwitch<TransferState<UncheckedOptionalAccessLattice>>
64+
TransferMatchSwitch;
5965
};
6066

6167
class UncheckedOptionalAccessDiagnoser {
@@ -65,7 +71,8 @@ class UncheckedOptionalAccessDiagnoser {
6571

6672
llvm::SmallVector<SourceLocation>
6773
operator()(const CFGElement &Elt, ASTContext &Ctx,
68-
const TransferStateForDiagnostics<NoopLattice> &State) {
74+
const TransferStateForDiagnostics<UncheckedOptionalAccessLattice>
75+
&State) {
6976
return DiagnoseMatchSwitch(Elt, Ctx, State.Env);
7077
}
7178

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10188,7 +10188,7 @@ def warn_new_dangling_initializer_list : Warning<
1018810188
"will be destroyed at the end of the full-expression">,
1018910189
InGroup<DanglingInitializerList>;
1019010190
def warn_dangling_pointer_assignment : Warning<
10191-
"object backing the pointer %0 "
10191+
"object backing %select{|the pointer }0%1 "
1019210192
"will be destroyed at the end of the full-expression">,
1019310193
InGroup<DanglingAssignment>;
1019410194

clang/include/clang/Basic/Module.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ namespace clang {
4848

4949
class FileManager;
5050
class LangOptions;
51+
class ModuleMap;
5152
class TargetInfo;
5253

5354
/// Describes the name of a module.
@@ -99,6 +100,15 @@ struct ASTFileSignature : std::array<uint8_t, 20> {
99100
}
100101
};
101102

103+
/// Required to construct a Module.
104+
///
105+
/// This tag type is only constructible by ModuleMap, guaranteeing it ownership
106+
/// of all Module instances.
107+
class ModuleConstructorTag {
108+
explicit ModuleConstructorTag() = default;
109+
friend ModuleMap;
110+
};
111+
102112
/// Describes a module or submodule.
103113
///
104114
/// Aligned to 8 bytes to allow for llvm::PointerIntPair<Module *, 3>.
@@ -497,8 +507,9 @@ class alignas(8) Module {
497507
std::vector<Conflict> Conflicts;
498508

499509
/// Construct a new module or submodule.
500-
Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,
501-
bool IsFramework, bool IsExplicit, unsigned VisibilityID);
510+
Module(ModuleConstructorTag, StringRef Name, SourceLocation DefinitionLoc,
511+
Module *Parent, bool IsFramework, bool IsExplicit,
512+
unsigned VisibilityID);
502513

503514
~Module();
504515

@@ -749,7 +760,6 @@ class alignas(8) Module {
749760
///
750761
/// \returns The submodule if found, or NULL otherwise.
751762
Module *findSubmodule(StringRef Name) const;
752-
Module *findOrInferSubmodule(StringRef Name);
753763

754764
/// Get the Global Module Fragment (sub-module) for this module, it there is
755765
/// one.

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8241,7 +8241,7 @@ def fnative_half_arguments_and_returns : Flag<["-"], "fnative-half-arguments-and
82418241
def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">,
82428242
HelpText<"Allow function arguments and returns of type half">,
82438243
MarshallingInfoFlag<LangOpts<"HalfArgsAndReturns">>,
8244-
ImpliedByAnyOf<[fnative_half_arguments_and_returns.KeyPath]>;
8244+
ImpliedByAnyOf<[open_cl.KeyPath, render_script.KeyPath, hlsl.KeyPath, hip.KeyPath]>;
82458245
def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">,
82468246
HelpText<"Set default calling convention">,
82478247
Values<"cdecl,fastcall,stdcall,vectorcall,regcall,rtdcall">,

clang/include/clang/Lex/ModuleMap.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ class ModuleMap {
9393
/// named LangOpts::CurrentModule, if we've loaded it).
9494
Module *SourceModule = nullptr;
9595

96+
/// The allocator for all (sub)modules.
97+
llvm::SpecificBumpPtrAllocator<Module> ModulesAlloc;
98+
9699
/// Submodules of the current module that have not yet been attached to it.
97-
/// (Ownership is transferred if/when we create an enclosing module.)
98-
llvm::SmallVector<std::unique_ptr<Module>, 8> PendingSubmodules;
100+
/// (Relationship is set up if/when we create an enclosing module.)
101+
llvm::SmallVector<Module *, 8> PendingSubmodules;
99102

100103
/// The top-level modules that are known.
101104
llvm::StringMap<Module *> Modules;
@@ -502,6 +505,8 @@ class ModuleMap {
502505
/// \returns The named module, if known; otherwise, returns null.
503506
Module *findModule(StringRef Name) const;
504507

508+
Module *findOrInferSubmodule(Module *Parent, StringRef Name);
509+
505510
/// Retrieve a module with the given name using lexical name lookup,
506511
/// starting at the given context.
507512
///

clang/include/clang/Sema/Sema.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13435,6 +13435,13 @@ class Sema final : public SemaBase {
1343513435
return CodeSynthesisContexts.size() > NonInstantiationEntries;
1343613436
}
1343713437

13438+
using EntityPrinter = llvm::function_ref<void(llvm::raw_ostream &)>;
13439+
13440+
/// \brief create a Requirement::SubstitutionDiagnostic with only a
13441+
/// SubstitutedEntity and DiagLoc using ASTContext's allocator.
13442+
concepts::Requirement::SubstitutionDiagnostic *
13443+
createSubstDiagAt(SourceLocation Location, EntityPrinter Printer);
13444+
1343813445
///@}
1343913446

1344013447
//

clang/include/clang/Serialization/ModuleFile.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define LLVM_CLANG_SERIALIZATION_MODULEFILE_H
1616

1717
#include "clang/Basic/FileManager.h"
18+
#include "clang/Basic/LLVM.h"
1819
#include "clang/Basic/Module.h"
1920
#include "clang/Basic/SourceLocation.h"
2021
#include "clang/Serialization/ASTBitCodes.h"
@@ -144,8 +145,8 @@ class ModuleFile {
144145
/// The base directory of the module.
145146
std::string BaseDirectory;
146147

147-
std::string getTimestampFilename() const {
148-
return FileName + ".timestamp";
148+
static std::string getTimestampFilename(StringRef FileName) {
149+
return (FileName + ".timestamp").str();
149150
}
150151

151152
/// The original source file name that was used to build the

clang/include/clang/Support/Compiler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
#define CLANG_TEMPLATE_ABI __declspec(dllimport)
5050
#define CLANG_EXPORT_TEMPLATE
5151
#endif
52-
#elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX)
52+
#elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX) || \
53+
defined(__MVS__)
5354
#define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
5455
#define CLANG_TEMPLATE_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
5556
#define CLANG_EXPORT_TEMPLATE

0 commit comments

Comments
 (0)