+1. All the enum cases were enumerated, and I want a compiler warning (from Clang) to tell us when we miss updating the switch statement instead of waiting for an assertion failure. A 'default' case removes this checking.
On Mar 2, 2011, at 3:33 PM, John McCall wrote: > On Mar 2, 2011, at 3:25 PM, Matt Beaumont-Gay wrote: >> Author: matthewbg >> Date: Wed Mar 2 17:25:06 2011 >> New Revision: 126897 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=126897&view=rev >> Log: >> Keep GCC from complaining about falling off the end of the function. >> >> Modified: >> cfe/trunk/lib/Analysis/CFG.cpp >> >> Modified: cfe/trunk/lib/Analysis/CFG.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=126897&r1=126896&r2=126897&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Analysis/CFG.cpp (original) >> +++ cfe/trunk/lib/Analysis/CFG.cpp Wed Mar 2 17:25:06 2011 >> @@ -2774,6 +2774,7 @@ >> >> const CXXDestructorDecl *CFGImplicitDtor::getDestructorDecl() const { >> switch (getKind()) { >> + default: assert(0 && "Unknown CFGElement"); >> case CFGElement::Invalid: >> case CFGElement::Statement: >> case CFGElement::Initializer: > > The general style in Clang is (1) to use llvm_unreachable(msg) instead of > assert(0 && msg) and (2) to not add default cases to switches which are > supposed to be exhaustive. Please move this to after the switch and follow > it with a return 0. > > John. > _______________________________________________ > cfe-commits mailing list > cfe-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits