コード例 #1
0
ファイル: Rewriter.cpp プロジェクト: DarkOfTheMoon/cpp-opencl
void RemoveFunction(clang::Rewriter& TheRewriter, const FunctionDecl* F)
{
    ExpandSourceRange SourceRange{TheRewriter};
    TheRewriter.RemoveText(SourceRange(F->getSourceRange()));
    if (FunctionTemplateDecl* D = F->getDescribedFunctionTemplate()) {
        TheRewriter.RemoveText(SourceRange(D->getSourceRange()));
    }
}
コード例 #2
0
ファイル: RefactoringTool.cpp プロジェクト: skelcl/skelcl
std::string RefactoringTool::writeReplacements(clang::Rewriter &rewriter)
{
  std::ostringstream oss;
  for ( auto i  = rewriter.buffer_begin(),
             e  = rewriter.buffer_end();
             i != e;
           ++i ) {
    llvm::raw_os_ostream stream(oss);
    i->second.write(stream);
    stream.flush();
  }
  return oss.str();
}
コード例 #3
0
bool writeFiles(const clang::Rewriter &Rewrites) {

  for (Rewriter::const_buffer_iterator BufferI = Rewrites.buffer_begin(),
                                       BufferE = Rewrites.buffer_end();
       BufferI != BufferE; ++BufferI) {
    const char *FileName =
        Rewrites.getSourceMgr().getFileEntryForID(BufferI->first)->getName();

    std::error_code EC;
    llvm::raw_fd_ostream FileStream(FileName, EC, llvm::sys::fs::F_Text);
    if (EC) {
      errs() << "Warning: Could not write to " << EC.message() << "\n";
      continue;
    }
    BufferI->second.write(FileStream);
  }

  return true;
}
コード例 #4
0
bool writeFiles(const clang::Rewriter &Rewrites) {

  for (Rewriter::const_buffer_iterator BufferI = Rewrites.buffer_begin(),
                                       BufferE = Rewrites.buffer_end();
       BufferI != BufferE; ++BufferI) {
    const char *FileName =
        Rewrites.getSourceMgr().getFileEntryForID(BufferI->first)->getName();

    std::string ErrorInfo;

    llvm::raw_fd_ostream FileStream(FileName, ErrorInfo);
    if (!ErrorInfo.empty()) {
      errs() << "Warning: Could not write to " << FileName << "\n";
      continue;
    }
    BufferI->second.write(FileStream);
  }

  return true;
}
コード例 #5
0
ファイル: Rewriter.cpp プロジェクト: DarkOfTheMoon/cpp-opencl
void RemoveStatement(clang::Rewriter& TheRewriter, clang::CallExpr const * const Statement)
{
    ExpandSourceRange SourceRange{TheRewriter};
    TheRewriter.RemoveText(SourceRange(Statement->getSourceRange()));
}