[PATCH] D28180: Fixing small errors in libAST Matcher Tutorial.

Mads Ravn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 30 10:54:19 PST 2016

madsravn created this revision.
madsravn added reviewers: aaron.ballman, malcolm.parsons.
madsravn added a subscriber: cfe-commits.

The tutorial contains a few errors which results in code not being able to compile.

One error was described here: https://llvm.org/bugs/show_bug.cgi?id=25583 .

I found and fixed the error and one additional error.



Index: docs/LibASTMatchersTutorial.rst
--- docs/LibASTMatchersTutorial.rst
+++ docs/LibASTMatchersTutorial.rst
@@ -496,9 +496,9 @@
       void LoopPrinter::run(const MatchFinder::MatchResult &Result) {
         ASTContext *Context = Result.Context;
-        const ForStmt *FS = Result.Nodes.getStmtAs<ForStmt>("forLoop");
+        const ForStmt *FS = Result.Nodes.getNodeAs<ForStmt>("forLoop");
         // We do not want to convert header files!
-        if (!FS || !Context->getSourceManager().isFromMainFile(FS->getForLoc()))
+        if (!FS || !Context->getSourceManager().isWrittenInMainFile(FS->getForLoc()))
         const VarDecl *IncVar = Result.Nodes.getNodeAs<VarDecl>("incVarName");
         const VarDecl *CondVar = Result.Nodes.getNodeAs<VarDecl>("condVarName");

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28180.82735.patch
Type: text/x-patch
Size: 867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161230/dbfafff7/attachment.bin>

More information about the cfe-commits mailing list