Skip to content

Commit c2e245c

Browse files
authored
Merge branch 'main' into dag-always-push-freeze
2 parents ff1c256 + 72f87d2 commit c2e245c

File tree

19 files changed

+204
-47
lines changed

19 files changed

+204
-47
lines changed

clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4363,6 +4363,36 @@ TEST(CompletionTest, PreambleFromDifferentTarget) {
43634363
EXPECT_THAT(Result.Completions, Not(testing::IsEmpty()));
43644364
EXPECT_THAT(Signatures.signatures, Not(testing::IsEmpty()));
43654365
}
4366+
4367+
TEST(CompletionTest, SkipExplicitObjectParameter) {
4368+
Annotations Code(R"cpp(
4369+
struct A {
4370+
void foo(this auto&& self, int arg);
4371+
};
4372+
4373+
int main() {
4374+
A a {};
4375+
a.^
4376+
}
4377+
)cpp");
4378+
4379+
auto TU = TestTU::withCode(Code.code());
4380+
TU.ExtraArgs = {"-std=c++23"};
4381+
4382+
auto Preamble = TU.preamble();
4383+
ASSERT_TRUE(Preamble);
4384+
4385+
CodeCompleteOptions Opts{};
4386+
4387+
MockFS FS;
4388+
auto Inputs = TU.inputs(FS);
4389+
auto Result = codeComplete(testPath(TU.Filename), Code.point(),
4390+
Preamble.get(), Inputs, Opts);
4391+
4392+
EXPECT_THAT(Result.Completions,
4393+
ElementsAre(AllOf(named("foo"), signature("(int arg)"),
4394+
snippetSuffix("(${1:int arg})"))));
4395+
}
43664396
} // namespace
43674397
} // namespace clangd
43684398
} // namespace clang

clang/lib/AST/ByteCode/Interp.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,20 +1332,6 @@ bool GE(InterpState &S, CodePtr OpPC) {
13321332
});
13331333
}
13341334

1335-
//===----------------------------------------------------------------------===//
1336-
// InRange
1337-
//===----------------------------------------------------------------------===//
1338-
1339-
template <PrimType Name, class T = typename PrimConv<Name>::T>
1340-
bool InRange(InterpState &S, CodePtr OpPC) {
1341-
const T RHS = S.Stk.pop<T>();
1342-
const T LHS = S.Stk.pop<T>();
1343-
const T Value = S.Stk.pop<T>();
1344-
1345-
S.Stk.push<bool>(LHS <= Value && Value <= RHS);
1346-
return true;
1347-
}
1348-
13491335
//===----------------------------------------------------------------------===//
13501336
// Dup, Pop, Test
13511337
//===----------------------------------------------------------------------===//

clang/lib/Sema/SemaCodeComplete.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3260,6 +3260,13 @@ static void AddFunctionParameterChunks(Preprocessor &PP,
32603260
break;
32613261
}
32623262

3263+
// C++23 introduces an explicit object parameter, a.k.a. "deducing this"
3264+
// Skip it for autocomplete and treat the next parameter as the first
3265+
// parameter
3266+
if (FirstParameter && Param->isExplicitObjectParameter()) {
3267+
continue;
3268+
}
3269+
32633270
if (FirstParameter)
32643271
FirstParameter = false;
32653272
else

clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefCallArgsChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class RawPtrRefCallArgsChecker
294294
if (name == "adoptRef" || name == "getPtr" || name == "WeakPtr" ||
295295
name == "is" || name == "equal" || name == "hash" || name == "isType" ||
296296
// FIXME: Most/all of these should be implemented via attributes.
297-
name == "equalIgnoringASCIICase" ||
297+
name == "CFEqual" || name == "equalIgnoringASCIICase" ||
298298
name == "equalIgnoringASCIICaseCommon" ||
299299
name == "equalIgnoringNullity" || name == "toString")
300300
return true;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
2+
// expected-no-diagnostics
3+
4+
#include "objc-mock-types.h"
5+
6+
CGImageRef provideImage();
7+
8+
Boolean cfe(CFTypeRef obj)
9+
{
10+
return CFEqual(obj, provideImage());
11+
}
12+

clang/test/Analysis/Checkers/WebKit/objc-mock-types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ CFDictionaryRef CFDictionaryCreateCopy(CFAllocatorRef allocator, CFDictionaryRef
4545
CFDictionaryRef CFDictionaryCreateMutableCopy(CFAllocatorRef allocator, CFIndex capacity, CFDictionaryRef theDict);
4646
CFIndex CFDictionaryGetCount(CFDictionaryRef theDict);
4747
Boolean CFDictionaryContainsKey(CFDictionaryRef theDict, const void *key);
48+
Boolean CFEqual(CFTypeRef, CFTypeRef);
4849
Boolean CFDictionaryContainsValue(CFDictionaryRef theDict, const void *value);
4950
const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key);
5051
void CFDictionaryAddValue(CFMutableDictionaryRef theDict, const void *key, const void *value);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
struct A {
2+
void foo(this A self, int arg);
3+
};
4+
5+
int main() {
6+
A a {};
7+
a.
8+
}
9+
// RUN: %clang_cc1 -cc1 -fsyntax-only -code-completion-at=%s:%(line-2):5 -std=c++23 %s | FileCheck %s
10+
// CHECK: COMPLETION: A : A::
11+
// CHECK-NEXT: COMPLETION: foo : [#void#]foo(<#int arg#>)
12+
// CHECK-NEXT: COMPLETION: operator= : [#A &#]operator=(<#const A &#>)
13+
// CHECK-NEXT: COMPLETION: operator= : [#A &#]operator=(<#A &&#>)
14+
// CHECK-NEXT: COMPLETION: ~A : [#void#]~A()

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5640,12 +5640,8 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
56405640
// Ensure that the element index is in bounds.
56415641
EVT VecVT = Op.getOperand(0).getValueType();
56425642
SDValue Idx = Op.getOperand(Opcode == ISD::INSERT_VECTOR_ELT ? 2 : 1);
5643-
if (isGuaranteedNotToBeUndefOrPoison(Idx, DemandedElts, PoisonOnly,
5644-
Depth + 1)) {
5645-
KnownBits KnownIdx = computeKnownBits(Idx, Depth + 1);
5646-
return KnownIdx.getMaxValue().uge(VecVT.getVectorMinNumElements());
5647-
}
5648-
return true;
5643+
KnownBits KnownIdx = computeKnownBits(Idx, Depth + 1);
5644+
return KnownIdx.getMaxValue().uge(VecVT.getVectorMinNumElements());
56495645
}
56505646

56515647
case ISD::VECTOR_SHUFFLE: {

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ static cl::opt<int>
102102
MaxStoresPerMemsetOptSizeCL("max-store-memset-Os", cl::Hidden, cl::init(4),
103103
cl::desc("Max #stores to inline memset"));
104104

105+
static cl::opt<bool>
106+
ConstantLoadsToImm("constant-loads-to-imm", cl::Hidden, cl::init(true),
107+
cl::desc("Convert constant loads to immediate values."));
108+
105109
static cl::opt<bool> AlignLoads("hexagon-align-loads",
106110
cl::Hidden, cl::init(false),
107111
cl::desc("Rewrite unaligned loads as a pair of aligned loads"));
@@ -3607,6 +3611,18 @@ bool HexagonTargetLowering::isFPImmLegal(const APFloat &Imm, EVT VT,
36073611
return true;
36083612
}
36093613

3614+
/// Returns true if it is beneficial to convert a load of a constant
3615+
/// to just the constant itself.
3616+
bool HexagonTargetLowering::shouldConvertConstantLoadToIntImm(const APInt &Imm,
3617+
Type *Ty) const {
3618+
if (!ConstantLoadsToImm)
3619+
return false;
3620+
3621+
assert(Ty->isIntegerTy());
3622+
unsigned BitSize = Ty->getPrimitiveSizeInBits();
3623+
return (BitSize > 0 && BitSize <= 64);
3624+
}
3625+
36103626
/// isLegalAddressingMode - Return true if the addressing mode represented by
36113627
/// AM is legal for this target, for a load/store of the specified type.
36123628
bool HexagonTargetLowering::isLegalAddressingMode(const DataLayout &DL,

llvm/lib/Target/Hexagon/HexagonISelLowering.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ class HexagonTargetLowering : public TargetLowering {
342342
SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG)
343343
const override;
344344

345+
/// Returns true if it is beneficial to convert a load of a constant
346+
/// to just the constant itself.
347+
bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
348+
Type *Ty) const override;
349+
345350
bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy, EVT NewVT,
346351
std::optional<unsigned> ByteOffset) const override;
347352

0 commit comments

Comments
 (0)