Skip to content

Commit 0e8964e

Browse files
committed
merge main into amd-staging
2 parents 806baca + a60e8a2 commit 0e8964e

File tree

195 files changed

+27040
-3964
lines changed

Some content is hidden

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

195 files changed

+27040
-3964
lines changed

bolt/test/binary-analysis/AArch64/gs-pacret-autiasp.s

Lines changed: 25 additions & 99 deletions
Large diffs are not rendered by default.

bolt/test/binary-analysis/AArch64/gs-pacret-multi-bb.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ f_crossbb1:
1515
1:
1616
ret
1717
.size f_crossbb1, .-f_crossbb1
18-
// CHECK-LABEL: GS-PACRET: non-protected ret found in function f_crossbb1, basic block .L{{[^,]+}}, at address
18+
// CHECK-LABEL: GS-PACRET: non-protected ret found in function f_crossbb1, basic block {{[^,]+}}, at address
1919
// CHECK-NEXT: The return instruction is {{[0-9a-f]+}}: ret
2020
// CHECK-NEXT: The 2 instructions that write to the return register after any authentication are:
2121
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10
@@ -37,7 +37,7 @@ f_mergebb1:
3737
1:
3838
ret
3939
.size f_mergebb1, .-f_mergebb1
40-
// CHECK-LABEL: GS-PACRET: non-protected ret found in function f_mergebb1, basic block .L{{[^,]+}}, at address
40+
// CHECK-LABEL: GS-PACRET: non-protected ret found in function f_mergebb1, basic block {{[^,]+}}, at address
4141
// CHECK-NEXT: The return instruction is {{[0-9a-f]+}}: ret
4242
// CHECK-NEXT: The 1 instructions that write to the return register after any authentication are:
4343
// CHECK-NEXT: 1. {{[0-9a-f]+}}: ldp x29, x30, [sp], #0x10

clang/docs/analyzer/checkers.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3668,6 +3668,51 @@ Here are some examples of situations that we warn about as they *might* be poten
36683668
RefCountable* uncounted = counted.get(); // warn
36693669
}
36703670
3671+
alpha.webkit.UnretainedLocalVarsChecker
3672+
"""""""""""""""""""""""""""""""""""""""
3673+
The goal of this rule is to make sure that any NS or CF local variable is backed by a RetainPtr with lifetime that is strictly larger than the scope of the unretained local variable. To be on the safe side we require the scope of an unretained variable to be embedded in the scope of Retainptr object that backs it.
3674+
3675+
The rules of when to use and not to use RetainPtr are same as alpha.webkit.UncountedCallArgsChecker for ref-counted objects.
3676+
3677+
These are examples of cases that we consider safe:
3678+
3679+
.. code-block:: cpp
3680+
3681+
void foo1() {
3682+
RetainPtr<NSObject> retained;
3683+
// The scope of unretained is EMBEDDED in the scope of retained.
3684+
{
3685+
NSObject* unretained = retained.get(); // ok
3686+
}
3687+
}
3688+
3689+
void foo2(RetainPtr<NSObject> retained_param) {
3690+
NSObject* unretained = retained_param.get(); // ok
3691+
}
3692+
3693+
void FooClass::foo_method() {
3694+
NSObject* unretained = this; // ok
3695+
}
3696+
3697+
Here are some examples of situations that we warn about as they *might* be potentially unsafe. The logic is that either we're able to guarantee that a local variable is safe or it's considered unsafe.
3698+
3699+
.. code-block:: cpp
3700+
3701+
void foo1() {
3702+
NSObject* unretained = [[NSObject alloc] init]; // warn
3703+
}
3704+
3705+
NSObject* global_unretained;
3706+
void foo2() {
3707+
NSObject* unretained = global_unretained; // warn
3708+
}
3709+
3710+
void foo3() {
3711+
RetainPtr<NSObject> retained;
3712+
// The scope of unretained is not EMBEDDED in the scope of retained.
3713+
NSObject* unretained = retained.get(); // warn
3714+
}
3715+
36713716
Debug Checkers
36723717
---------------
36733718

clang/include/clang/AST/DeclCXX.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,14 +1720,6 @@ class CXXRecordDecl : public RecordDecl {
17201720
/// static analysis, or similar.
17211721
bool hasMemberName(DeclarationName N) const;
17221722

1723-
/// Performs an imprecise lookup of a dependent name in this class.
1724-
///
1725-
/// This function does not follow strict semantic rules and should be used
1726-
/// only when lookup rules can be relaxed, e.g. indexing.
1727-
std::vector<const NamedDecl *>
1728-
lookupDependentName(DeclarationName Name,
1729-
llvm::function_ref<bool(const NamedDecl *ND)> Filter);
1730-
17311723
/// Renders and displays an inheritance diagram
17321724
/// for this C++ class and all of its base classes (transitively) using
17331725
/// GraphViz.

clang/include/clang/Basic/BuiltinsSPIRV.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ def SPIRVLength : Builtin {
1919
let Attributes = [NoThrow, Const];
2020
let Prototype = "void(...)";
2121
}
22+
23+
def SPIRVReflect : Builtin {
24+
let Spellings = ["__builtin_spirv_reflect"];
25+
let Attributes = [NoThrow, Const];
26+
let Prototype = "void(...)";
27+
}

clang/include/clang/Basic/LangOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,8 @@ class LangOptions : public LangOptionsBase {
816816
VisibilityForcedKinds::ForceHidden;
817817
}
818818

819+
bool allowArrayReturnTypes() const { return HLSL; }
820+
819821
/// Remap path prefix according to -fmacro-prefix-path option.
820822
void remapPathPrefix(SmallVectorImpl<char> &Path) const;
821823

clang/include/clang/CIR/Passes.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file exposes the entry points to create compiler passes for ClangIR.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef CLANG_CIR_PASSES_H
14+
#define CLANG_CIR_PASSES_H
15+
16+
#include "mlir/Pass/Pass.h"
17+
18+
#include <memory>
19+
20+
namespace cir {
21+
namespace direct {
22+
/// Create a pass that fully lowers CIR to the LLVMIR dialect.
23+
std::unique_ptr<mlir::Pass> createConvertCIRToLLVMPass();
24+
25+
/// Adds passes that fully lower CIR to the LLVMIR dialect.
26+
void populateCIRToLLVMPasses(mlir::OpPassManager &pm);
27+
28+
} // namespace direct
29+
} // end namespace cir
30+
31+
#endif // CLANG_CIR_PASSES_H

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,4 +1782,8 @@ def UncheckedLocalVarsChecker : Checker<"UncheckedLocalVarsChecker">,
17821782
HelpText<"Check unchecked local variables.">,
17831783
Documentation<HasDocumentation>;
17841784

1785+
def UnretainedLocalVarsChecker : Checker<"UnretainedLocalVarsChecker">,
1786+
HelpText<"Check unretained local variables.">,
1787+
Documentation<HasDocumentation>;
1788+
17851789
} // end alpha.webkit

clang/lib/AST/CXXInheritance.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -411,59 +411,6 @@ bool CXXRecordDecl::hasMemberName(DeclarationName Name) const {
411411
Paths);
412412
}
413413

414-
static bool
415-
findOrdinaryMemberInDependentClasses(const CXXBaseSpecifier *Specifier,
416-
CXXBasePath &Path, DeclarationName Name) {
417-
const TemplateSpecializationType *TST =
418-
Specifier->getType()->getAs<TemplateSpecializationType>();
419-
if (!TST) {
420-
auto *RT = Specifier->getType()->getAs<RecordType>();
421-
if (!RT)
422-
return false;
423-
return findOrdinaryMember(cast<CXXRecordDecl>(RT->getDecl()), Path, Name);
424-
}
425-
TemplateName TN = TST->getTemplateName();
426-
const auto *TD = dyn_cast_or_null<ClassTemplateDecl>(TN.getAsTemplateDecl());
427-
if (!TD)
428-
return false;
429-
CXXRecordDecl *RD = TD->getTemplatedDecl();
430-
if (!RD)
431-
return false;
432-
return findOrdinaryMember(RD, Path, Name);
433-
}
434-
435-
std::vector<const NamedDecl *> CXXRecordDecl::lookupDependentName(
436-
DeclarationName Name,
437-
llvm::function_ref<bool(const NamedDecl *ND)> Filter) {
438-
std::vector<const NamedDecl *> Results;
439-
// Lookup in the class.
440-
bool AnyOrdinaryMembers = false;
441-
for (const NamedDecl *ND : lookup(Name)) {
442-
if (isOrdinaryMember(ND))
443-
AnyOrdinaryMembers = true;
444-
if (Filter(ND))
445-
Results.push_back(ND);
446-
}
447-
if (AnyOrdinaryMembers)
448-
return Results;
449-
450-
// Perform lookup into our base classes.
451-
CXXBasePaths Paths;
452-
Paths.setOrigin(this);
453-
if (!lookupInBases(
454-
[&](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
455-
return findOrdinaryMemberInDependentClasses(Specifier, Path, Name);
456-
},
457-
Paths, /*LookupInDependent=*/true))
458-
return Results;
459-
for (DeclContext::lookup_iterator I = Paths.front().Decls, E = I.end();
460-
I != E; ++I) {
461-
if (isOrdinaryMember(*I) && Filter(*I))
462-
Results.push_back(*I);
463-
}
464-
return Results;
465-
}
466-
467414
void OverridingMethods::add(unsigned OverriddenSubobject,
468415
UniqueVirtualMethod Overriding) {
469416
SmallVectorImpl<UniqueVirtualMethod> &SubobjectOverrides

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,25 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) {
462462
// bug
463463
if (ArrIdx.isNonNegative() && ArrIdx.getLimitedValue() < limit)
464464
return true;
465+
} else if (const auto *BE = dyn_cast<BinaryOperator>(IndexExpr)) {
466+
// For an integer expression `e` and an integer constant `n`, `e & n` and
467+
// `n & e` are bounded by `n`:
468+
if (BE->getOpcode() != BO_And)
469+
return false;
470+
471+
const Expr *LHS = BE->getLHS();
472+
const Expr *RHS = BE->getRHS();
473+
474+
if ((!LHS->isValueDependent() &&
475+
LHS->EvaluateAsInt(EVResult,
476+
Finder->getASTContext())) || // case: `n & e`
477+
(!RHS->isValueDependent() &&
478+
RHS->EvaluateAsInt(EVResult, Finder->getASTContext()))) { // `e & n`
479+
llvm::APSInt result = EVResult.Val.getInt();
480+
if (result.isNonNegative() && result.getLimitedValue() < limit)
481+
return true;
482+
}
483+
return false;
465484
}
466485
return false;
467486
}

0 commit comments

Comments
 (0)