Skip to content

Commit 217e406

Browse files
committed
[AutoBump] Merge with 67c3f2b (Jan 18)
2 parents 52e1d52 + 67c3f2b commit 217e406

24 files changed

+176
-208
lines changed

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class UnusedUsingDeclsCheck : public ClangTidyCheck {
5151
std::vector<UsingDeclContext> Contexts;
5252
llvm::SmallPtrSet<const Decl *, 32> UsingTargetDeclsCache;
5353

54-
StringRef RawStringHeaderFileExtensions;
5554
FileExtensionsSet HeaderFileExtensions;
5655
};
5756

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 56 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6194,60 +6194,67 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
61946194
return revisit(VD);
61956195
}
61966196

6197-
if (D != InitializingDecl) {
6198-
// Try to lazily visit (or emit dummy pointers for) declarations
6199-
// we haven't seen yet.
6200-
if (Ctx.getLangOpts().CPlusPlus) {
6201-
if (const auto *VD = dyn_cast<VarDecl>(D)) {
6202-
const auto typeShouldBeVisited = [&](QualType T) -> bool {
6203-
if (T.isConstant(Ctx.getASTContext()))
6204-
return true;
6205-
return T->isReferenceType();
6206-
};
6197+
// Avoid infinite recursion.
6198+
if (D == InitializingDecl)
6199+
return this->emitDummyPtr(D, E);
6200+
6201+
// Try to lazily visit (or emit dummy pointers for) declarations
6202+
// we haven't seen yet.
6203+
// For C.
6204+
if (!Ctx.getLangOpts().CPlusPlus) {
6205+
if (const auto *VD = dyn_cast<VarDecl>(D);
6206+
VD && VD->getAnyInitializer() &&
6207+
VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak())
6208+
return revisit(VD);
6209+
return this->emitDummyPtr(D, E);
6210+
}
62076211

6208-
// DecompositionDecls are just proxies for us.
6209-
if (isa<DecompositionDecl>(VD))
6210-
return revisit(VD);
6211-
6212-
if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
6213-
typeShouldBeVisited(VD->getType())) {
6214-
if (const Expr *Init = VD->getAnyInitializer();
6215-
Init && !Init->isValueDependent()) {
6216-
// Whether or not the evaluation is successul doesn't really matter
6217-
// here -- we will create a global variable in any case, and that
6218-
// will have the state of initializer evaluation attached.
6219-
APValue V;
6220-
SmallVector<PartialDiagnosticAt> Notes;
6221-
(void)Init->EvaluateAsInitializer(V, Ctx.getASTContext(), VD, Notes,
6222-
true);
6223-
return this->visitDeclRef(D, E);
6224-
}
6225-
return revisit(VD);
6226-
}
6212+
// ... and C++.
6213+
const auto *VD = dyn_cast<VarDecl>(D);
6214+
if (!VD)
6215+
return this->emitDummyPtr(D, E);
62276216

6228-
// FIXME: The evaluateValue() check here is a little ridiculous, since
6229-
// it will ultimately call into Context::evaluateAsInitializer(). In
6230-
// other words, we're evaluating the initializer, just to know if we can
6231-
// evaluate the initializer.
6232-
if (VD->isLocalVarDecl() && typeShouldBeVisited(VD->getType()) &&
6233-
VD->getInit() && !VD->getInit()->isValueDependent()) {
6217+
const auto typeShouldBeVisited = [&](QualType T) -> bool {
6218+
if (T.isConstant(Ctx.getASTContext()))
6219+
return true;
6220+
return T->isReferenceType();
6221+
};
62346222

6235-
if (VD->evaluateValue())
6236-
return revisit(VD);
6223+
// DecompositionDecls are just proxies for us.
6224+
if (isa<DecompositionDecl>(VD))
6225+
return revisit(VD);
6226+
6227+
if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
6228+
typeShouldBeVisited(VD->getType())) {
6229+
if (const Expr *Init = VD->getAnyInitializer();
6230+
Init && !Init->isValueDependent()) {
6231+
// Whether or not the evaluation is successul doesn't really matter
6232+
// here -- we will create a global variable in any case, and that
6233+
// will have the state of initializer evaluation attached.
6234+
APValue V;
6235+
SmallVector<PartialDiagnosticAt> Notes;
6236+
(void)Init->EvaluateAsInitializer(V, Ctx.getASTContext(), VD, Notes,
6237+
true);
6238+
return this->visitDeclRef(D, E);
6239+
}
6240+
return revisit(VD);
6241+
}
6242+
6243+
// FIXME: The evaluateValue() check here is a little ridiculous, since
6244+
// it will ultimately call into Context::evaluateAsInitializer(). In
6245+
// other words, we're evaluating the initializer, just to know if we can
6246+
// evaluate the initializer.
6247+
if (VD->isLocalVarDecl() && typeShouldBeVisited(VD->getType()) &&
6248+
VD->getInit() && !VD->getInit()->isValueDependent()) {
6249+
6250+
if (VD->evaluateValue())
6251+
return revisit(VD);
62376252

6238-
if (!D->getType()->isReferenceType())
6239-
return this->emitDummyPtr(D, E);
6253+
if (!D->getType()->isReferenceType())
6254+
return this->emitDummyPtr(D, E);
62406255

6241-
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
6242-
/*InitializerFailed=*/true, E);
6243-
}
6244-
}
6245-
} else {
6246-
if (const auto *VD = dyn_cast<VarDecl>(D);
6247-
VD && VD->getAnyInitializer() &&
6248-
VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak())
6249-
return revisit(VD);
6250-
}
6256+
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
6257+
/*InitializerFailed=*/true, E);
62516258
}
62526259

62536260
return this->emitDummyPtr(D, E);

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,29 +2016,20 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
20162016
// First element is always return type. For 'void' functions it is NULL.
20172017
Elts.push_back(Args[0]);
20182018

2019-
const bool HasExplicitObjectParameter = ThisPtr.isNull();
2020-
2021-
// "this" pointer is always first argument. For explicit "this"
2022-
// parameters, it will already be in Args[1].
2023-
if (!HasExplicitObjectParameter) {
2019+
// "this" pointer is always first argument.
2020+
// ThisPtr may be null if the member function has an explicit 'this'
2021+
// parameter.
2022+
if (!ThisPtr.isNull()) {
20242023
llvm::DIType *ThisPtrType = getOrCreateType(ThisPtr, Unit);
20252024
TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
2026-
ThisPtrType =
2027-
DBuilder.createObjectPointerType(ThisPtrType, /*Implicit=*/true);
2025+
ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
20282026
Elts.push_back(ThisPtrType);
20292027
}
20302028

20312029
// Copy rest of the arguments.
20322030
for (unsigned i = 1, e = Args.size(); i != e; ++i)
20332031
Elts.push_back(Args[i]);
20342032

2035-
// Attach FlagObjectPointer to the explicit "this" parameter.
2036-
if (HasExplicitObjectParameter) {
2037-
assert(Elts.size() >= 2 && Args.size() >= 2 &&
2038-
"Expected at least return type and object parameter.");
2039-
Elts[1] = DBuilder.createObjectPointerType(Args[1], /*Implicit=*/false);
2040-
}
2041-
20422033
llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
20432034

20442035
return DBuilder.createSubroutineType(EltTypeArray, OriginalFunc->getFlags(),
@@ -5127,7 +5118,7 @@ llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
51275118
llvm::DIType *CachedTy = getTypeOrNull(QualTy);
51285119
if (CachedTy)
51295120
Ty = CachedTy;
5130-
return DBuilder.createObjectPointerType(Ty, /*Implicit=*/true);
5121+
return DBuilder.createObjectPointerType(Ty);
51315122
}
51325123

51335124
void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(

clang/test/CodeGenCXX/debug-info-object-pointer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
66
// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer
77
//
8+
// // FIXME: DIFlagObjectPointer not attached to the explicit object
9+
// // argument in the subprogram declaration.
810
// CHECK: !DISubprogram(name: "explicit_this",
911
// flags: DIFlagPrototyped
10-
//
11-
// CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type
12-
// CHECK-SAME: flags: DIFlagObjectPointer)
12+
// CHECK-NOT: DIFlagObjectPointer
13+
// CHECK-NOT: DIFlagArtificial
1314
//
1415
// CHECK: !DILocalVariable(name: "this", arg: 1
1516
// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer

compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,17 @@ INTERCEPTOR(int, getnameinfo, const struct sockaddr *sa, socklen_t salen,
829829
return REAL(getnameinfo)(sa, salen, host, hostlen, serv, servlen, flags);
830830
}
831831

832+
#if SANITIZER_INTERCEPT_GETSOCKNAME
833+
INTERCEPTOR(int, getsockname, int socket, struct sockaddr *sa,
834+
socklen_t *salen) {
835+
__rtsan_notify_intercepted_call("getsockname");
836+
return REAL(getsockname)(socket, sa, salen);
837+
}
838+
#define RTSAN_MAYBE_INTERCEPT_GETSOCKNAME INTERCEPT_FUNCTION(getsockname)
839+
#else
840+
#define RTSAN_MAYBE_INTERCEPT_GETSOCKNAME
841+
#endif
842+
832843
INTERCEPTOR(int, bind, int socket, const struct sockaddr *address,
833844
socklen_t address_len) {
834845
__rtsan_notify_intercepted_call("bind");
@@ -1189,6 +1200,7 @@ void __rtsan::InitializeInterceptors() {
11891200
INTERCEPT_FUNCTION(shutdown);
11901201
INTERCEPT_FUNCTION(socket);
11911202
RTSAN_MAYBE_INTERCEPT_ACCEPT4;
1203+
RTSAN_MAYBE_INTERCEPT_GETSOCKNAME;
11921204

11931205
RTSAN_MAYBE_INTERCEPT_SELECT;
11941206
INTERCEPT_FUNCTION(pselect);

compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,16 @@ TEST(TestRtsanInterceptors, ShutdownOnASocketDiesWhenRealtime) {
11531153
ExpectNonRealtimeSurvival(Func);
11541154
}
11551155

1156+
#if SANITIZER_INTERCEPT_GETSOCKNAME
1157+
TEST(TestRtsanInterceptors, GetsocknameOnASocketDiesWhenRealtime) {
1158+
sockaddr addr{};
1159+
socklen_t len{};
1160+
auto Func = [&]() { getsockname(0, &addr, &len); };
1161+
ExpectRealtimeDeath(Func, "getsockname");
1162+
ExpectNonRealtimeSurvival(Func);
1163+
}
1164+
#endif
1165+
11561166
/*
11571167
I/O Multiplexing
11581168
*/

llvm/include/llvm-c/DebugInfo.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -870,16 +870,13 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
870870
LLVMMetadataRef Ty);
871871

872872
/**
873-
* Create a uniqued DIType* clone with FlagObjectPointer. If \c Implicit
874-
* is true, then also set FlagArtificial.
873+
* Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
875874
* \param Builder The DIBuilder.
876875
* \param Type The underlying type to which this pointer points.
877-
* \param Implicit Indicates whether this pointer was implicitly generated
878-
* (i.e., not spelled out in source).
879876
*/
880-
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
881-
LLVMMetadataRef Type,
882-
LLVMBool Implicit);
877+
LLVMMetadataRef
878+
LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
879+
LLVMMetadataRef Type);
883880

884881
/**
885882
* Create debugging information entry for a qualified

llvm/include/llvm/IR/DIBuilder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,9 @@ namespace llvm {
662662
/// Create a uniqued clone of \p Ty with FlagArtificial set.
663663
static DIType *createArtificialType(DIType *Ty);
664664

665-
/// Create a uniqued clone of \p Ty with FlagObjectPointer set.
666-
/// If \p Implicit is true, also set FlagArtificial.
667-
static DIType *createObjectPointerType(DIType *Ty, bool Implicit);
665+
/// Create a uniqued clone of \p Ty with FlagObjectPointer and
666+
/// FlagArtificial set.
667+
static DIType *createObjectPointerType(DIType *Ty);
668668

669669
/// Create a permanent forward-declared type.
670670
DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,

llvm/lib/IR/DIBuilder.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,15 +644,11 @@ DIType *DIBuilder::createArtificialType(DIType *Ty) {
644644
return createTypeWithFlags(Ty, DINode::FlagArtificial);
645645
}
646646

647-
DIType *DIBuilder::createObjectPointerType(DIType *Ty, bool Implicit) {
647+
DIType *DIBuilder::createObjectPointerType(DIType *Ty) {
648648
// FIXME: Restrict this to the nodes where it's valid.
649649
if (Ty->isObjectPointer())
650650
return Ty;
651-
DINode::DIFlags Flags = DINode::FlagObjectPointer;
652-
653-
if (Implicit)
654-
Flags |= DINode::FlagArtificial;
655-
651+
DINode::DIFlags Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
656652
return createTypeWithFlags(Ty, Flags);
657653
}
658654

llvm/lib/IR/DebugInfo.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,11 +1432,10 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
14321432
PropertyAttributes, unwrapDI<DIType>(Ty)));
14331433
}
14341434

1435-
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
1436-
LLVMMetadataRef Type,
1437-
LLVMBool Implicit) {
1438-
return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type),
1439-
Implicit));
1435+
LLVMMetadataRef
1436+
LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
1437+
LLVMMetadataRef Type) {
1438+
return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type)));
14401439
}
14411440

14421441
LLVMMetadataRef

0 commit comments

Comments
 (0)