[clang] b89e09a - Silence "Undefined or garbage value returned to caller" static analysis warning. NFCI.

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Mon May 24 16:11:26 PDT 2021


If this is meant to be NFC, I guess the function is never meant to return
null? (it's meant to be an invariant of the code that at least one of the
builders is valid) - if that's the case, I'm not sure if this is good
change.

If there is a bug in the future that causes there to be an no valid builder
- this change will cause that failure mode to be delayed and more distant
from the problem, compared to the failure that this code would have under
msan if it attempted to return garbage, I think? (hmm, well, I guess not
/much/ better, even the msan failure is delayed until the value is used in
an "interesting" way - not directly on the return - but the msan error is
clearer/might lead someone back to the variable declaration (where we could
have a comment about the intended invariant of the code) compared to them
thinking null was a valid return value from the function and adding null
handling in the caller instead)

On Mon, May 17, 2021 at 6:09 AM Simon Pilgrim via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

>
> Author: Simon Pilgrim
> Date: 2021-05-17T14:08:27+01:00
> New Revision: b89e09a19f9b60dfa9477b24a404a7ae5522f898
>
> URL:
> https://github.com/llvm/llvm-project/commit/b89e09a19f9b60dfa9477b24a404a7ae5522f898
> DIFF:
> https://github.com/llvm/llvm-project/commit/b89e09a19f9b60dfa9477b24a404a7ae5522f898.diff
>
> LOG: Silence "Undefined or garbage value returned to caller" static
> analysis warning. NFCI.
>
> Added:
>
>
> Modified:
>     clang/lib/Driver/Driver.cpp
>
> Removed:
>
>
>
>
> ################################################################################
> diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
> index 1086887a8de5..25af909d9bd2 100644
> --- a/clang/lib/Driver/Driver.cpp
> +++ b/clang/lib/Driver/Driver.cpp
> @@ -3449,7 +3449,7 @@ class OffloadingActionBuilder final {
>        return nullptr;
>
>      // Let builders add host linking actions.
> -    Action* HA;
> +    Action* HA = nullptr;
>      for (DeviceActionBuilder *SB : SpecializedBuilders) {
>        if (!SB->isValid())
>          continue;
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210524/1138ce98/attachment.html>


More information about the cfe-commits mailing list