fix build bug with current clang/llvm
This commit is contained in:
+38
-38
@@ -229,22 +229,22 @@ namespace {
|
||||
DenseMap<StringRef, StringRef> cuda2hipRename;
|
||||
};
|
||||
|
||||
struct HipifyPPCallbacks : public PPCallbacks, public SourceFileCallbacks {
|
||||
HipifyPPCallbacks(Replacements * R)
|
||||
: SeenEnd(false), _sm(nullptr), Replace(R)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool handleBeginSource(CompilerInstance &CI, StringRef Filename) override
|
||||
{
|
||||
Preprocessor &PP = CI.getPreprocessor();
|
||||
SourceManager & SM = CI.getSourceManager();
|
||||
setSourceManager(&SM);
|
||||
PP.addPPCallbacks(std::unique_ptr<HipifyPPCallbacks>(this));
|
||||
PP.Retain();
|
||||
return true;
|
||||
}
|
||||
|
||||
struct HipifyPPCallbacks : public PPCallbacks, public SourceFileCallbacks {
|
||||
HipifyPPCallbacks(Replacements * R)
|
||||
: SeenEnd(false), _sm(nullptr), Replace(R)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool handleBeginSource(CompilerInstance &CI, StringRef Filename) override
|
||||
{
|
||||
Preprocessor &PP = CI.getPreprocessor();
|
||||
SourceManager & SM = CI.getSourceManager();
|
||||
setSourceManager(&SM);
|
||||
PP.addPPCallbacks(std::unique_ptr<HipifyPPCallbacks>(this));
|
||||
PP.Retain();
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void InclusionDirective(
|
||||
SourceLocation hash_loc,
|
||||
const Token &include_token,
|
||||
@@ -254,7 +254,7 @@ namespace {
|
||||
const FileEntry *file,
|
||||
StringRef search_path,
|
||||
StringRef relative_path,
|
||||
const Module *imported) override
|
||||
const clang::Module *imported) override
|
||||
{
|
||||
if (_sm->isWrittenInMainFile(hash_loc)) {
|
||||
if (is_angled) {
|
||||
@@ -265,8 +265,8 @@ namespace {
|
||||
llvm::errs() << "\nWill be replaced with " << repName << "\n";
|
||||
SourceLocation sl = filename_range.getBegin();
|
||||
SourceLocation sle = filename_range.getEnd();
|
||||
const char* B = _sm->getCharacterData(sl);
|
||||
const char* E = _sm->getCharacterData(sle);
|
||||
const char* B = _sm->getCharacterData(sl);
|
||||
const char* E = _sm->getCharacterData(sle);
|
||||
repName = "<" + repName + ">";
|
||||
Replacement Rep(*_sm, sl, E - B, repName);
|
||||
Replace->insert(Rep);
|
||||
@@ -300,22 +300,22 @@ namespace {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EndOfMainFile() override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool SeenEnd;
|
||||
void setSourceManager(SourceManager * sm) { _sm = sm; }
|
||||
|
||||
private:
|
||||
|
||||
SourceManager * _sm;
|
||||
Replacements * Replace;
|
||||
struct hipName N;
|
||||
};
|
||||
|
||||
|
||||
void EndOfMainFile() override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool SeenEnd;
|
||||
void setSourceManager(SourceManager * sm) { _sm = sm; }
|
||||
|
||||
private:
|
||||
|
||||
SourceManager * _sm;
|
||||
Replacements * Replace;
|
||||
struct hipName N;
|
||||
};
|
||||
|
||||
class Cuda2HipCallback : public MatchFinder::MatchCallback {
|
||||
public:
|
||||
Cuda2HipCallback(Replacements *Replace) : Replace(Replace) {}
|
||||
@@ -452,8 +452,8 @@ class Cuda2HipCallback : public MatchFinder::MatchCallback {
|
||||
|
||||
if (const ParmVarDecl * cudaParamDecl = Result.Nodes.getNodeAs<clang::ParmVarDecl>("cudaParamDecl"))
|
||||
{
|
||||
QualType QT = cudaParamDecl->getOriginalType();
|
||||
std::string name = QT.getAsString();
|
||||
QualType QT = cudaParamDecl->getOriginalType();
|
||||
std::string name = QT.getAsString();
|
||||
std::string repName = N.cuda2hipRename[name];
|
||||
SourceLocation sl = cudaParamDecl->getLocStart();
|
||||
Replacement Rep(*SM, SM->isMacroArgExpansion(sl) ?
|
||||
@@ -506,7 +506,7 @@ int main(int argc, const char **argv) {
|
||||
Finder.addMatcher(declRefExpr(isExpansionInMainFile(), to(enumConstantDecl(matchesName("cuda.*")))).bind("cudaEnumConstantRef"), &Callback);
|
||||
Finder.addMatcher(varDecl(isExpansionInMainFile(), hasType(enumDecl(matchesName("cuda.*")))).bind("cudaEnumConstantDecl"), &Callback);
|
||||
Finder.addMatcher(varDecl(isExpansionInMainFile(), hasType(cxxRecordDecl(matchesName("cuda.*")))).bind("cudaStructVar"), &Callback);
|
||||
Finder.addMatcher(parmVarDecl(isExpansionInMainFile(), hasType(namedDecl(matchesName("cuda.*")))).bind("cudaParamDecl"), &Callback);
|
||||
Finder.addMatcher(parmVarDecl(isExpansionInMainFile(), hasType(namedDecl(matchesName("cuda.*")))).bind("cudaParamDecl"), &Callback);
|
||||
|
||||
auto action = newFrontendActionFactory(&Finder, &PPCallbacks);
|
||||
|
||||
|
||||
Verwijs in nieuw issue
Block a user