Skip to content

Commit 7f2e99c

Browse files
authored
[Driver][SYCL] Allow for preprocessing to succeed with coding errors (#5784)
Typical behavior is to allow for preprocessing to succeed regardless of the input file. When building with -fsycl, this is not possible due to the requirement to generate the integration ehader and footer before we do the actual preprocessing step. Adjust the compilation when preprocessing is requested to allow for the device compilation to fail and continue to perform the preprocessing steps.
1 parent 9fcab29 commit 7f2e99c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

clang/lib/Driver/Compilation.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ int Compilation::ExecuteCommand(const Command &C,
236236
getDriver().Diag(diag::err_drv_command_failure) << Error;
237237
}
238238

239+
// When performing preprocessing, we need to be able to produce the
240+
// preprocessed output even if the compilation is not valid. If
241+
// the device compilation fails for SYCL allow the failure to pass
242+
// through so we can still generate the expected preprocessed files.
243+
if (Res && C.getSource().isDeviceOffloading(Action::OFK_SYCL) &&
244+
getArgs().hasArg(options::OPT_E))
245+
return 0;
246+
239247
if (Res)
240248
FailingCommand = &C;
241249

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// Allow for preprocessing to 'succeed' even though there are coding issues
2+
/// in the source. We always have an additional step to generate the
3+
/// integration header and footer, so if that fails we still want to produce
4+
/// preprocessing information in the subsequent passes.
5+
// RUN: %clang -fsycl -E -dM %s 2>&1 | FileCheck %s --check-prefix=PP_CHECK
6+
// PP_CHECK: SYCL_PP_CHECK
7+
8+
void foo(;
9+
#define SYCL_PP_CHECK

0 commit comments

Comments
 (0)