Skip to content

Commit 894877c

Browse files
authored
Merge pull request #1878 from brentdax/merged-into-an-umbrella-corporation
Manually merge apple/stable/20200714 -> swift/main
2 parents 0bd1713 + 9fa69d8 commit 894877c

File tree

84 files changed

+1754
-187
lines changed

Some content is hidden

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

84 files changed

+1754
-187
lines changed

clang/docs/SourceBasedCodeCoverage.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ directory structure will be created. Additionally, the following special
7979

8080
* "%h" expands out to the hostname of the machine running the program.
8181

82+
* "%t" expands out to the value of the ``TMPDIR`` environment variable. On
83+
Darwin, this is typically set to a temporary scratch directory.
84+
8285
* "%Nm" expands out to the instrumented binary's signature. When this pattern
8386
is specified, the runtime creates a pool of N raw profiles which are used for
8487
on-line profile merging. The runtime takes care of selecting a raw profile

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ def ExtraSemi : DiagGroup<"extra-semi", [CXX98CompatExtraSemi,
234234
def GNUFlexibleArrayInitializer : DiagGroup<"gnu-flexible-array-initializer">;
235235
def GNUFlexibleArrayUnionMember : DiagGroup<"gnu-flexible-array-union-member">;
236236
def GNUFoldingConstant : DiagGroup<"gnu-folding-constant">;
237+
def FormatInsufficientArgs : DiagGroup<"format-insufficient-args">;
237238
def FormatExtraArgs : DiagGroup<"format-extra-args">;
238239
def FormatZeroLength : DiagGroup<"format-zero-length">;
239240

@@ -840,7 +841,8 @@ def FormatPedantic : DiagGroup<"format-pedantic">;
840841
def FormatTypeConfusion : DiagGroup<"format-type-confusion">;
841842
def Format : DiagGroup<"format",
842843
[FormatExtraArgs, FormatZeroLength, NonNull,
843-
FormatSecurity, FormatY2K, FormatInvalidSpecifier]>,
844+
FormatSecurity, FormatY2K, FormatInvalidSpecifier,
845+
FormatInsufficientArgs]>,
844846
DiagCategory<"Format String Issue">;
845847
def FormatNonLiteral : DiagGroup<"format-nonliteral">;
846848
def Format2 : DiagGroup<"format=2",

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8945,7 +8945,7 @@ def note_array_declared_here : Note<
89458945
"array %0 declared here">;
89468946

89478947
def warn_printf_insufficient_data_args : Warning<
8948-
"more '%%' conversions than data arguments">, InGroup<Format>;
8948+
"more '%%' conversions than data arguments">, InGroup<FormatInsufficientArgs>;
89498949
def warn_printf_data_arg_not_used : Warning<
89508950
"data argument not used by format string">, InGroup<FormatExtraArgs>;
89518951
def warn_format_invalid_conversion : Warning<

clang/lib/CodeGen/CGCall.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3746,10 +3746,7 @@ void CodeGenFunction::EmitNonNullArgCheck(RValue RV, QualType ArgType,
37463746
}
37473747

37483748
SanitizerScope SanScope(this);
3749-
assert(RV.isScalar());
3750-
llvm::Value *V = RV.getScalarVal();
3751-
llvm::Value *Cond =
3752-
Builder.CreateICmpNE(V, llvm::Constant::getNullValue(V->getType()));
3749+
llvm::Value *Cond = EmitNonNullRValueCheck(RV, ArgType);
37533750
llvm::Constant *StaticData[] = {
37543751
EmitCheckSourceLocation(ArgLoc), EmitCheckSourceLocation(AttrLoc),
37553752
llvm::ConstantInt::get(Int32Ty, ArgNo + 1),

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,13 @@ Address CodeGenFunction::EmitPointerWithAlignment(const Expr *E,
11701170
return Address(EmitScalarExpr(E), Align);
11711171
}
11721172

1173+
llvm::Value *CodeGenFunction::EmitNonNullRValueCheck(RValue RV, QualType T) {
1174+
llvm::Value *V = RV.getScalarVal();
1175+
if (auto MPT = T->getAs<MemberPointerType>())
1176+
return CGM.getCXXABI().EmitMemberPointerIsNotNull(*this, V, MPT);
1177+
return Builder.CreateICmpNE(V, llvm::Constant::getNullValue(V->getType()));
1178+
}
1179+
11731180
RValue CodeGenFunction::GetUndefRValue(QualType Ty) {
11741181
if (Ty->isVoidType())
11751182
return RValue::get(nullptr);

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3563,6 +3563,9 @@ class CodeGenFunction : public CodeGenTypeCache {
35633563
// LValue Expression Emission
35643564
//===--------------------------------------------------------------------===//
35653565

3566+
/// Create a check that a scalar RValue is non-null.
3567+
llvm::Value *EmitNonNullRValueCheck(RValue RV, QualType T);
3568+
35663569
/// GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
35673570
RValue GetUndefRValue(QualType Ty);
35683571

clang/lib/Lex/PPLexerChange.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,12 @@ static void collectAllSubModulesWithUmbrellaHeader(
263263
}
264264

265265
void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
266-
assert(Mod.getUmbrellaHeader() && "Module must use umbrella header");
267-
SourceLocation StartLoc =
268-
SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
269-
if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header, StartLoc))
266+
const Module::Header &UmbrellaHeader = Mod.getUmbrellaHeader();
267+
assert(UmbrellaHeader.Entry && "Module must use umbrella header");
268+
const FileID &File = SourceMgr.translateFile(UmbrellaHeader.Entry);
269+
SourceLocation ExpectedHeadersLoc = SourceMgr.getLocForEndOfFile(File);
270+
if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header,
271+
ExpectedHeadersLoc))
270272
return;
271273

272274
ModuleMap &ModMap = getHeaderSearchInfo().getModuleMap();
@@ -291,7 +293,7 @@ void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
291293
// Find the relative path that would access this header.
292294
SmallString<128> RelativePath;
293295
computeRelativePath(FileMgr, Dir, *Header, RelativePath);
294-
Diag(StartLoc, diag::warn_uncovered_module_header)
296+
Diag(ExpectedHeadersLoc, diag::warn_uncovered_module_header)
295297
<< Mod.getFullModuleName() << RelativePath;
296298
}
297299
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// RUN: %clang_cc1 -x c++ -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=nullability-arg | FileCheck %s -check-prefixes=ITANIUM,ALL
2+
// RUN: %clang_cc1 -x c++ -triple x86_64-pc-windows-msvc -emit-llvm -o - %s -fsanitize=nullability-arg | FileCheck %s -check-prefixes=MSVC,ALL
3+
4+
namespace method_ptr {
5+
6+
struct S0 {
7+
void foo1();
8+
};
9+
10+
void foo1(void (S0::*_Nonnull f)());
11+
12+
// ITANIUM-LABEL: @_ZN10method_ptr5test1Ev(){{.*}} {
13+
// ITANIUM: br i1 icmp ne (i64 ptrtoint (void (%"struct.method_ptr::S0"*)* @_ZN10method_ptr2S04foo1Ev to i64), i64 0), label %[[CONT:.*]], label %[[FAIL:[^,]*]]
14+
// ITANIUM-EMPTY:
15+
// ITANIUM-NEXT: [[FAIL]]:
16+
// ITANIUM-NEXT: call void @__ubsan_handle_nullability_arg
17+
18+
// MSVC-LABEL: @"?test1@method_ptr@@YAXXZ"(){{.*}} {
19+
// MSVC: br i1 true, label %[[CONT:.*]], label %[[FAIL:[^,]*]]
20+
// MSVC-EMPTY:
21+
// MSVC-NEXT: [[FAIL]]:
22+
// MSVC-NEXT: call void @__ubsan_handle_nullability_arg
23+
void test1() {
24+
foo1(&S0::foo1);
25+
}
26+
27+
} // namespace method_ptr
28+
29+
namespace data_ptr {
30+
31+
struct S0 {
32+
int field1;
33+
};
34+
35+
using member_ptr = int S0::*;
36+
37+
void foo1(member_ptr _Nonnull);
38+
39+
// ITANIUM-LABEL: @_ZN8data_ptr5test1ENS_2S0E(
40+
// MSVC-LABEL: @"?test1@data_ptr@@YAXUS0@1@@Z"(
41+
// ALL: [[DATA_PTR_CHECK:%.*]] = icmp ne {{.*}}, -1, !nosanitize
42+
// ALL-NEXT: br i1 [[DATA_PTR_CHECK]], label %[[CONT:.*]], label %[[FAIL:[^,]+]]
43+
// ALL-EMPTY:
44+
// ALL-NEXT: [[FAIL]]:
45+
// ALL-NEXT: call void @__ubsan_handle_nullability_arg
46+
void test1(S0 s) {
47+
int S0::*member = &S0::field1;
48+
foo1(member);
49+
}
50+
51+
} // namespace data_ptr

clang/test/Misc/warning-wall.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CHECK-NEXT: -Wnonnull
1515
CHECK-NEXT: -Wformat-security
1616
CHECK-NEXT: -Wformat-y2k
1717
CHECK-NEXT: -Wformat-invalid-specifier
18+
CHECK-NEXT: -Wformat-insufficient-args
1819
CHECK-NEXT: -Wfor-loop-analysis
1920
CHECK-NEXT: -Wframe-address
2021
CHECK-NEXT: -Wimplicit

clang/test/Modules/incomplete-umbrella.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
#import <Foo/Baz.h>
77
@import Foo.Private;
88

9-
// CHECK: warning: umbrella header for module 'Foo' does not include header 'Bar.h'
10-
// CHECK: warning: umbrella header for module 'Foo.Private' does not include header 'Baz.h'
9+
// CHECK: While building module 'Foo' imported from {{.*[/\]}}incomplete-umbrella.m:4:
10+
// CHECK-NEXT: In file included from <module-includes>:1:
11+
// CHECK-NEXT: {{.*Foo[.]framework[/\]Headers[/\]}}FooPublic.h:2:1: warning: umbrella header for module 'Foo' does not include header 'Bar.h'
12+
// CHECK: While building module 'Foo' imported from {{.*[/\]}}incomplete-umbrella.m:4:
13+
// CHECK-NEXT: In file included from <module-includes>:2:
14+
// CHECK-NEXT: {{.*Foo[.]framework[/\]PrivateHeaders[/\]}}Foo.h:2:1: warning: umbrella header for module 'Foo.Private' does not include header 'Baz.h'
1115
int foo() {
1216
int a = BAR_PUBLIC;
1317
int b = BAZ_PRIVATE;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify=WARNING-ON %s
2+
// RUN: %clang_cc1 -fsyntax-only -Wno-format-insufficient-args -verify=WARNING-OFF %s
3+
4+
5+
int printf(const char * format, ...);
6+
7+
int main(void) {
8+
int patatino = 42;
9+
printf("%i %i", patatino); // WARNING-ON-warning {{more '%' conversions than data arguments}}
10+
// WARNING-OFF-no-diagnostics
11+
}

compiler-rt/lib/profile/InstrProfilingFile.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ typedef struct lprofFilename {
7474
unsigned OwnsFilenamePat;
7575
const char *ProfilePathPrefix;
7676
char PidChars[MAX_PID_SIZE];
77+
char *TmpDir;
7778
char Hostname[COMPILER_RT_MAX_HOSTLEN];
7879
unsigned NumPids;
7980
unsigned NumHosts;
@@ -90,8 +91,8 @@ typedef struct lprofFilename {
9091
ProfileNameSpecifier PNS;
9192
} lprofFilename;
9293

93-
static lprofFilename lprofCurFilename = {0, 0, 0, {0}, {0}, 0,
94-
0, 0, {0}, 0, PNS_unknown};
94+
static lprofFilename lprofCurFilename = {0, 0, 0, {0}, NULL, {0},
95+
0, 0, 0, {0}, 0, PNS_unknown};
9596

9697
static int ProfileMergeRequested = 0;
9798
static int isProfileMergeRequested() { return ProfileMergeRequested; }
@@ -773,6 +774,14 @@ static int parseFilenamePattern(const char *FilenamePat,
773774
FilenamePat);
774775
return -1;
775776
}
777+
} else if (FilenamePat[I] == 't') {
778+
lprofCurFilename.TmpDir = getenv("TMPDIR");
779+
if (!lprofCurFilename.TmpDir) {
780+
PROF_WARN("Unable to get the TMPDIR environment variable, referenced "
781+
"in %s. Using the default path.",
782+
FilenamePat);
783+
return -1;
784+
}
776785
} else if (FilenamePat[I] == 'c') {
777786
if (__llvm_profile_is_continuous_mode_enabled()) {
778787
PROF_WARN("%%c specifier can only be specified once in %s.\n",
@@ -874,12 +883,14 @@ static int getCurFilenameLength() {
874883
return 0;
875884

876885
if (!(lprofCurFilename.NumPids || lprofCurFilename.NumHosts ||
877-
lprofCurFilename.MergePoolSize || lprofCurFilename.NumExitSignals))
886+
lprofCurFilename.TmpDir || lprofCurFilename.MergePoolSize ||
887+
lprofCurFilename.NumExitSignals))
878888
return strlen(lprofCurFilename.FilenamePat);
879889

880890
Len = strlen(lprofCurFilename.FilenamePat) +
881891
lprofCurFilename.NumPids * (strlen(lprofCurFilename.PidChars) - 2) +
882-
lprofCurFilename.NumHosts * (strlen(lprofCurFilename.Hostname) - 2);
892+
lprofCurFilename.NumHosts * (strlen(lprofCurFilename.Hostname) - 2) +
893+
(lprofCurFilename.TmpDir ? (strlen(lprofCurFilename.TmpDir) - 1) : 0);
883894
if (lprofCurFilename.MergePoolSize)
884895
Len += SIGLEN;
885896
for (I = 0; I < lprofCurFilename.NumExitSignals; ++I) {
@@ -896,14 +907,14 @@ static int getCurFilenameLength() {
896907
* current filename pattern string is directly returned, unless ForceUseBuf
897908
* is enabled. */
898909
static const char *getCurFilename(char *FilenameBuf, int ForceUseBuf) {
899-
int I, J, PidLength, HostNameLength, FilenamePatLength;
910+
int I, J, PidLength, HostNameLength, TmpDirLength, FilenamePatLength;
900911
const char *FilenamePat = lprofCurFilename.FilenamePat;
901912

902913
if (!lprofCurFilename.FilenamePat || !lprofCurFilename.FilenamePat[0])
903914
return 0;
904915

905916
if (!(lprofCurFilename.NumPids || lprofCurFilename.NumHosts ||
906-
lprofCurFilename.MergePoolSize ||
917+
lprofCurFilename.TmpDir || lprofCurFilename.MergePoolSize ||
907918
__llvm_profile_is_continuous_mode_enabled() ||
908919
lprofCurFilename.NumExitSignals)) {
909920
if (!ForceUseBuf)
@@ -917,6 +928,7 @@ static const char *getCurFilename(char *FilenameBuf, int ForceUseBuf) {
917928

918929
PidLength = strlen(lprofCurFilename.PidChars);
919930
HostNameLength = strlen(lprofCurFilename.Hostname);
931+
TmpDirLength = lprofCurFilename.TmpDir ? strlen(lprofCurFilename.TmpDir) : 0;
920932
/* Construct the new filename. */
921933
for (I = 0, J = 0; FilenamePat[I]; ++I)
922934
if (FilenamePat[I] == '%') {
@@ -929,6 +941,10 @@ static const char *getCurFilename(char *FilenameBuf, int ForceUseBuf) {
929941
} else if (containsExitOnSignalSpecifier(FilenamePat, I)) {
930942
while (FilenamePat[I] != 'x')
931943
++I;
944+
} else if (FilenamePat[I] == 't') {
945+
memcpy(FilenameBuf + J, lprofCurFilename.TmpDir, TmpDirLength);
946+
FilenameBuf[J + TmpDirLength] = DIR_SEPARATOR;
947+
J += TmpDirLength + 1;
932948
} else {
933949
if (!getMergePoolSize(FilenamePat, &I))
934950
continue;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: cd %t
4+
// RUN: %clang_profgen -o %t/binary %s
5+
//
6+
// Check that a dir separator is appended after %t is subsituted.
7+
// RUN: env TMPDIR="%t" LLVM_PROFILE_FILE="%%traw1.profraw" %run ./binary
8+
// RUN: llvm-profdata show ./raw1.profraw | FileCheck %s -check-prefix TMPDIR
9+
//
10+
// Check that substitution works even if a redundant dir separator is added.
11+
// RUN: env TMPDIR="%t" LLVM_PROFILE_FILE="%%t/raw2.profraw" %run ./binary
12+
// RUN: llvm-profdata show ./raw2.profraw | FileCheck %s -check-prefix TMPDIR
13+
//
14+
// Check that we fall back to the default path if TMPDIR is missing.
15+
// RUN: env -u TMPDIR LLVM_PROFILE_FILE="%%t/raw3.profraw" %run ./binary 2>&1 | FileCheck %s -check-prefix MISSING
16+
// RUN: llvm-profdata show ./default.profraw | FileCheck %s -check-prefix TMPDIR
17+
18+
// TMPDIR: Maximum function count: 1
19+
20+
// MISSING: Unable to get the TMPDIR environment variable, referenced in {{.*}}raw3.profraw. Using the default path.
21+
22+
int main() { return 0; }

lldb/bindings/interface/SBThreadPlan.i

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ public:
9292
bool
9393
IsPlanStale();
9494

95+
%feature("docstring", "Return whether this plan will ask to stop other threads when it runs.") GetStopOthers;
96+
bool
97+
GetStopOthers();
98+
99+
%feature("docstring", "Set whether this plan will ask to stop other threads when it runs.") GetStopOthers;
100+
void
101+
SetStopOthers(bool stop_others);
102+
95103
SBThreadPlan
96104
QueueThreadPlanForStepOverRange (SBAddress &start_address,
97105
lldb::addr_t range_size);

lldb/bindings/interface/SBTypeEnumMember.i

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,18 @@ protected:
7171
SBTypeEnumMember (const lldb::TypeEnumMemberImplSP &);
7272
};
7373

74-
%feature(
75-
"docstring",
76-
"Represents a list of SBTypeEnumMembers."
77-
) SBTypeEnumMemberList;
74+
%feature("docstring",
75+
"Represents a list of SBTypeEnumMembers.
76+
SBTypeEnumMemberList supports SBTypeEnumMember iteration.
77+
It also supports [] access either by index, or by enum
78+
element name by doing:
79+
80+
myType = target.FindFirstType('MyEnumWithElementA')
81+
members = myType.GetEnumMembers()
82+
first_elem = members[0]
83+
elem_A = members['A']
84+
85+
") SBTypeEnumMemberList;
7886

7987
class SBTypeEnumMemberList
8088
{
@@ -99,6 +107,29 @@ public:
99107
uint32_t
100108
GetSize();
101109

110+
#ifdef SWIGPYTHON
111+
%pythoncode %{
112+
def __iter__(self):
113+
'''Iterate over all members in a lldb.SBTypeEnumMemberList object.'''
114+
return lldb_iter(self, 'GetSize', 'GetTypeEnumMemberAtIndex')
115+
116+
def __len__(self):
117+
'''Return the number of members in a lldb.SBTypeEnumMemberList object.'''
118+
return self.GetSize()
119+
120+
def __getitem__(self, key):
121+
num_elements = self.GetSize()
122+
if type(key) is int:
123+
if key < num_elements:
124+
return self.GetTypeEnumMemberAtIndex(key)
125+
elif type(key) is str:
126+
for idx in range(num_elements):
127+
item = self.GetTypeEnumMemberAtIndex(idx)
128+
if item.name == key:
129+
return item
130+
return None
131+
%}
132+
#endif
102133

103134
private:
104135
std::unique_ptr<lldb_private::TypeEnumMemberListImpl> m_opaque_ap;

lldb/include/lldb/API/SBThreadPlan.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ class LLDB_API SBThreadPlan {
7777

7878
bool IsValid();
7979

80+
bool GetStopOthers();
81+
82+
void SetStopOthers(bool stop_others);
83+
8084
// This section allows an SBThreadPlan to push another of the common types of
8185
// plans...
8286
SBThreadPlan QueueThreadPlanForStepOverRange(SBAddress &start_address,

lldb/include/lldb/Interpreter/OptionValue.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class OptionValue {
3131
eTypeChar,
3232
eTypeDictionary,
3333
eTypeEnum,
34+
eTypeFileLineColumn,
3435
eTypeFileSpec,
3536
eTypeFileSpecList,
3637
eTypeFormat,
@@ -135,6 +136,8 @@ class OptionValue {
135136
return eTypeDictionary;
136137
case 1u << eTypeEnum:
137138
return eTypeEnum;
139+
case 1u << eTypeFileLineColumn:
140+
return eTypeFileLineColumn;
138141
case 1u << eTypeFileSpec:
139142
return eTypeFileSpec;
140143
case 1u << eTypeFileSpecList:

0 commit comments

Comments
 (0)