[llvm-bugs] [Bug 25583] New: Outdated code example in "Tutorial for building tools using LibTooling and LibASTMatchers" does not compile

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 20 02:55:30 PST 2015


https://llvm.org/bugs/show_bug.cgi?id=25583

            Bug ID: 25583
           Summary: Outdated code example in "Tutorial for building tools
                    using LibTooling and LibASTMatchers" does not compile
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Documentation
          Assignee: unassignedclangbugs at nondot.org
          Reporter: 24hesk at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The tutorial at http://clang.llvm.org/docs/LibASTMatchersTutorial.html has the
following code snippet:

void LoopPrinter::run(const MatchFinder::MatchResult &Result) {
  ASTContext *Context = Result.Context;
  const ForStmt *FS = Result.Nodes.getStmtAs<ForStmt>("forLoop");
  // We do not want to convert header files!
  if (!FS || !Context->getSourceManager().isFromMainFile(FS->getForLoc()))
    return;
  const VarDecl *IncVar = Result.Nodes.getNodeAs<VarDecl>("incVarName");
  const VarDecl *CondVar = Result.Nodes.getNodeAs<VarDecl>("condVarName");
  const VarDecl *InitVar = Result.Nodes.getNodeAs<VarDecl>("initVarName");

  if (!areSameVariable(IncVar, CondVar) || !areSameVariable(IncVar, InitVar))
    return;
  llvm::outs() << "Potential array-based loop discovered.\n";
}

This does not compile. The function call to isFromMainFile needs to be changed
to isWrittenInMainFile.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151120/fe49130a/attachment-0001.html>


More information about the llvm-bugs mailing list