File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ static const char WarningMessage[] = "do not use 'else' after '%0'";
2727static const char WarnOnUnfixableStr[] = " WarnOnUnfixable" ;
2828
2929const DeclRefExpr *findUsage (const Stmt *Node, int64_t DeclIdentifier) {
30+ if (!Node)
31+ return nullptr ;
3032 if (const auto *DeclRef = dyn_cast<DeclRefExpr>(Node)) {
3133 if (DeclRef->getDecl ()->getID () == DeclIdentifier) {
3234 return DeclRef;
@@ -44,6 +46,8 @@ const DeclRefExpr *findUsage(const Stmt *Node, int64_t DeclIdentifier) {
4446const DeclRefExpr *
4547findUsageRange (const Stmt *Node,
4648 const llvm::iterator_range<int64_t *> &DeclIdentifiers) {
49+ if (!Node)
50+ return nullptr ;
4751 if (const auto *DeclRef = dyn_cast<DeclRefExpr>(Node)) {
4852 if (llvm::is_contained (DeclIdentifiers, DeclRef->getDecl ()->getID ())) {
4953 return DeclRef;
Original file line number Diff line number Diff line change @@ -213,3 +213,16 @@ int lifeTimeExtensionTests(int a) {
213213 return b;
214214 }
215215}
216+
217+ void test_B44745 () {
218+ // This is the actual minimum test case for the crash in bug 44745. We aren't
219+ // too worried about the warning or fix here, more we don't want a crash.
220+ // CHECK-MESSAGES: :[[@LINE+3]]:5: warning: do not use 'else' after 'return' [readability-else-after-return]
221+ if (auto X = false ) {
222+ return ;
223+ } else {
224+ for (;;) {
225+ }
226+ }
227+ return ;
228+ }
You can’t perform that action at this time.
0 commit comments