[clang] e63abde - [clang][driver] Fix null pointer dereference warning inside PrintActions1 (PR43462)
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 5 07:32:39 PST 2020
Author: Simon Pilgrim
Date: 2020-02-05T15:32:18Z
New Revision: e63abde39f530028b0089ea477446c1b671a28f1
URL: https://github.com/llvm/llvm-project/commit/e63abde39f530028b0089ea477446c1b671a28f1
DIFF: https://github.com/llvm/llvm-project/commit/e63abde39f530028b0089ea477446c1b671a28f1.diff
LOG: [clang][driver] Fix null pointer dereference warning inside PrintActions1 (PR43462)
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.
Differential Revision: https://reviews.llvm.org/D74046
Added:
Modified:
clang/lib/Driver/Driver.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 6db791ab8333..f35aab19e83d 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1848,6 +1848,7 @@ static unsigned PrintActions1(const Compilation &C, Action *A,
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 @@ static unsigned PrintActions1(const Compilation &C, Action *A,
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 << ")";
More information about the cfe-commits
mailing list