Skip to content

Commit 5b92602

Browse files
authored
[Driver][SYCL] Fix null pointer dereference (#2008)
Signed-off-by: Harini Chilamantula <[email protected]>
1 parent a4f2182 commit 5b92602

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

clang/lib/Driver/Driver.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -4841,6 +4841,20 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
48414841
if (!UnbundlerInputs.empty() && !PL.empty()) {
48424842
Action *PartialLink =
48434843
C.MakeAction<PartialLinkJobAction>(UnbundlerInputs, types::TY_Object);
4844+
if (!LastArg) {
4845+
auto *TA = dyn_cast<Action>(UnbundlerInputs.back());
4846+
assert(TA->getKind() == Action::InputClass ||
4847+
TA->getKind() == Action::OffloadClass);
4848+
4849+
// If the Action is of OffloadAction type, use the HostAction of the
4850+
// specific Offload Action to set LastArg
4851+
if (auto *OA = dyn_cast<OffloadAction>(UnbundlerInputs.back()))
4852+
LastArg =
4853+
&(dyn_cast<InputAction>(OA->getHostDependence())->getInputArg());
4854+
else if (auto *IA = dyn_cast<InputAction>(UnbundlerInputs.back()))
4855+
// else set the LastArg based on Last InputAction
4856+
LastArg = &(IA->getInputArg());
4857+
}
48444858
Action *Current = C.MakeAction<InputAction>(*LastArg, types::TY_Object);
48454859
ActionList AL;
48464860
AL.push_back(PartialLink);

0 commit comments

Comments
 (0)