xref: /freebsd/contrib/llvm-project/clang/include/clang-c/Rewrite.h (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1 /*===-- clang-c/Rewrite.h - C CXRewriter   --------------------------*- C -*-===*\
2 |*                                                                            *|
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
4 |* Exceptions.                                                                *|
5 |* See https://llvm.org/LICENSE.txt for license information.                  *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
7 |*                                                                            *|
8 |*===----------------------------------------------------------------------===*/
9 
10 #ifndef LLVM_CLANG_C_REWRITE_H
11 #define LLVM_CLANG_C_REWRITE_H
12 
13 #include "clang-c/CXString.h"
14 #include "clang-c/ExternC.h"
15 #include "clang-c/Index.h"
16 #include "clang-c/Platform.h"
17 
18 LLVM_CLANG_C_EXTERN_C_BEGIN
19 
20 typedef void *CXRewriter;
21 
22 /**
23  * Create CXRewriter.
24  */
25 CINDEX_LINKAGE CXRewriter clang_CXRewriter_create(CXTranslationUnit TU);
26 
27 /**
28  * Insert the specified string at the specified location in the original buffer.
29  */
30 CINDEX_LINKAGE void clang_CXRewriter_insertTextBefore(CXRewriter Rew, CXSourceLocation Loc,
31                                            const char *Insert);
32 
33 /**
34  * Replace the specified range of characters in the input with the specified
35  * replacement.
36  */
37 CINDEX_LINKAGE void clang_CXRewriter_replaceText(CXRewriter Rew, CXSourceRange ToBeReplaced,
38                                       const char *Replacement);
39 
40 /**
41  * Remove the specified range.
42  */
43 CINDEX_LINKAGE void clang_CXRewriter_removeText(CXRewriter Rew, CXSourceRange ToBeRemoved);
44 
45 /**
46  * Save all changed files to disk.
47  * Returns 1 if any files were not saved successfully, returns 0 otherwise.
48  */
49 CINDEX_LINKAGE int clang_CXRewriter_overwriteChangedFiles(CXRewriter Rew);
50 
51 /**
52  * Write out rewritten version of the main file to stdout.
53  */
54 CINDEX_LINKAGE void clang_CXRewriter_writeMainFileToStdOut(CXRewriter Rew);
55 
56 /**
57  * Free the given CXRewriter.
58  */
59 CINDEX_LINKAGE void clang_CXRewriter_dispose(CXRewriter Rew);
60 
61 LLVM_CLANG_C_EXTERN_C_END
62 
63 #endif
64