diff options
-rw-r--r-- | clang/lib/Analysis/CalledOnceCheck.cpp | 5 | ||||
-rw-r--r-- | clang/test/SemaObjC/warn-called-once.m | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Analysis/CalledOnceCheck.cpp b/clang/lib/Analysis/CalledOnceCheck.cpp index 04c5f6a..30cbd25 100644 --- a/clang/lib/Analysis/CalledOnceCheck.cpp +++ b/clang/lib/Analysis/CalledOnceCheck.cpp @@ -163,7 +163,7 @@ public: NotVisited = 0x8, /* 1000 */ // We already reported a violation and stopped tracking calls for this // parameter. - Reported = 0x15, /* 1111 */ + Reported = 0xF, /* 1111 */ LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ Reported) }; @@ -932,7 +932,8 @@ private: ParameterStatus &CurrentParamStatus = CurrentState.getStatusFor(Index); // Escape overrides whatever error we think happened. - if (CurrentParamStatus.isErrorStatus()) { + if (CurrentParamStatus.isErrorStatus() && + CurrentParamStatus.getKind() != ParameterStatus::Kind::Reported) { CurrentParamStatus = ParameterStatus::Escaped; } } diff --git a/clang/test/SemaObjC/warn-called-once.m b/clang/test/SemaObjC/warn-called-once.m index dbe8dc1..f23e41e 100644 --- a/clang/test/SemaObjC/warn-called-once.m +++ b/clang/test/SemaObjC/warn-called-once.m @@ -1194,6 +1194,16 @@ void suppression_3(int cond, void (^callback)(void) CALLED_ONCE) { escape(handler); } +- (void)test_termination:(int)cond + withCompletion:(void (^)(void))handler { + // The code below was able to cause non-termination but should be + // fixed now: + do { + escape(handler); + handler(); // expected-warning{{completion handler is called twice}} expected-note{{previous call is here; set to nil to indicate it cannot be called afterwards}} + } while (cond); +} + typedef void (^DeferredBlock)(void); static inline void DefferedCallback(DeferredBlock *inBlock) { (*inBlock)(); } #define _DEFERCONCAT(a, b) a##b |