[PATCH] D102067: [amdgpu-arch] Guard hsa.h with __has_include
Pushpinder Singh via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 7 06:48:47 PDT 2021
pdhaliwal updated this revision to Diff 343668.
pdhaliwal added a comment.
Added fallback in case __has_include is not defined or header is not found anywhere.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102067/new/
https://reviews.llvm.org/D102067
Files:
clang/tools/amdgpu-arch/AMDGPUArch.cpp
Index: clang/tools/amdgpu-arch/AMDGPUArch.cpp
===================================================================
--- clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -11,7 +11,24 @@
//
//===----------------------------------------------------------------------===//
-#include <hsa.h>
+#if defined(__has_include)
+#if __has_include("hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa.h"
+#elif __has_include("hsa/hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa/hsa.h"
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+
+#if !HSA_HEADER_FOUND
+int main() { return 1; }
+#else
+
#include <string>
#include <vector>
@@ -57,3 +74,5 @@
hsa_shut_down();
return 0;
}
+
+#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102067.343668.patch
Type: text/x-patch
Size: 761 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210507/de91665b/attachment.bin>
More information about the cfe-commits
mailing list