• Home
  • Raw
  • Download

Lines Matching +full:fs +full:- +full:extra

5 This document is intended to show how to build a useful source-to-source
24 .. code-block:: console
26 mkdir ~/clang-llvm && cd ~/clang-llvm
31 git clone http://llvm.org/git/clang-tools-extra.git extra
37 .. code-block:: console
39 cd ~/clang-llvm
46 cd ~/clang-llvm
56 .. code-block:: console
58 cd ~/clang-llvm
60 cmake -G Ninja ../llvm -DLLVM_BUILD_TESTS=ON # Enable tests; default is off.
63 ninja clang-test # Test Clang only.
74 .. code-block:: console
76 cd ~/clang-llvm/build
92 already exists as ``clang-check``, it's important to understand what's
97 live in the ``tools/extra`` repository.
99 .. code-block:: console
101 cd ~/clang-llvm/llvm/tools/clang
102 mkdir tools/extra/loop-convert
103 echo 'add_subdirectory(loop-convert)' >> tools/extra/CMakeLists.txt
104 vim tools/extra/loop-convert/CMakeLists.txt
112 add_clang_executable(loop-convert
115 target_link_libraries(loop-convert
123 ``tools/extra/loop-convert/LoopConvert.cpp``. A detailed explanation of
127 .. code-block:: c++
139 // Apply a custom category to all command-line options so that they are the
141 static llvm::cl::OptionCategory MyToolCategory("my-tool options");
144 // command-line options related to the compilation database and input files.
161 .. code-block:: console
163 cd ~/clang-llvm/build
167 ``~/clang-llvm/build/bin``, on any source file. Try it!
169 .. code-block:: console
172 bin/loop-convert test.cpp --
176 them from a compilation database - there just aren't any options needed
194 .. code-block:: c++
215 .. code-block:: c++
226 .. code-block:: c++
233 .. code-block:: c++
240 .. code-block:: c++
255 .. code-block:: c++
268 .. code-block:: c++
283 if (const ForStmt *FS = Result.Nodes.getNodeAs<clang::ForStmt>("forLoop"))
284 FS->dump();
290 .. code-block:: c++
308 .. code-block:: console
310 cd ~/clang-llvm/llvm/llvm_build/
311 ninja loop-convert
312 vim ~/test-files/simple-loops.cc
313 bin/loop-convert ~/test-files/simple-loops.cc
324 for translation to range-based syntax? Range based loops over arrays of
327 - start at index ``0``
328 - iterate consecutively
329 - end at index ``N-1``
335 require a pre- or post-increment of the same variable declared in the
341 would like to allow, and punting extra comparisons to the callback.
343 In any case, we can start building this sub-matcher. We can require that
346 .. code-block:: c++
356 .. code-block:: c++
365 .. code-block:: c++
374 .. code-block:: c++
388 only one problem - we don't know which array we're iterating over
393 .. code-block:: c++
397 It makes sense to ensure that the left-hand side is a reference to a
398 variable, and that the right-hand side has integer type.
400 .. code-block:: c++
408 ``test-files/simple.cpp``, zero of them have a matching condition. A
410 previous iteration of loop-convert, shows us the answer:
430 applied to the first operand (i.e. the LHS) of the less-than operator,
431 an L-value to R-value conversion applied to the expression referencing
437 .. code-block:: c++
446 extracting the identifier strings into variables, we have array-step-2
471 .. code-block:: c++
477 .. code-block:: c++
495 .. code-block:: c++
499 const ForStmt *FS = Result.Nodes.getStmtAs<ForStmt>("forLoop");
501 if (!FS || !Context->getSourceManager().isFromMainFile(FS->getForLoc()))
509 llvm::outs() << "Potential array-based loop discovered.\n";
517 .. code-block:: c++
521 First->getCanonicalDecl() == Second->getCanonicalDecl();
527 .. code-block:: c++
539 .. code-block:: c++
546 First->Profile(FirstID, *Context, true);
547 Second->Profile(SecondID, *Context, true);
558 test-files/simple.cpp, try to figure out which ones will be considered