[PATCH] D74046: [clang][driver] Fix null pointer dereference warning inside PrintActions1 (PR43462)
Simon Pilgrim via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 5 06:03:36 PST 2020
RKSimon created this revision.
RKSimon added reviewers: sfantao, tra, ABataev, jlebar.
Herald added a project: clang.
As detailed on PR43462, clang static analyzer is complaining about a null pointer dereference as we provide a 'host' toolchain fallback if the ToolChain pointer is null, but then use that pointer anyhow to report the triple.
Tests indicate the ToolChain pointer is always valid and the 'host' code path is redundant.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74046
Files:
clang/lib/Driver/Driver.cpp
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1848,6 +1848,7 @@
bool IsFirst = true;
OA->doOnEachDependence(
[&](Action *A, const ToolChain *TC, const char *BoundArch) {
+ assert(TC && "Unknown host toolchain");
// E.g. for two CUDA device dependences whose bound arch is sm_20 and
// sm_35 this will generate:
// "cuda-device" (nvptx64-nvidia-cuda:sm_20) {#ID}, "cuda-device"
@@ -1855,13 +1856,9 @@
if (!IsFirst)
os << ", ";
os << '"';
- if (TC)
- os << A->getOffloadingKindPrefix();
- else
- os << "host";
+ os << A->getOffloadingKindPrefix();
os << " (";
os << TC->getTriple().normalize();
-
if (BoundArch)
os << ":" << BoundArch;
os << ")";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74046.242579.patch
Type: text/x-patch
Size: 972 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200205/0eee60d5/attachment.bin>
More information about the cfe-commits
mailing list