Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/LLVMCompat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ THE SOFTWARE.
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Frontend/CompilerInstance.h"

const std::string sHipify = "[HIPIFY] ", sConflict = "conflict: ", sError = "error: ", sWarning = "warning: ";
const std::string sHipify = "[HIPIFY] ", sConflict = "conflict: ",
sError = "error: ", sWarning = "warning: ", sNote = "note: ";

namespace llcompat {

Expand Down
2 changes: 1 addition & 1 deletion src/LLVMCompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ THE SOFTWARE.

namespace ct = clang::tooling;

extern const std::string sHipify, sConflict, sError, sWarning;
extern const std::string sHipify, sConflict, sError, sWarning, sNote;

// Things for papering over the differences between different LLVM versions.

Expand Down
24 changes: 24 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ constexpr auto DEBUG_TYPE = "cuda2hip";

namespace ct = clang::tooling;

static bool isHeaderFile(llvm::StringRef filePath) {
llvm::StringRef extension = llvm::sys::path::extension(filePath);
return extension.equals_insensitive(".h") ||
extension.equals_insensitive(".hpp") ||
extension.equals_insensitive(".hxx") ||
extension.equals_insensitive(".cuh") ||
extension.equals_insensitive(".inl") ||
extension.equals_insensitive(".inc");
}

void cleanupHipifyOptions(std::vector<const char*> &args) {
for (const auto &a : hipifyOptions) {
args.erase(std::remove(args.begin(), args.end(), "--" + a), args.end());
Expand Down Expand Up @@ -539,6 +549,20 @@ int main(int argc, const char **argv) {
Statistics::current().hasErrors = true;
Result = 1;
LLVM_DEBUG(llvm::dbgs() << "Hipification failed for: " << src << "\n");
if (isHeaderFile(src)) {
llvm::errs()
<< "\n"
<< sHipify << sWarning << "Header file '"
<< sys::path::filename(sSourceAbsPath)
<< "' failed to hipify. This header may not be self-contained.\n";
llvm::errs() << sHipify << sNote
<< "Headers that depend on symbols from other files "
<< "cannot be hipified in isolation.\n";
llvm::errs() << sHipify << sNote
<< "Consider hipifying the parent source file (.cu/.cpp) "
<< "that includes this header to ensure all dependencies "
"are resolved.\n";
}
}

Statistics::current().markCompletion();
Expand Down