Skip to content

Commit

Permalink
Fix bug llvm#23 where funcs where not searched for ref
Browse files Browse the repository at this point in the history
  • Loading branch information
manorom committed Mar 5, 2019
1 parent 8346133 commit d742497
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
4 changes: 3 additions & 1 deletion clang/tools/sotoc/src/DeclResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void DeclResolver::addDecl(clang::Decl *D) {

// This Decl may have other Decls that is depends on.
// Add Decl if we haven't already
findDependDecls(D, UnresolvedDecls);
findDependDecls(ResolveDecl, UnresolvedDecls);
}
UnresolvedDecls.erase(ResolveDeclIter);
}
Expand All @@ -111,6 +111,7 @@ void DeclResolver::findDependDecls(
// compile.
runOwnVisitor(D, [&D, &UnresolvedDecls, this](clang::Decl *Dep) {
if (!this->AllDecls.count(Dep)) {
DEBUGPDECL(Dep, "Found referred decl: ");
UnresolvedDecls.insert(Dep);
}
// Fix for enums. TODO: find a better way to avoid duplicates
Expand Down Expand Up @@ -181,6 +182,7 @@ void TypeDeclResolver::runOwnVisitor(clang::Decl *D,

void FunctionDeclResolver::runOwnVisitor(
clang::Decl *D, std::function<void(clang::Decl *Dep)> Fn) {
DEBUGPDECL(D, "Searching for referred decls in function " );
DiscoverFunctionsInDeclVisitor Visitor(Fn);
Visitor.TraverseDecl(D);
}
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/sotoc/src/TargetCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bool TargetCode::addCodeFragment(std::shared_ptr<TargetCodeFragment> Frag,
if ((SM.isPointWithin(Frag->getRealRange().getBegin(),
F->getRealRange().getBegin(),
F->getRealRange().getEnd()) &&
Frag->getRealRange().getBegin() != F->getRealRange().getBegin()) ||
Frag->getRealRange().getBegin() != F->getRealRange().getBegin()) &&
SM.isPointWithin(Frag->getRealRange().getEnd(),
F->getRealRange().getBegin(),
F->getRealRange().getEnd())) {
Expand Down
13 changes: 1 addition & 12 deletions clang/tools/sotoc/src/Visitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,23 +245,12 @@ bool FindTargetCodeVisitor::VisitDecl(clang::Decl *D) {
// search Decl attributes for 'omp declare target' attr
for (auto &attr : D->attrs()) {
if (attr->getKind() == clang::attr::OMPDeclareTargetDecl) {
auto SystemHeader = getSystemHeaderForDecl(D);
if (SystemHeader.hasValue()) {
TargetCodeInfo.addHeader(SystemHeader.getValue());
return true;
}

auto TCD = std::make_shared<TargetCodeDecl>(D);
TargetCodeInfo.addCodeFragment(TCD);
DiscoverTypeVisitor.TraverseDecl(D);
Functions.addDecl(D);
if (FD) {
if (FD->hasBody() && !FD->doesThisDeclarationHaveABody()) {
FuncDeclWithoutBody.insert(FD->getNameAsString());
}
}
if (!D->hasBody() || (FD && !FD->doesThisDeclarationHaveABody())) {
TCD->NeedsSemicolon = true;
}
return true;
}
}
Expand Down

0 comments on commit d742497

Please sign in to comment.