[cfe-commits] r173292 - /cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp

David Blaikie dblaikie at gmail.com
Wed Jan 23 13:50:54 PST 2013


On Wed, Jan 23, 2013 at 1:12 PM, Ted Kremenek <kremenek at apple.com> wrote:
> Author: kremenek
> Date: Wed Jan 23 15:12:49 2013
> New Revision: 173292
>
> URL: http://llvm.org/viewvc/llvm-project?rev=173292&view=rev
> Log:
> Add missing null check.  Not sure why my tests passed before.

Did the old code fail if you added an assert(MD) in it? If not, it
sounds like there's a missing test case that might be good to add. (if
it did fail, then somehow you were getting lucky with the way hasAttr
was accessing memory near address zero? Which would be rather
surprising, but if true, there's not really any test to add)

>
> Modified:
>     cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp?rev=173292&r1=173291&r2=173292&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp Wed Jan 23 15:12:49 2013
> @@ -102,10 +102,12 @@
>  void NoReturnFunctionChecker::checkPostObjCMessage(const ObjCMethodCall &Msg,
>                                                     CheckerContext &C) const {
>    // Check if the method is annotated with analyzer_noreturn.
> -  const ObjCMethodDecl *MD = Msg.getDecl()->getCanonicalDecl();
> -  if (MD->hasAttr<AnalyzerNoReturnAttr>()) {
> -    C.generateSink();
> -    return;
> +  if (const ObjCMethodDecl *MD = Msg.getDecl()) {
> +    MD = MD->getCanonicalDecl();
> +    if (MD->hasAttr<AnalyzerNoReturnAttr>()) {
> +      C.generateSink();
> +      return;
> +    }
>    }
>
>    // HACK: This entire check is to handle two messages in the Cocoa frameworks:
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list