Skip to content

Commit 040f999

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3752)
2 parents 4d7a18a + 1c6a1b3 commit 040f999

File tree

238 files changed

+4190
-2648
lines changed

Some content is hidden

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

238 files changed

+4190
-2648
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 --start-server
68+
SCCACHE_LOG=info SCCACHE_ERROR_LOG=artifacts/sccache.log 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 --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_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 }}\""
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-tools-extra/test/clang-tidy/check_clang_tidy.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import argparse
4646
import os
4747
import pathlib
48+
import platform
4849
import re
4950
import subprocess
5051
import sys
@@ -145,7 +146,12 @@ def __init__(self, args: argparse.Namespace, extra_args: List[str]) -> None:
145146
self.clang_extra_args.append("-resource-dir=%s" % self.resource_dir)
146147

147148
def read_input(self) -> None:
148-
with open(self.input_file_name, "r", encoding="utf-8") as input_file:
149+
# Use a "\\?\" prefix on Windows to handle long file paths transparently:
150+
# https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
151+
file_name = self.input_file_name
152+
if platform.system() == "Windows":
153+
file_name = "\\\\?\\" + os.path.abspath(file_name)
154+
with open(file_name, "r", encoding="utf-8") as input_file:
149155
self.input_text = input_file.read()
150156

151157
def get_prefixes(self) -> None:

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/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
//===----------------------------------------------------------------------===//

clang/include/clang/Driver/Action.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ class Action {
7777
StaticLibJobClass,
7878
BinaryAnalyzeJobClass,
7979
BinaryTranslatorJobClass,
80+
ObjcopyJobClass,
8081

8182
JobClassFirst = PreprocessJobClass,
82-
JobClassLast = BinaryTranslatorJobClass
83+
JobClassLast = ObjcopyJobClass
8384
};
8485

8586
// The offloading kind determines if this action is binded to a particular
@@ -699,6 +700,17 @@ class BinaryTranslatorJobAction : public JobAction {
699700
}
700701
};
701702

703+
class ObjcopyJobAction : public JobAction {
704+
void anchor() override;
705+
706+
public:
707+
ObjcopyJobAction(Action *Input, types::ID Type);
708+
709+
static bool classof(const Action *A) {
710+
return A->getKind() == ObjcopyJobClass;
711+
}
712+
};
713+
702714
} // namespace driver
703715
} // namespace clang
704716

0 commit comments

Comments
 (0)