diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 41f8f9f0bc50900c7fb9515387d1a7039b623f4f..3d58b9ae05af91ba50212596ba1d774f4a4c01f3 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -7695,8 +7695,7 @@ bool DiagnoseUnguardedAvailability::TraverseIfStmt(IfStmt *If) { // If we're using the '*' case here or if this check is redundant, then we // use the enclosing version to check both branches. if (CondVersion.empty() || CondVersion <= AvailabilityStack.back()) - return Base::TraverseStmt(If->getThen()) && - Base::TraverseStmt(If->getElse()); + return TraverseStmt(If->getThen()) && TraverseStmt(If->getElse()); } else { // This isn't an availability checking 'if', we can just continue. return Base::TraverseIfStmt(If); diff --git a/test/FixIt/fixit-availability.mm b/test/FixIt/fixit-availability.mm index f6a185569443499457686f046aafb4d8b8e46d0b..a5660825327f77ae524a495336dd2c4e8db005dc 100644 --- a/test/FixIt/fixit-availability.mm +++ b/test/FixIt/fixit-availability.mm @@ -108,6 +108,14 @@ void wrapDeclStmtUses() { // CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:24-[[@LINE-2]]:24}:"\n } else {\n // Fallback on earlier versions\n }" anotherFunction(y); anotherFunction(x); + + if (@available(macOS 10.1, *)) { + int z = function(); + (void)z; +// CHECK: fix-it:{{.*}}:{[[@LINE-2]]:5-[[@LINE-2]]:5}:"if (@available(macOS 10.12, *)) {\n " +// CHECK-NEXT: fix-it:{{.*}}:{[[@LINE-2]]:13-[[@LINE-2]]:13}:"\n } else {\n // Fallback on earlier versions\n }" + anotherFunction(x); + } } #define API_AVAILABLE(X) __attribute__((availability(macos, introduced=10.12))) // dummy macro