36 #include <clang/AST/ASTContext.h>
38 using namespace clang;
45 void ReportError(ASTContext& Ctx, StringRef Message, T *Subject) {
46 DiagnosticsEngine& Diag = Ctx.getDiagnostics();
47 int DiagID = Diag.getCustomDiagID(DiagnosticsEngine::Error,
48 (
"TESLA: " + Message).str());
50 Diag.Report(Subject->getLocStart(), DiagID) << Subject->getSourceRange();
54 TeslaVisitor::TeslaVisitor(llvm::StringRef Filename, ASTContext *Context)
55 : Filename(Filename), Context(Context)
60 for (
auto *A : Automata)
68 FunctionDecl *F = E->getDirectCallee();
71 StringRef FnName = F->getName();
72 if (!FnName.startswith(
TESLA_BASE))
return true;
80 OwningPtr<AutomatonDescription> Description;
82 if (!P->Parse(Description, Use))
85 Automata.push_back(Description.take());
86 Roots.push_back(Use.take());
96 if (!F->doesThisDeclarationHaveABody())
101 const Type *RetTy = F->getResultType().getTypePtr();
102 if (!RetTy->isPointerType())
105 QualType Pointee = RetTy->getPointeeType();
106 auto TypeID = Pointee.getBaseTypeIdentifier();
111 StringRef FnName = F->getName();
114 string RetTypeName = TypeID->getName();
129 OwningPtr<AutomatonDescription> Description;
130 OwningPtr<Usage> Use;
131 if (!P->Parse(Description, Use))
135 Automata.push_back(Description.take());
138 Roots.push_back(Use.take());