/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Frontend/Rewrite/RewriteTest.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- RewriteTest.cpp - Rewriter playground ----------------------------===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | // |
9 | | // This is a testbed. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #include "clang/Lex/Preprocessor.h" |
14 | | #include "clang/Rewrite/Core/TokenRewriter.h" |
15 | | #include "clang/Rewrite/Frontend/Rewriters.h" |
16 | | #include "llvm/Support/raw_ostream.h" |
17 | | |
18 | 0 | void clang::DoRewriteTest(Preprocessor &PP, raw_ostream *OS) { |
19 | 0 | SourceManager &SM = PP.getSourceManager(); |
20 | 0 | const LangOptions &LangOpts = PP.getLangOpts(); |
21 | |
|
22 | 0 | TokenRewriter Rewriter(SM.getMainFileID(), SM, LangOpts); |
23 | | |
24 | | // Throw <i> </i> tags around comments. |
25 | 0 | for (TokenRewriter::token_iterator I = Rewriter.token_begin(), |
26 | 0 | E = Rewriter.token_end(); I != E; ++I) { |
27 | 0 | if (I->isNot(tok::comment)) continue; |
28 | | |
29 | 0 | Rewriter.AddTokenBefore(I, "<i>"); |
30 | 0 | Rewriter.AddTokenAfter(I, "</i>"); |
31 | 0 | } |
32 | | |
33 | | |
34 | | // Print out the output. |
35 | 0 | for (TokenRewriter::token_iterator I = Rewriter.token_begin(), |
36 | 0 | E = Rewriter.token_end(); I != E; ++I) |
37 | 0 | *OS << PP.getSpelling(*I); |
38 | 0 | } |