Skip to content

Commit cb0125f

Browse files
author
git apple-llvm automerger
committed
Merge commit '1183af5e91d8' from apple/stable/20190619 into swift/master
2 parents 021a2bc + 1183af5 commit cb0125f

File tree

5 files changed

+83
-15
lines changed

5 files changed

+83
-15
lines changed

clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,14 +1418,19 @@ FindLastStoreBRVisitor::VisitNode(const ExplodedNode *Succ,
14181418
if (Optional<CallEnter> CE = Succ->getLocationAs<CallEnter>()) {
14191419
if (const auto *VR = dyn_cast<VarRegion>(R)) {
14201420

1421-
const auto *Param = cast<ParmVarDecl>(VR->getDecl());
1421+
if (const auto *Param = dyn_cast<ParmVarDecl>(VR->getDecl())) {
1422+
ProgramStateManager &StateMgr = BRC.getStateManager();
1423+
CallEventManager &CallMgr = StateMgr.getCallEventManager();
14221424

1423-
ProgramStateManager &StateMgr = BRC.getStateManager();
1424-
CallEventManager &CallMgr = StateMgr.getCallEventManager();
1425-
1426-
CallEventRef<> Call = CallMgr.getCaller(CE->getCalleeContext(),
1427-
Succ->getState());
1428-
InitE = Call->getArgExpr(Param->getFunctionScopeIndex());
1425+
CallEventRef<> Call = CallMgr.getCaller(CE->getCalleeContext(),
1426+
Succ->getState());
1427+
InitE = Call->getArgExpr(Param->getFunctionScopeIndex());
1428+
} else {
1429+
// Handle Objective-C 'self'.
1430+
assert(isa<ImplicitParamDecl>(VR->getDecl()));
1431+
InitE = cast<ObjCMessageExpr>(CE->getCalleeContext()->getCallSite())
1432+
->getInstanceReceiver()->IgnoreParenCasts();
1433+
}
14291434
IsParam = true;
14301435
}
14311436
}
@@ -2029,8 +2034,6 @@ bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode,
20292034

20302035
// Is it a symbolic value?
20312036
if (auto L = V.getAs<loc::MemRegionVal>()) {
2032-
report.addVisitor(llvm::make_unique<UndefOrNullArgVisitor>(L->getRegion()));
2033-
20342037
// FIXME: this is a hack for fixing a later crash when attempting to
20352038
// dereference a void* pointer.
20362039
// We should not try to dereference pointers at all when we don't care
@@ -2051,10 +2054,14 @@ bool bugreporter::trackExpressionValue(const ExplodedNode *InputNode,
20512054
else if (CanDereference)
20522055
RVal = LVState->getSVal(L->getRegion());
20532056

2054-
if (CanDereference)
2057+
if (CanDereference) {
2058+
report.addVisitor(
2059+
std::make_unique<UndefOrNullArgVisitor>(L->getRegion()));
2060+
20552061
if (auto KV = RVal.getAs<KnownSVal>())
20562062
report.addVisitor(llvm::make_unique<FindLastStoreBRVisitor>(
20572063
*KV, L->getRegion(), EnableNullFPSuppression, TKind, SFC));
2064+
}
20582065

20592066
const MemRegion *RegionRVal = RVal.getAsRegion();
20602067
if (RegionRVal && isa<SymbolicRegion>(RegionRVal)) {

clang/test/Analysis/novoidtypecrash.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
// RUN: %clang_analyze_cc1 -analyzer-checker=core %s
2+
x;
3+
y(void **z) { // no-crash
4+
*z = x;
5+
int *w;
6+
y(&w);
7+
*w;
8+
}
9+
210
a;
3-
b(void **c) { // no-crash
4-
*c = a;
5-
int *d;
6-
b(&d);
7-
*d;
11+
b(*c) {}
12+
e(*c) {
13+
void *d = f();
14+
b(d);
15+
*c = d;
16+
}
17+
void *g() {
18+
e(&a);
19+
return a;
20+
}
21+
j() {
22+
int h;
23+
char i = g();
24+
if (i)
25+
for (; h;)
26+
;
827
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,nullability -verify %s
2+
3+
// expected-no-diagnostics
4+
5+
@class C;
6+
7+
#pragma clang assume_nonnull begin
8+
@interface I
9+
- foo:(C *)c;
10+
@end
11+
#pragma clang assume_nonnull end
12+
13+
@interface J
14+
@property C *c;
15+
@end
16+
17+
J *conjure_J();
18+
19+
@implementation I
20+
- (void)bar {
21+
if (self) { // no-crash
22+
J *j = conjure_J();
23+
if (j.c)
24+
[self bar];
25+
// FIXME: Should warn.
26+
[self foo:j.c]; // no-warning
27+
}
28+
}
29+
@end
30+
31+
@implementation J
32+
@end

clang/test/lit.cfg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ def is_filesystem_case_insensitive():
151151
if platform.system() not in ['Windows']:
152152
config.available_features.add('can-remove-opened-file')
153153

154+
# *-apple-macosx should also be XFAILED when 'darwin' is XFAILED.
155+
if lit.util.isMacOSTriple(config.target_triple):
156+
config.available_features.add('darwin')
154157

155158
def calculate_arch_features(arch_string):
156159
features = []

llvm/include/llvm/DebugInfo/CodeView/CodeViewRegisters.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ CV_REGISTER(AMD64_K7, 765)
368368

369369
#if defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_ARM64)
370370

371+
// arm64intr.h from MSVC defines ARM64_FPSR, which conflicts with
372+
// these declarations.
373+
#pragma push_macro("ARM64_FPSR")
374+
#undef ARM64_FPSR
375+
371376
// ARM64 registers
372377

373378
CV_REGISTER(ARM64_NOREG, 0)
@@ -556,4 +561,6 @@ CV_REGISTER(ARM64_Q31, 211)
556561

557562
CV_REGISTER(ARM64_FPSR, 220)
558563

564+
#pragma pop_macro("ARM64_FPSR")
565+
559566
#endif // defined(CV_REGISTERS_ALL) || defined(CV_REGISTERS_ARM64)

0 commit comments

Comments
 (0)