|
12 | 12 | #include "Utility.h" |
13 | 13 | #include "ValidateArguments.h" |
14 | 14 |
|
| 15 | +#include "ToolChains/Cuda.h" |
| 16 | +#include "clang/Driver/Driver.h" |
| 17 | +#include "clang/Driver/Options.h" |
15 | 18 | #include "clang/Tooling/Refactoring.h" |
16 | 19 | #include "llvm/ADT/SmallString.h" |
17 | 20 | #include "llvm/ADT/StringRef.h" |
18 | 21 | #include "llvm/Support/FileSystem.h" |
19 | 22 | #include "llvm/Support/Path.h" |
20 | 23 | #include "llvm/Support/raw_os_ostream.h" |
| 24 | +#include "llvm/TargetParser/Host.h" |
21 | 25 |
|
22 | 26 | #include <fstream> |
23 | 27 | #include <string> |
@@ -210,6 +214,27 @@ static void getCompileInfo( |
210 | 214 | clang::tooling::UnifiedPath IncPath = Option; |
211 | 215 | rewriteCanonicalDir(IncPath, InRoot, OutRoot); |
212 | 216 |
|
| 217 | + unsigned MissingArgIndex, MissingArgCount; |
| 218 | + MissingArgIndex = MissingArgCount = 0; |
| 219 | + auto &Opts = clang::driver::getDriverOptTable(); |
| 220 | + llvm::opt::InputArgList ParsedArgs = |
| 221 | + Opts.ParseArgs(nullptr, MissingArgIndex, MissingArgCount); |
| 222 | + |
| 223 | + // Create minimalist CudaInstallationDetector to call the member |
| 224 | + // function validateCudaHeaderDirectory() |
| 225 | + DiagnosticsEngine E(nullptr, nullptr, nullptr, false); |
| 226 | + clang::driver::Driver Driver("", llvm::sys::getDefaultTargetTriple(), |
| 227 | + E); |
| 228 | + clang::driver::CudaInstallationDetector CudaIncludeDetector( |
| 229 | + Driver, llvm::Triple(Driver.getTargetTriple()), ParsedArgs); |
| 230 | + bool Ret = CudaIncludeDetector.validateCudaHeaderDirectory( |
| 231 | + IncPath.getCanonicalPath().str(), Driver); |
| 232 | + if (Ret) { |
| 233 | + // Skip CUDA SDK header path specified by option "-isystem" in the |
| 234 | + // auto-generated Makefile. |
| 235 | + continue; |
| 236 | + } |
| 237 | + |
213 | 238 | NewOptions += "-isystem "; |
214 | 239 | SmallString<512> OutDirectory(IncPath.getCanonicalPath()); |
215 | 240 | llvm::sys::path::replace_path_prefix(OutDirectory, |
|
0 commit comments