Skip to content

Commit 366489e

Browse files
rebase
Created using spr 1.3.6
2 parents 8332d24 + acaa925 commit 366489e

File tree

143 files changed

+3139
-2606
lines changed

Some content is hidden

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

143 files changed

+3139
-2606
lines changed

.github/workflows/premerge.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
# several test suites in a row and discard statistics that we want
6666
# to save in the end.
6767
export SCCACHE_IDLE_TIMEOUT=0
68-
SCCACHE_LOG=info SCCACHE_ERROR_LOG=artifacts/sccache.log sccache --start-server
68+
sccache --start-server
6969
7070
./.ci/monolithic-linux.sh "${projects_to_build}" "${project_check_targets}" "${runtimes_to_build}" "${runtimes_check_targets}" "${runtimes_check_targets_needs_reconfig}" "${enable_cir}"
7171
- name: Upload Artifacts
@@ -117,7 +117,7 @@ jobs:
117117
call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64
118118
# See the comments above in the Linux job for why we define each of
119119
# these environment variables.
120-
bash -c "export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET; export SCCACHE_GCS_RW_MODE=READ_WRITE; export SCCACHE_IDLE_TIMEOUT=0; SCCACHE_LOG=info SCCACHE_ERROR_LOG=artifacts/sccache.log sccache --start-server; .ci/monolithic-windows.sh \"${{ steps.vars.outputs.windows-projects }}\" \"${{ steps.vars.outputs.windows-check-targets }}\""
120+
bash -c "export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET; export SCCACHE_GCS_RW_MODE=READ_WRITE; export SCCACHE_IDLE_TIMEOUT=0; sccache --start-server; .ci/monolithic-windows.sh \"${{ steps.vars.outputs.windows-projects }}\" \"${{ steps.vars.outputs.windows-check-targets }}\""
121121
- name: Upload Artifacts
122122
# In some cases, Github will fail to upload the artifact. We want to
123123
# continue anyways as a failed artifact upload is an infra failure, not

clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,8 @@ void TaggedUnionMemberCountCheck::check(
169169
if (!Root || !UnionField || !TagField)
170170
return;
171171

172-
const auto *UnionDef =
173-
UnionField->getType().getCanonicalType().getTypePtr()->getAsRecordDecl();
174-
const auto *EnumDef = llvm::dyn_cast<EnumDecl>(
175-
TagField->getType().getCanonicalType().getTypePtr()->getAsTagDecl());
176-
177-
assert(UnionDef && "UnionDef is missing!");
178-
assert(EnumDef && "EnumDef is missing!");
179-
if (!UnionDef || !EnumDef)
180-
return;
172+
const auto *UnionDef = UnionField->getType()->castAsRecordDecl();
173+
const auto *EnumDef = TagField->getType()->castAsEnumDecl();
181174

182175
const std::size_t UnionMemberCount = llvm::range_size(UnionDef->fields());
183176
auto [TagCount, CountingEnumConstantDecl] = getNumberOfEnumValues(EnumDef);

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ ExceptionSpecAnalyzer::analyzeBase(const CXXBaseSpecifier &Base,
6666
if (!RecType)
6767
return State::Unknown;
6868

69-
const auto *BaseClass =
70-
cast<CXXRecordDecl>(RecType->getOriginalDecl())->getDefinitionOrSelf();
71-
72-
return analyzeRecord(BaseClass, Kind);
69+
return analyzeRecord(RecType->getAsCXXRecordDecl(), Kind);
7370
}
7471

7572
ExceptionSpecAnalyzer::State

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,9 @@ bool FormatStringConverter::emitIntegerArgument(
460460
// be passed as its underlying type. However, printf will have forced
461461
// the signedness based on the format string, so we need to do the
462462
// same.
463-
if (const auto *ET = ArgType->getAs<EnumType>()) {
464-
if (const std::optional<std::string> MaybeCastType = castTypeForArgument(
465-
ArgKind,
466-
ET->getOriginalDecl()->getDefinitionOrSelf()->getIntegerType()))
463+
if (const auto *ED = ArgType->getAsEnumDecl()) {
464+
if (const std::optional<std::string> MaybeCastType =
465+
castTypeForArgument(ArgKind, ED->getIntegerType()))
467466
ArgFixes.emplace_back(
468467
ArgIndex, (Twine("static_cast<") + *MaybeCastType + ">(").str());
469468
else

clang-tools-extra/clangd/Hover.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,7 @@ std::optional<std::string> printExprValue(const Expr *E,
454454
Constant.Val.getInt().getSignificantBits() <= 64) {
455455
// Compare to int64_t to avoid bit-width match requirements.
456456
int64_t Val = Constant.Val.getInt().getExtValue();
457-
for (const EnumConstantDecl *ECD :
458-
T->castAs<EnumType>()->getOriginalDecl()->enumerators())
457+
for (const EnumConstantDecl *ECD : T->castAsEnumDecl()->enumerators())
459458
if (ECD->getInitVal() == Val)
460459
return llvm::formatv("{0} ({1})", ECD->getNameAsString(),
461460
printHex(Constant.Val.getInt()))
@@ -832,7 +831,7 @@ std::optional<HoverInfo> getThisExprHoverContents(const CXXThisExpr *CTE,
832831
ASTContext &ASTCtx,
833832
const PrintingPolicy &PP) {
834833
QualType OriginThisType = CTE->getType()->getPointeeType();
835-
QualType ClassType = declaredType(OriginThisType->getAsTagDecl());
834+
QualType ClassType = declaredType(OriginThisType->castAsTagDecl());
836835
// For partial specialization class, origin `this` pointee type will be
837836
// parsed as `InjectedClassNameType`, which will ouput template arguments
838837
// like "type-parameter-0-0". So we retrieve user written class type in this

clang/include/clang/AST/ASTContext.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
642642
/// contain data that is address discriminated. This includes
643643
/// implicitly authenticated values like vtable pointers, as well as
644644
/// explicitly qualified fields.
645-
bool containsAddressDiscriminatedPointerAuth(QualType T) {
645+
bool containsAddressDiscriminatedPointerAuth(QualType T) const {
646646
if (!isPointerAuthenticationAvailable())
647647
return false;
648648
return findPointerAuthContent(T) != PointerAuthContent::None;
@@ -656,8 +656,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
656656
bool containsNonRelocatablePointerAuth(QualType T) {
657657
if (!isPointerAuthenticationAvailable())
658658
return false;
659-
return findPointerAuthContent(T) ==
660-
PointerAuthContent::AddressDiscriminatedData;
659+
return findPointerAuthContent(T) != PointerAuthContent::None;
661660
}
662661

663662
private:
@@ -675,8 +674,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
675674
bool isPointerAuthenticationAvailable() const {
676675
return LangOpts.PointerAuthCalls || LangOpts.PointerAuthIntrinsics;
677676
}
678-
PointerAuthContent findPointerAuthContent(QualType T);
679-
llvm::DenseMap<const RecordDecl *, PointerAuthContent>
677+
PointerAuthContent findPointerAuthContent(QualType T) const;
678+
mutable llvm::DenseMap<const RecordDecl *, PointerAuthContent>
680679
RecordContainsAddressDiscriminatedPointerAuth;
681680

682681
ImportDecl *FirstLocalImport = nullptr;
@@ -3723,7 +3722,7 @@ OPT_LIST(V)
37233722
/// Resolve the root record to be used to derive the vtable pointer
37243723
/// authentication policy for the specified record.
37253724
const CXXRecordDecl *
3726-
baseForVTableAuthentication(const CXXRecordDecl *ThisClass);
3725+
baseForVTableAuthentication(const CXXRecordDecl *ThisClass) const;
37273726

37283727
bool useAbbreviatedThunkName(GlobalDecl VirtualMethodDecl,
37293728
StringRef MangledName);

clang/include/clang/AST/Decl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3915,6 +3915,10 @@ class TagDecl : public TypeDecl,
39153915
bool isUnion() const { return getTagKind() == TagTypeKind::Union; }
39163916
bool isEnum() const { return getTagKind() == TagTypeKind::Enum; }
39173917

3918+
bool isStructureOrClass() const {
3919+
return isStruct() || isClass() || isInterface();
3920+
}
3921+
39183922
/// Is this tag type named, either directly or via being defined in
39193923
/// a typedef of this type?
39203924
///

clang/include/clang/AST/Type.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,14 +2883,21 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
28832883
/// because the type is a RecordType or because it is the injected-class-name
28842884
/// type of a class template or class template partial specialization.
28852885
CXXRecordDecl *getAsCXXRecordDecl() const;
2886+
CXXRecordDecl *castAsCXXRecordDecl() const;
28862887

28872888
/// Retrieves the RecordDecl this type refers to.
28882889
RecordDecl *getAsRecordDecl() const;
2890+
RecordDecl *castAsRecordDecl() const;
2891+
2892+
/// Retrieves the EnumDecl this type refers to.
2893+
EnumDecl *getAsEnumDecl() const;
2894+
EnumDecl *castAsEnumDecl() const;
28892895

28902896
/// Retrieves the TagDecl that this type refers to, either
28912897
/// because the type is a TagType or because it is the injected-class-name
28922898
/// type of a class template or class template partial specialization.
28932899
TagDecl *getAsTagDecl() const;
2900+
TagDecl *castAsTagDecl() const;
28942901

28952902
/// If this is a pointer or reference to a RecordType, return the
28962903
/// CXXRecordDecl that the type refers to.

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12618,7 +12618,7 @@ def warn_zero_as_null_pointer_constant : Warning<
1261812618
InGroup<DiagGroup<"zero-as-null-pointer-constant">>, DefaultIgnore;
1261912619

1262012620
def warn_not_eliding_copy_on_return : Warning<
12621-
"not eliding copy on return">,
12621+
"not eliding copy on return">,
1262212622
InGroup<DiagGroup<"nrvo">>, DefaultIgnore;
1262312623

1262412624
def err_nullability_cs_multilevel : Error<

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,70 @@ def CIR_VTableGetVirtualFnAddrOp : CIR_Op<"vtable.get_virtual_fn_addr", [
19061906
}];
19071907
}
19081908

1909+
//===----------------------------------------------------------------------===//
1910+
// VTTAddrPointOp
1911+
//===----------------------------------------------------------------------===//
1912+
1913+
def CIR_VTTAddrPointOp : CIR_Op<"vtt.address_point", [
1914+
Pure, DeclareOpInterfaceMethods<SymbolUserOpInterface>
1915+
]> {
1916+
let summary = "Get the VTT address point";
1917+
let description = [{
1918+
The `vtt.address_point` operation retrieves an element from the virtual
1919+
table table (VTT), which is the address point of a C++ vtable. In virtual
1920+
inheritance, a set of internal `__vptr` members for an object are
1921+
initialized by this operation, which assigns an element from the VTT. The
1922+
initialization order is as follows:
1923+
1924+
The complete object constructors and destructors find the VTT,
1925+
via the mangled name of the VTT global variable. They pass the address of
1926+
the subobject's sub-VTT entry in the VTT as a second parameter
1927+
when calling the base object constructors and destructors.
1928+
The base object constructors and destructors use the address passed to
1929+
initialize the primary virtual pointer and virtual pointers that point to
1930+
the classes which either have virtual bases or override virtual functions
1931+
with a virtual step.
1932+
1933+
The first parameter is either the mangled name of VTT global variable
1934+
or the address of the subobject's sub-VTT entry in the VTT.
1935+
The second parameter `offset` provides a virtual step to adjust to
1936+
the actual address point of the vtable.
1937+
1938+
The return type is always a `!cir.ptr<!cir.ptr<void>>`.
1939+
1940+
Example:
1941+
```mlir
1942+
cir.global linkonce_odr @_ZTV1B = ...
1943+
...
1944+
%3 = cir.base_class_addr(%1 : !cir.ptr<!rec_D> nonnull) [0]
1945+
-> !cir.ptr<!rec_B>
1946+
%4 = cir.vtt.address_point @_ZTT1D, offset = 1
1947+
-> !cir.ptr<!cir.ptr<!void>>
1948+
cir.call @_ZN1BC2Ev(%3, %4)
1949+
```
1950+
Or:
1951+
```mlir
1952+
%7 = cir.vtt.address_point %3 : !cir.ptr<!cir.ptr<!void>>, offset = 1
1953+
-> !cir.ptr<!cir.ptr<!void>>
1954+
```
1955+
}];
1956+
1957+
let arguments = (ins OptionalAttr<FlatSymbolRefAttr>:$name,
1958+
Optional<CIR_AnyType>:$sym_addr,
1959+
I32Attr:$offset);
1960+
let results = (outs CIR_PointerType:$addr);
1961+
1962+
let assemblyFormat = [{
1963+
($name^)?
1964+
($sym_addr^ `:` type($sym_addr))?
1965+
`,`
1966+
`offset` `=` $offset
1967+
`->` qualified(type($addr)) attr-dict
1968+
}];
1969+
1970+
let hasVerifier = 1;
1971+
}
1972+
19091973
//===----------------------------------------------------------------------===//
19101974
// SetBitfieldOp
19111975
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)