├── .gitignore
├── LICENSE
├── README.md
├── fat-lib.sh
├── lib
└── libclang
│ ├── include
│ └── clang-c
│ │ ├── BuildSystem.h
│ │ ├── CXCompilationDatabase.h
│ │ ├── CXErrorCode.h
│ │ ├── CXString.h
│ │ ├── Documentation.h
│ │ ├── Index.h
│ │ ├── Platform.h
│ │ └── module.modulemap
│ └── lib
│ ├── .gitignore
│ ├── libclang-arm64.a
│ ├── libclang-armv7.a
│ ├── libclang-i386.a
│ └── libclang-x86_64.a
└── llvm-ios
├── README.md
├── patches
├── gtest-death-test-nsgetenviron.patch
├── lineeditor-histedit.patch
├── llvm-unittests-nsgetenviron.patch
└── support-unix-program-nsgetenviron.patch
└── scripts
├── apply-patches.sh
├── build.sh
├── clone.sh
├── fatty.sh
└── magic.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | llvm-ios/build
2 | llvm-ios/source
3 | llvm-ios/libclang
4 | llvm-ios/install
5 | clang-sample/libclang/lib
6 | # Xcode
7 | .DS_Store
8 | build/
9 | *.pbxuser
10 | !default.pbxuser
11 | *.mode1v3
12 | !default.mode1v3
13 | *.mode2v3
14 | !default.mode2v3
15 | *.perspectivev3
16 | !default.perspectivev3
17 | xcuserdata
18 | *.xcuserdatad
19 | profile
20 | *.moved-aside
21 | DerivedData
22 | .idea/
23 | *.mobileprovision
24 | *.p12
25 | *.xcuserstate
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 TopMonks, s.r.o.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Lot of questions how to build `libclang` for iOS and very few, not complete, answers.
2 | Here it is - kind of R&D project for `libclang` testing on iOS devices.
3 |
4 | ## Structure
5 |
6 | * `llvm-ios` - patches and scripts to build `libclang` from the source code
7 | * `lib` - ready to go binaries with header files
8 |
9 | ## Ready to go binaries
10 |
11 | I had to split `libclang.a` library to several pieces (per architecture), because
12 | of GitHub limitations (file size). Just issue `fat-lib.sh` to create fat `libclang.a`,
13 | which does support all architectures (armv7, arm64, i386 and x86_64).
14 |
15 | ## Contact
16 |
17 | Follow TopMonks on Twitter ([@topmonks](https://twitter.com/topmonks))
18 |
19 | ### Creator
20 |
21 | - [Robert Vojta](http://github.com/robertvojta) ([@robertvojta](https://twitter.com/robertvojta))
22 |
23 | ## License
24 |
25 | libclang-ios is released under the MIT license. See LICENSE for details.
26 |
--------------------------------------------------------------------------------
/fat-lib.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | SCRIPT_DIR="`dirname \"$0\"`"
4 | SCRIPT_DIR="`( cd \"$SCRIPT_DIR\" && pwd )`"
5 |
6 | LIB_DIR="$SCRIPT_DIR/lib/libclang/lib"
7 | lipo -create "$LIB_DIR/libclang-arm64.a" "$LIB_DIR/libclang-armv7.a" "$LIB_DIR/libclang-i386.a" "$LIB_DIR/libclang-x86_64.a" -output "$LIB_DIR/libclang.a"
8 |
--------------------------------------------------------------------------------
/lib/libclang/include/clang-c/BuildSystem.h:
--------------------------------------------------------------------------------
1 | /*==-- clang-c/BuildSystem.h - Utilities for use by build systems -*- C -*-===*\
2 | |* *|
3 | |* The LLVM Compiler Infrastructure *|
4 | |* *|
5 | |* This file is distributed under the University of Illinois Open Source *|
6 | |* License. See LICENSE.TXT for details. *|
7 | |* *|
8 | |*===----------------------------------------------------------------------===*|
9 | |* *|
10 | |* This header provides various utilities for use by build systems. *|
11 | |* *|
12 | \*===----------------------------------------------------------------------===*/
13 |
14 | #ifndef LLVM_CLANG_C_BUILDSYSTEM_H
15 | #define LLVM_CLANG_C_BUILDSYSTEM_H
16 |
17 | #include "clang-c/Platform.h"
18 | #include "clang-c/CXErrorCode.h"
19 | #include "clang-c/CXString.h"
20 |
21 | #ifdef __cplusplus
22 | extern "C" {
23 | #endif
24 |
25 | /**
26 | * \defgroup BUILD_SYSTEM Build system utilities
27 | * @{
28 | */
29 |
30 | /**
31 | * \brief Return the timestamp for use with Clang's
32 | * \c -fbuild-session-timestamp= option.
33 | */
34 | CINDEX_LINKAGE unsigned long long clang_getBuildSessionTimestamp(void);
35 |
36 | /**
37 | * \brief Object encapsulating information about overlaying virtual
38 | * file/directories over the real file system.
39 | */
40 | typedef struct CXVirtualFileOverlayImpl *CXVirtualFileOverlay;
41 |
42 | /**
43 | * \brief Create a \c CXVirtualFileOverlay object.
44 | * Must be disposed with \c clang_VirtualFileOverlay_dispose().
45 | *
46 | * \param options is reserved, always pass 0.
47 | */
48 | CINDEX_LINKAGE CXVirtualFileOverlay
49 | clang_VirtualFileOverlay_create(unsigned options);
50 |
51 | /**
52 | * \brief Map an absolute virtual file path to an absolute real one.
53 | * The virtual path must be canonicalized (not contain "."/"..").
54 | * \returns 0 for success, non-zero to indicate an error.
55 | */
56 | CINDEX_LINKAGE enum CXErrorCode
57 | clang_VirtualFileOverlay_addFileMapping(CXVirtualFileOverlay,
58 | const char *virtualPath,
59 | const char *realPath);
60 |
61 | /**
62 | * \brief Set the case sensitivity for the \c CXVirtualFileOverlay object.
63 | * The \c CXVirtualFileOverlay object is case-sensitive by default, this
64 | * option can be used to override the default.
65 | * \returns 0 for success, non-zero to indicate an error.
66 | */
67 | CINDEX_LINKAGE enum CXErrorCode
68 | clang_VirtualFileOverlay_setCaseSensitivity(CXVirtualFileOverlay,
69 | int caseSensitive);
70 |
71 | /**
72 | * \brief Write out the \c CXVirtualFileOverlay object to a char buffer.
73 | *
74 | * \param options is reserved, always pass 0.
75 | * \param out_buffer_ptr pointer to receive the buffer pointer, which should be
76 | * disposed using \c free().
77 | * \param out_buffer_size pointer to receive the buffer size.
78 | * \returns 0 for success, non-zero to indicate an error.
79 | */
80 | CINDEX_LINKAGE enum CXErrorCode
81 | clang_VirtualFileOverlay_writeToBuffer(CXVirtualFileOverlay, unsigned options,
82 | char **out_buffer_ptr,
83 | unsigned *out_buffer_size);
84 |
85 | /**
86 | * \brief Dispose a \c CXVirtualFileOverlay object.
87 | */
88 | CINDEX_LINKAGE void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay);
89 |
90 | /**
91 | * \brief Object encapsulating information about a module.map file.
92 | */
93 | typedef struct CXModuleMapDescriptorImpl *CXModuleMapDescriptor;
94 |
95 | /**
96 | * \brief Create a \c CXModuleMapDescriptor object.
97 | * Must be disposed with \c clang_ModuleMapDescriptor_dispose().
98 | *
99 | * \param options is reserved, always pass 0.
100 | */
101 | CINDEX_LINKAGE CXModuleMapDescriptor
102 | clang_ModuleMapDescriptor_create(unsigned options);
103 |
104 | /**
105 | * \brief Sets the framework module name that the module.map describes.
106 | * \returns 0 for success, non-zero to indicate an error.
107 | */
108 | CINDEX_LINKAGE enum CXErrorCode
109 | clang_ModuleMapDescriptor_setFrameworkModuleName(CXModuleMapDescriptor,
110 | const char *name);
111 |
112 | /**
113 | * \brief Sets the umbrealla header name that the module.map describes.
114 | * \returns 0 for success, non-zero to indicate an error.
115 | */
116 | CINDEX_LINKAGE enum CXErrorCode
117 | clang_ModuleMapDescriptor_setUmbrellaHeader(CXModuleMapDescriptor,
118 | const char *name);
119 |
120 | /**
121 | * \brief Write out the \c CXModuleMapDescriptor object to a char buffer.
122 | *
123 | * \param options is reserved, always pass 0.
124 | * \param out_buffer_ptr pointer to receive the buffer pointer, which should be
125 | * disposed using \c free().
126 | * \param out_buffer_size pointer to receive the buffer size.
127 | * \returns 0 for success, non-zero to indicate an error.
128 | */
129 | CINDEX_LINKAGE enum CXErrorCode
130 | clang_ModuleMapDescriptor_writeToBuffer(CXModuleMapDescriptor, unsigned options,
131 | char **out_buffer_ptr,
132 | unsigned *out_buffer_size);
133 |
134 | /**
135 | * \brief Dispose a \c CXModuleMapDescriptor object.
136 | */
137 | CINDEX_LINKAGE void clang_ModuleMapDescriptor_dispose(CXModuleMapDescriptor);
138 |
139 | /**
140 | * @}
141 | */
142 |
143 | #ifdef __cplusplus
144 | }
145 | #endif
146 |
147 | #endif /* CLANG_C_BUILD_SYSTEM_H */
148 |
149 |
--------------------------------------------------------------------------------
/lib/libclang/include/clang-c/CXCompilationDatabase.h:
--------------------------------------------------------------------------------
1 | /*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- C -*-===*\
2 | |* *|
3 | |* The LLVM Compiler Infrastructure *|
4 | |* *|
5 | |* This file is distributed under the University of Illinois Open Source *|
6 | |* License. See LICENSE.TXT for details. *|
7 | |* *|
8 | |*===----------------------------------------------------------------------===*|
9 | |* *|
10 | |* This header provides a public inferface to use CompilationDatabase without *|
11 | |* the full Clang C++ API. *|
12 | |* *|
13 | \*===----------------------------------------------------------------------===*/
14 |
15 | #ifndef LLVM_CLANG_C_CXCOMPILATIONDATABASE_H
16 | #define LLVM_CLANG_C_CXCOMPILATIONDATABASE_H
17 |
18 | #include "clang-c/Platform.h"
19 | #include "clang-c/CXString.h"
20 |
21 | #ifdef __cplusplus
22 | extern "C" {
23 | #endif
24 |
25 | /** \defgroup COMPILATIONDB CompilationDatabase functions
26 | * \ingroup CINDEX
27 | *
28 | * @{
29 | */
30 |
31 | /**
32 | * A compilation database holds all information used to compile files in a
33 | * project. For each file in the database, it can be queried for the working
34 | * directory or the command line used for the compiler invocation.
35 | *
36 | * Must be freed by \c clang_CompilationDatabase_dispose
37 | */
38 | typedef void * CXCompilationDatabase;
39 |
40 | /**
41 | * \brief Contains the results of a search in the compilation database
42 | *
43 | * When searching for the compile command for a file, the compilation db can
44 | * return several commands, as the file may have been compiled with
45 | * different options in different places of the project. This choice of compile
46 | * commands is wrapped in this opaque data structure. It must be freed by
47 | * \c clang_CompileCommands_dispose.
48 | */
49 | typedef void * CXCompileCommands;
50 |
51 | /**
52 | * \brief Represents the command line invocation to compile a specific file.
53 | */
54 | typedef void * CXCompileCommand;
55 |
56 | /**
57 | * \brief Error codes for Compilation Database
58 | */
59 | typedef enum {
60 | /*
61 | * \brief No error occurred
62 | */
63 | CXCompilationDatabase_NoError = 0,
64 |
65 | /*
66 | * \brief Database can not be loaded
67 | */
68 | CXCompilationDatabase_CanNotLoadDatabase = 1
69 |
70 | } CXCompilationDatabase_Error;
71 |
72 | /**
73 | * \brief Creates a compilation database from the database found in directory
74 | * buildDir. For example, CMake can output a compile_commands.json which can
75 | * be used to build the database.
76 | *
77 | * It must be freed by \c clang_CompilationDatabase_dispose.
78 | */
79 | CINDEX_LINKAGE CXCompilationDatabase
80 | clang_CompilationDatabase_fromDirectory(const char *BuildDir,
81 | CXCompilationDatabase_Error *ErrorCode);
82 |
83 | /**
84 | * \brief Free the given compilation database
85 | */
86 | CINDEX_LINKAGE void
87 | clang_CompilationDatabase_dispose(CXCompilationDatabase);
88 |
89 | /**
90 | * \brief Find the compile commands used for a file. The compile commands
91 | * must be freed by \c clang_CompileCommands_dispose.
92 | */
93 | CINDEX_LINKAGE CXCompileCommands
94 | clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase,
95 | const char *CompleteFileName);
96 |
97 | /**
98 | * \brief Get all the compile commands in the given compilation database.
99 | */
100 | CINDEX_LINKAGE CXCompileCommands
101 | clang_CompilationDatabase_getAllCompileCommands(CXCompilationDatabase);
102 |
103 | /**
104 | * \brief Free the given CompileCommands
105 | */
106 | CINDEX_LINKAGE void clang_CompileCommands_dispose(CXCompileCommands);
107 |
108 | /**
109 | * \brief Get the number of CompileCommand we have for a file
110 | */
111 | CINDEX_LINKAGE unsigned
112 | clang_CompileCommands_getSize(CXCompileCommands);
113 |
114 | /**
115 | * \brief Get the I'th CompileCommand for a file
116 | *
117 | * Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands)
118 | */
119 | CINDEX_LINKAGE CXCompileCommand
120 | clang_CompileCommands_getCommand(CXCompileCommands, unsigned I);
121 |
122 | /**
123 | * \brief Get the working directory where the CompileCommand was executed from
124 | */
125 | CINDEX_LINKAGE CXString
126 | clang_CompileCommand_getDirectory(CXCompileCommand);
127 |
128 | /**
129 | * \brief Get the number of arguments in the compiler invocation.
130 | *
131 | */
132 | CINDEX_LINKAGE unsigned
133 | clang_CompileCommand_getNumArgs(CXCompileCommand);
134 |
135 | /**
136 | * \brief Get the I'th argument value in the compiler invocations
137 | *
138 | * Invariant :
139 | * - argument 0 is the compiler executable
140 | */
141 | CINDEX_LINKAGE CXString
142 | clang_CompileCommand_getArg(CXCompileCommand, unsigned I);
143 |
144 | /**
145 | * \brief Get the number of source mappings for the compiler invocation.
146 | */
147 | CINDEX_LINKAGE unsigned
148 | clang_CompileCommand_getNumMappedSources(CXCompileCommand);
149 |
150 | /**
151 | * \brief Get the I'th mapped source path for the compiler invocation.
152 | */
153 | CINDEX_LINKAGE CXString
154 | clang_CompileCommand_getMappedSourcePath(CXCompileCommand, unsigned I);
155 |
156 | /**
157 | * \brief Get the I'th mapped source content for the compiler invocation.
158 | */
159 | CINDEX_LINKAGE CXString
160 | clang_CompileCommand_getMappedSourceContent(CXCompileCommand, unsigned I);
161 |
162 | /**
163 | * @}
164 | */
165 |
166 | #ifdef __cplusplus
167 | }
168 | #endif
169 | #endif
170 |
171 |
--------------------------------------------------------------------------------
/lib/libclang/include/clang-c/CXErrorCode.h:
--------------------------------------------------------------------------------
1 | /*===-- clang-c/CXErrorCode.h - C Index Error Codes --------------*- C -*-===*\
2 | |* *|
3 | |* The LLVM Compiler Infrastructure *|
4 | |* *|
5 | |* This file is distributed under the University of Illinois Open Source *|
6 | |* License. See LICENSE.TXT for details. *|
7 | |* *|
8 | |*===----------------------------------------------------------------------===*|
9 | |* *|
10 | |* This header provides the CXErrorCode enumerators. *|
11 | |* *|
12 | \*===----------------------------------------------------------------------===*/
13 |
14 | #ifndef LLVM_CLANG_C_CXERRORCODE_H
15 | #define LLVM_CLANG_C_CXERRORCODE_H
16 |
17 | #include "clang-c/Platform.h"
18 |
19 | #ifdef __cplusplus
20 | extern "C" {
21 | #endif
22 |
23 | /**
24 | * \brief Error codes returned by libclang routines.
25 | *
26 | * Zero (\c CXError_Success) is the only error code indicating success. Other
27 | * error codes, including not yet assigned non-zero values, indicate errors.
28 | */
29 | enum CXErrorCode {
30 | /**
31 | * \brief No error.
32 | */
33 | CXError_Success = 0,
34 |
35 | /**
36 | * \brief A generic error code, no further details are available.
37 | *
38 | * Errors of this kind can get their own specific error codes in future
39 | * libclang versions.
40 | */
41 | CXError_Failure = 1,
42 |
43 | /**
44 | * \brief libclang crashed while performing the requested operation.
45 | */
46 | CXError_Crashed = 2,
47 |
48 | /**
49 | * \brief The function detected that the arguments violate the function
50 | * contract.
51 | */
52 | CXError_InvalidArguments = 3,
53 |
54 | /**
55 | * \brief An AST deserialization error has occurred.
56 | */
57 | CXError_ASTReadError = 4
58 | };
59 |
60 | #ifdef __cplusplus
61 | }
62 | #endif
63 | #endif
64 |
65 |
--------------------------------------------------------------------------------
/lib/libclang/include/clang-c/CXString.h:
--------------------------------------------------------------------------------
1 | /*===-- clang-c/CXString.h - C Index strings --------------------*- C -*-===*\
2 | |* *|
3 | |* The LLVM Compiler Infrastructure *|
4 | |* *|
5 | |* This file is distributed under the University of Illinois Open Source *|
6 | |* License. See LICENSE.TXT for details. *|
7 | |* *|
8 | |*===----------------------------------------------------------------------===*|
9 | |* *|
10 | |* This header provides the interface to C Index strings. *|
11 | |* *|
12 | \*===----------------------------------------------------------------------===*/
13 |
14 | #ifndef LLVM_CLANG_C_CXSTRING_H
15 | #define LLVM_CLANG_C_CXSTRING_H
16 |
17 | #include "clang-c/Platform.h"
18 |
19 | #ifdef __cplusplus
20 | extern "C" {
21 | #endif
22 |
23 | /**
24 | * \defgroup CINDEX_STRING String manipulation routines
25 | * \ingroup CINDEX
26 | *
27 | * @{
28 | */
29 |
30 | /**
31 | * \brief A character string.
32 | *
33 | * The \c CXString type is used to return strings from the interface when
34 | * the ownership of that string might differ from one call to the next.
35 | * Use \c clang_getCString() to retrieve the string data and, once finished
36 | * with the string data, call \c clang_disposeString() to free the string.
37 | */
38 | typedef struct {
39 | const void *data;
40 | unsigned private_flags;
41 | } CXString;
42 |
43 | /**
44 | * \brief Retrieve the character data associated with the given string.
45 | */
46 | CINDEX_LINKAGE const char *clang_getCString(CXString string);
47 |
48 | /**
49 | * \brief Free the given string.
50 | */
51 | CINDEX_LINKAGE void clang_disposeString(CXString string);
52 |
53 | /**
54 | * @}
55 | */
56 |
57 | #ifdef __cplusplus
58 | }
59 | #endif
60 | #endif
61 |
62 |
--------------------------------------------------------------------------------
/lib/libclang/include/clang-c/Documentation.h:
--------------------------------------------------------------------------------
1 | /*==-- clang-c/Documentation.h - Utilities for comment processing -*- C -*-===*\
2 | |* *|
3 | |* The LLVM Compiler Infrastructure *|
4 | |* *|
5 | |* This file is distributed under the University of Illinois Open Source *|
6 | |* License. See LICENSE.TXT for details. *|
7 | |* *|
8 | |*===----------------------------------------------------------------------===*|
9 | |* *|
10 | |* This header provides a supplementary interface for inspecting *|
11 | |* documentation comments. *|
12 | |* *|
13 | \*===----------------------------------------------------------------------===*/
14 |
15 | #ifndef LLVM_CLANG_C_DOCUMENTATION_H
16 | #define LLVM_CLANG_C_DOCUMENTATION_H
17 |
18 | #include "clang-c/Index.h"
19 |
20 | #ifdef __cplusplus
21 | extern "C" {
22 | #endif
23 |
24 | /**
25 | * \defgroup CINDEX_COMMENT Comment introspection
26 | *
27 | * The routines in this group provide access to information in documentation
28 | * comments. These facilities are distinct from the core and may be subject to
29 | * their own schedule of stability and deprecation.
30 | *
31 | * @{
32 | */
33 |
34 | /**
35 | * \brief A parsed comment.
36 | */
37 | typedef struct {
38 | const void *ASTNode;
39 | CXTranslationUnit TranslationUnit;
40 | } CXComment;
41 |
42 | /**
43 | * \brief Given a cursor that represents a documentable entity (e.g.,
44 | * declaration), return the associated parsed comment as a
45 | * \c CXComment_FullComment AST node.
46 | */
47 | CINDEX_LINKAGE CXComment clang_Cursor_getParsedComment(CXCursor C);
48 |
49 | /**
50 | * \brief Describes the type of the comment AST node (\c CXComment). A comment
51 | * node can be considered block content (e. g., paragraph), inline content
52 | * (plain text) or neither (the root AST node).
53 | */
54 | enum CXCommentKind {
55 | /**
56 | * \brief Null comment. No AST node is constructed at the requested location
57 | * because there is no text or a syntax error.
58 | */
59 | CXComment_Null = 0,
60 |
61 | /**
62 | * \brief Plain text. Inline content.
63 | */
64 | CXComment_Text = 1,
65 |
66 | /**
67 | * \brief A command with word-like arguments that is considered inline content.
68 | *
69 | * For example: \\c command.
70 | */
71 | CXComment_InlineCommand = 2,
72 |
73 | /**
74 | * \brief HTML start tag with attributes (name-value pairs). Considered
75 | * inline content.
76 | *
77 | * For example:
78 | * \verbatim
79 | *
80 | * \endverbatim
81 | */
82 | CXComment_HTMLStartTag = 3,
83 |
84 | /**
85 | * \brief HTML end tag. Considered inline content.
86 | *
87 | * For example:
88 | * \verbatim
89 | *
90 | * \endverbatim
91 | */
92 | CXComment_HTMLEndTag = 4,
93 |
94 | /**
95 | * \brief A paragraph, contains inline comment. The paragraph itself is
96 | * block content.
97 | */
98 | CXComment_Paragraph = 5,
99 |
100 | /**
101 | * \brief A command that has zero or more word-like arguments (number of
102 | * word-like arguments depends on command name) and a paragraph as an
103 | * argument. Block command is block content.
104 | *
105 | * Paragraph argument is also a child of the block command.
106 | *
107 | * For example: \\brief has 0 word-like arguments and a paragraph argument.
108 | *
109 | * AST nodes of special kinds that parser knows about (e. g., \\param
110 | * command) have their own node kinds.
111 | */
112 | CXComment_BlockCommand = 6,
113 |
114 | /**
115 | * \brief A \\param or \\arg command that describes the function parameter
116 | * (name, passing direction, description).
117 | *
118 | * For example: \\param [in] ParamName description.
119 | */
120 | CXComment_ParamCommand = 7,
121 |
122 | /**
123 | * \brief A \\tparam command that describes a template parameter (name and
124 | * description).
125 | *
126 | * For example: \\tparam T description.
127 | */
128 | CXComment_TParamCommand = 8,
129 |
130 | /**
131 | * \brief A verbatim block command (e. g., preformatted code). Verbatim
132 | * block has an opening and a closing command and contains multiple lines of
133 | * text (\c CXComment_VerbatimBlockLine child nodes).
134 | *
135 | * For example:
136 | * \\verbatim
137 | * aaa
138 | * \\endverbatim
139 | */
140 | CXComment_VerbatimBlockCommand = 9,
141 |
142 | /**
143 | * \brief A line of text that is contained within a
144 | * CXComment_VerbatimBlockCommand node.
145 | */
146 | CXComment_VerbatimBlockLine = 10,
147 |
148 | /**
149 | * \brief A verbatim line command. Verbatim line has an opening command,
150 | * a single line of text (up to the newline after the opening command) and
151 | * has no closing command.
152 | */
153 | CXComment_VerbatimLine = 11,
154 |
155 | /**
156 | * \brief A full comment attached to a declaration, contains block content.
157 | */
158 | CXComment_FullComment = 12
159 | };
160 |
161 | /**
162 | * \brief The most appropriate rendering mode for an inline command, chosen on
163 | * command semantics in Doxygen.
164 | */
165 | enum CXCommentInlineCommandRenderKind {
166 | /**
167 | * \brief Command argument should be rendered in a normal font.
168 | */
169 | CXCommentInlineCommandRenderKind_Normal,
170 |
171 | /**
172 | * \brief Command argument should be rendered in a bold font.
173 | */
174 | CXCommentInlineCommandRenderKind_Bold,
175 |
176 | /**
177 | * \brief Command argument should be rendered in a monospaced font.
178 | */
179 | CXCommentInlineCommandRenderKind_Monospaced,
180 |
181 | /**
182 | * \brief Command argument should be rendered emphasized (typically italic
183 | * font).
184 | */
185 | CXCommentInlineCommandRenderKind_Emphasized
186 | };
187 |
188 | /**
189 | * \brief Describes parameter passing direction for \\param or \\arg command.
190 | */
191 | enum CXCommentParamPassDirection {
192 | /**
193 | * \brief The parameter is an input parameter.
194 | */
195 | CXCommentParamPassDirection_In,
196 |
197 | /**
198 | * \brief The parameter is an output parameter.
199 | */
200 | CXCommentParamPassDirection_Out,
201 |
202 | /**
203 | * \brief The parameter is an input and output parameter.
204 | */
205 | CXCommentParamPassDirection_InOut
206 | };
207 |
208 | /**
209 | * \param Comment AST node of any kind.
210 | *
211 | * \returns the type of the AST node.
212 | */
213 | CINDEX_LINKAGE enum CXCommentKind clang_Comment_getKind(CXComment Comment);
214 |
215 | /**
216 | * \param Comment AST node of any kind.
217 | *
218 | * \returns number of children of the AST node.
219 | */
220 | CINDEX_LINKAGE unsigned clang_Comment_getNumChildren(CXComment Comment);
221 |
222 | /**
223 | * \param Comment AST node of any kind.
224 | *
225 | * \param ChildIdx child index (zero-based).
226 | *
227 | * \returns the specified child of the AST node.
228 | */
229 | CINDEX_LINKAGE
230 | CXComment clang_Comment_getChild(CXComment Comment, unsigned ChildIdx);
231 |
232 | /**
233 | * \brief A \c CXComment_Paragraph node is considered whitespace if it contains
234 | * only \c CXComment_Text nodes that are empty or whitespace.
235 | *
236 | * Other AST nodes (except \c CXComment_Paragraph and \c CXComment_Text) are
237 | * never considered whitespace.
238 | *
239 | * \returns non-zero if \c Comment is whitespace.
240 | */
241 | CINDEX_LINKAGE unsigned clang_Comment_isWhitespace(CXComment Comment);
242 |
243 | /**
244 | * \returns non-zero if \c Comment is inline content and has a newline
245 | * immediately following it in the comment text. Newlines between paragraphs
246 | * do not count.
247 | */
248 | CINDEX_LINKAGE
249 | unsigned clang_InlineContentComment_hasTrailingNewline(CXComment Comment);
250 |
251 | /**
252 | * \param Comment a \c CXComment_Text AST node.
253 | *
254 | * \returns text contained in the AST node.
255 | */
256 | CINDEX_LINKAGE CXString clang_TextComment_getText(CXComment Comment);
257 |
258 | /**
259 | * \param Comment a \c CXComment_InlineCommand AST node.
260 | *
261 | * \returns name of the inline command.
262 | */
263 | CINDEX_LINKAGE
264 | CXString clang_InlineCommandComment_getCommandName(CXComment Comment);
265 |
266 | /**
267 | * \param Comment a \c CXComment_InlineCommand AST node.
268 | *
269 | * \returns the most appropriate rendering mode, chosen on command
270 | * semantics in Doxygen.
271 | */
272 | CINDEX_LINKAGE enum CXCommentInlineCommandRenderKind
273 | clang_InlineCommandComment_getRenderKind(CXComment Comment);
274 |
275 | /**
276 | * \param Comment a \c CXComment_InlineCommand AST node.
277 | *
278 | * \returns number of command arguments.
279 | */
280 | CINDEX_LINKAGE
281 | unsigned clang_InlineCommandComment_getNumArgs(CXComment Comment);
282 |
283 | /**
284 | * \param Comment a \c CXComment_InlineCommand AST node.
285 | *
286 | * \param ArgIdx argument index (zero-based).
287 | *
288 | * \returns text of the specified argument.
289 | */
290 | CINDEX_LINKAGE
291 | CXString clang_InlineCommandComment_getArgText(CXComment Comment,
292 | unsigned ArgIdx);
293 |
294 | /**
295 | * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
296 | * node.
297 | *
298 | * \returns HTML tag name.
299 | */
300 | CINDEX_LINKAGE CXString clang_HTMLTagComment_getTagName(CXComment Comment);
301 |
302 | /**
303 | * \param Comment a \c CXComment_HTMLStartTag AST node.
304 | *
305 | * \returns non-zero if tag is self-closing (for example, <br />).
306 | */
307 | CINDEX_LINKAGE
308 | unsigned clang_HTMLStartTagComment_isSelfClosing(CXComment Comment);
309 |
310 | /**
311 | * \param Comment a \c CXComment_HTMLStartTag AST node.
312 | *
313 | * \returns number of attributes (name-value pairs) attached to the start tag.
314 | */
315 | CINDEX_LINKAGE unsigned clang_HTMLStartTag_getNumAttrs(CXComment Comment);
316 |
317 | /**
318 | * \param Comment a \c CXComment_HTMLStartTag AST node.
319 | *
320 | * \param AttrIdx attribute index (zero-based).
321 | *
322 | * \returns name of the specified attribute.
323 | */
324 | CINDEX_LINKAGE
325 | CXString clang_HTMLStartTag_getAttrName(CXComment Comment, unsigned AttrIdx);
326 |
327 | /**
328 | * \param Comment a \c CXComment_HTMLStartTag AST node.
329 | *
330 | * \param AttrIdx attribute index (zero-based).
331 | *
332 | * \returns value of the specified attribute.
333 | */
334 | CINDEX_LINKAGE
335 | CXString clang_HTMLStartTag_getAttrValue(CXComment Comment, unsigned AttrIdx);
336 |
337 | /**
338 | * \param Comment a \c CXComment_BlockCommand AST node.
339 | *
340 | * \returns name of the block command.
341 | */
342 | CINDEX_LINKAGE
343 | CXString clang_BlockCommandComment_getCommandName(CXComment Comment);
344 |
345 | /**
346 | * \param Comment a \c CXComment_BlockCommand AST node.
347 | *
348 | * \returns number of word-like arguments.
349 | */
350 | CINDEX_LINKAGE
351 | unsigned clang_BlockCommandComment_getNumArgs(CXComment Comment);
352 |
353 | /**
354 | * \param Comment a \c CXComment_BlockCommand AST node.
355 | *
356 | * \param ArgIdx argument index (zero-based).
357 | *
358 | * \returns text of the specified word-like argument.
359 | */
360 | CINDEX_LINKAGE
361 | CXString clang_BlockCommandComment_getArgText(CXComment Comment,
362 | unsigned ArgIdx);
363 |
364 | /**
365 | * \param Comment a \c CXComment_BlockCommand or
366 | * \c CXComment_VerbatimBlockCommand AST node.
367 | *
368 | * \returns paragraph argument of the block command.
369 | */
370 | CINDEX_LINKAGE
371 | CXComment clang_BlockCommandComment_getParagraph(CXComment Comment);
372 |
373 | /**
374 | * \param Comment a \c CXComment_ParamCommand AST node.
375 | *
376 | * \returns parameter name.
377 | */
378 | CINDEX_LINKAGE
379 | CXString clang_ParamCommandComment_getParamName(CXComment Comment);
380 |
381 | /**
382 | * \param Comment a \c CXComment_ParamCommand AST node.
383 | *
384 | * \returns non-zero if the parameter that this AST node represents was found
385 | * in the function prototype and \c clang_ParamCommandComment_getParamIndex
386 | * function will return a meaningful value.
387 | */
388 | CINDEX_LINKAGE
389 | unsigned clang_ParamCommandComment_isParamIndexValid(CXComment Comment);
390 |
391 | /**
392 | * \param Comment a \c CXComment_ParamCommand AST node.
393 | *
394 | * \returns zero-based parameter index in function prototype.
395 | */
396 | CINDEX_LINKAGE
397 | unsigned clang_ParamCommandComment_getParamIndex(CXComment Comment);
398 |
399 | /**
400 | * \param Comment a \c CXComment_ParamCommand AST node.
401 | *
402 | * \returns non-zero if parameter passing direction was specified explicitly in
403 | * the comment.
404 | */
405 | CINDEX_LINKAGE
406 | unsigned clang_ParamCommandComment_isDirectionExplicit(CXComment Comment);
407 |
408 | /**
409 | * \param Comment a \c CXComment_ParamCommand AST node.
410 | *
411 | * \returns parameter passing direction.
412 | */
413 | CINDEX_LINKAGE
414 | enum CXCommentParamPassDirection clang_ParamCommandComment_getDirection(
415 | CXComment Comment);
416 |
417 | /**
418 | * \param Comment a \c CXComment_TParamCommand AST node.
419 | *
420 | * \returns template parameter name.
421 | */
422 | CINDEX_LINKAGE
423 | CXString clang_TParamCommandComment_getParamName(CXComment Comment);
424 |
425 | /**
426 | * \param Comment a \c CXComment_TParamCommand AST node.
427 | *
428 | * \returns non-zero if the parameter that this AST node represents was found
429 | * in the template parameter list and
430 | * \c clang_TParamCommandComment_getDepth and
431 | * \c clang_TParamCommandComment_getIndex functions will return a meaningful
432 | * value.
433 | */
434 | CINDEX_LINKAGE
435 | unsigned clang_TParamCommandComment_isParamPositionValid(CXComment Comment);
436 |
437 | /**
438 | * \param Comment a \c CXComment_TParamCommand AST node.
439 | *
440 | * \returns zero-based nesting depth of this parameter in the template parameter list.
441 | *
442 | * For example,
443 | * \verbatim
444 | * template class TT>
445 | * void test(TT aaa);
446 | * \endverbatim
447 | * for C and TT nesting depth is 0,
448 | * for T nesting depth is 1.
449 | */
450 | CINDEX_LINKAGE
451 | unsigned clang_TParamCommandComment_getDepth(CXComment Comment);
452 |
453 | /**
454 | * \param Comment a \c CXComment_TParamCommand AST node.
455 | *
456 | * \returns zero-based parameter index in the template parameter list at a
457 | * given nesting depth.
458 | *
459 | * For example,
460 | * \verbatim
461 | * template class TT>
462 | * void test(TT aaa);
463 | * \endverbatim
464 | * for C and TT nesting depth is 0, so we can ask for index at depth 0:
465 | * at depth 0 C's index is 0, TT's index is 1.
466 | *
467 | * For T nesting depth is 1, so we can ask for index at depth 0 and 1:
468 | * at depth 0 T's index is 1 (same as TT's),
469 | * at depth 1 T's index is 0.
470 | */
471 | CINDEX_LINKAGE
472 | unsigned clang_TParamCommandComment_getIndex(CXComment Comment, unsigned Depth);
473 |
474 | /**
475 | * \param Comment a \c CXComment_VerbatimBlockLine AST node.
476 | *
477 | * \returns text contained in the AST node.
478 | */
479 | CINDEX_LINKAGE
480 | CXString clang_VerbatimBlockLineComment_getText(CXComment Comment);
481 |
482 | /**
483 | * \param Comment a \c CXComment_VerbatimLine AST node.
484 | *
485 | * \returns text contained in the AST node.
486 | */
487 | CINDEX_LINKAGE CXString clang_VerbatimLineComment_getText(CXComment Comment);
488 |
489 | /**
490 | * \brief Convert an HTML tag AST node to string.
491 | *
492 | * \param Comment a \c CXComment_HTMLStartTag or \c CXComment_HTMLEndTag AST
493 | * node.
494 | *
495 | * \returns string containing an HTML tag.
496 | */
497 | CINDEX_LINKAGE CXString clang_HTMLTagComment_getAsString(CXComment Comment);
498 |
499 | /**
500 | * \brief Convert a given full parsed comment to an HTML fragment.
501 | *
502 | * Specific details of HTML layout are subject to change. Don't try to parse
503 | * this HTML back into an AST, use other APIs instead.
504 | *
505 | * Currently the following CSS classes are used:
506 | * \li "para-brief" for \\brief paragraph and equivalent commands;
507 | * \li "para-returns" for \\returns paragraph and equivalent commands;
508 | * \li "word-returns" for the "Returns" word in \\returns paragraph.
509 | *
510 | * Function argument documentation is rendered as a \ list with arguments
511 | * sorted in function prototype order. CSS classes used:
512 | * \li "param-name-index-NUMBER" for parameter name (\- );
513 | * \li "param-descr-index-NUMBER" for parameter description (\
- );
514 | * \li "param-name-index-invalid" and "param-descr-index-invalid" are used if
515 | * parameter index is invalid.
516 | *
517 | * Template parameter documentation is rendered as a \
list with
518 | * parameters sorted in template parameter list order. CSS classes used:
519 | * \li "tparam-name-index-NUMBER" for parameter name (\- );
520 | * \li "tparam-descr-index-NUMBER" for parameter description (\
- );
521 | * \li "tparam-name-index-other" and "tparam-descr-index-other" are used for
522 | * names inside template template parameters;
523 | * \li "tparam-name-index-invalid" and "tparam-descr-index-invalid" are used if
524 | * parameter position is invalid.
525 | *
526 | * \param Comment a \c CXComment_FullComment AST node.
527 | *
528 | * \returns string containing an HTML fragment.
529 | */
530 | CINDEX_LINKAGE CXString clang_FullComment_getAsHTML(CXComment Comment);
531 |
532 | /**
533 | * \brief Convert a given full parsed comment to an XML document.
534 | *
535 | * A Relax NG schema for the XML can be found in comment-xml-schema.rng file
536 | * inside clang source tree.
537 | *
538 | * \param Comment a \c CXComment_FullComment AST node.
539 | *
540 | * \returns string containing an XML document.
541 | */
542 | CINDEX_LINKAGE CXString clang_FullComment_getAsXML(CXComment Comment);
543 |
544 | /**
545 | * @}
546 | */
547 |
548 |
549 | #ifdef __cplusplus
550 | }
551 | #endif
552 |
553 | #endif /* CLANG_C_DOCUMENTATION_H */
554 |
555 |
--------------------------------------------------------------------------------
/lib/libclang/include/clang-c/Platform.h:
--------------------------------------------------------------------------------
1 | /*===-- clang-c/Platform.h - C Index platform decls -------------*- C -*-===*\
2 | |* *|
3 | |* The LLVM Compiler Infrastructure *|
4 | |* *|
5 | |* This file is distributed under the University of Illinois Open Source *|
6 | |* License. See LICENSE.TXT for details. *|
7 | |* *|
8 | |*===----------------------------------------------------------------------===*|
9 | |* *|
10 | |* This header provides platform specific macros (dllimport, deprecated, ...) *|
11 | |* *|
12 | \*===----------------------------------------------------------------------===*/
13 |
14 | #ifndef LLVM_CLANG_C_PLATFORM_H
15 | #define LLVM_CLANG_C_PLATFORM_H
16 |
17 | #ifdef __cplusplus
18 | extern "C" {
19 | #endif
20 |
21 | /* MSVC DLL import/export. */
22 | #ifdef _MSC_VER
23 | #ifdef _CINDEX_LIB_
24 | #define CINDEX_LINKAGE __declspec(dllexport)
25 | #else
26 | #define CINDEX_LINKAGE __declspec(dllimport)
27 | #endif
28 | #else
29 | #define CINDEX_LINKAGE
30 | #endif
31 |
32 | #ifdef __GNUC__
33 | #define CINDEX_DEPRECATED __attribute__((deprecated))
34 | #else
35 | #ifdef _MSC_VER
36 | #define CINDEX_DEPRECATED __declspec(deprecated)
37 | #else
38 | #define CINDEX_DEPRECATED
39 | #endif
40 | #endif
41 |
42 | #ifdef __cplusplus
43 | }
44 | #endif
45 | #endif
46 |
--------------------------------------------------------------------------------
/lib/libclang/include/clang-c/module.modulemap:
--------------------------------------------------------------------------------
1 | module Clang_C {
2 | umbrella "."
3 | module * { export * }
4 | }
5 |
--------------------------------------------------------------------------------
/lib/libclang/lib/.gitignore:
--------------------------------------------------------------------------------
1 | libclang.a
2 |
--------------------------------------------------------------------------------
/lib/libclang/lib/libclang-arm64.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/topmonks/libclang-ios/7e72a5bbd3e86334feabebb71404566c92f534da/lib/libclang/lib/libclang-arm64.a
--------------------------------------------------------------------------------
/lib/libclang/lib/libclang-armv7.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/topmonks/libclang-ios/7e72a5bbd3e86334feabebb71404566c92f534da/lib/libclang/lib/libclang-armv7.a
--------------------------------------------------------------------------------
/lib/libclang/lib/libclang-i386.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/topmonks/libclang-ios/7e72a5bbd3e86334feabebb71404566c92f534da/lib/libclang/lib/libclang-i386.a
--------------------------------------------------------------------------------
/lib/libclang/lib/libclang-x86_64.a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/topmonks/libclang-ios/7e72a5bbd3e86334feabebb71404566c92f534da/lib/libclang/lib/libclang-x86_64.a
--------------------------------------------------------------------------------
/llvm-ios/README.md:
--------------------------------------------------------------------------------
1 | ## Description
2 |
3 | Just issue `scripts/magic.sh` command to clone, patch, build and process fat
4 | (arm64, armv7, x86_64, i386) static `libclang` library and include files. Result can
5 | be found in `libclang` directory.
6 |
7 | ## Comments
8 |
9 | It's not perfect ...
10 |
11 | * it builds almost everything from llvm tree
12 | * it fails for random architecture sometimes, but everything needed for `libclang` was already compiled, not a big issue,
13 | * etc.
14 |
15 | ... but it builds what I need now.
16 |
17 | Feel free to fork, fix and provide pull request.
--------------------------------------------------------------------------------
/llvm-ios/patches/gtest-death-test-nsgetenviron.patch:
--------------------------------------------------------------------------------
1 | --- a/llvm/utils/unittest/googletest/src/gtest-death-test.cc 2015-03-05 10:04:00.000000000 +0100
2 | +++ b/llvm/utils/unittest/googletest/src/gtest-death-test.cc 2015-03-05 10:05:10.000000000 +0100
3 | @@ -36,10 +36,6 @@
4 |
5 | #if GTEST_HAS_DEATH_TEST
6 |
7 | -# if GTEST_OS_MAC
8 | -# include
9 | -# endif // GTEST_OS_MAC
10 | -
11 | # include
12 | # include
13 | # include
14 | @@ -882,20 +878,6 @@
15 | int close_fd; // File descriptor to close; the read end of a pipe
16 | };
17 |
18 | -# if GTEST_OS_MAC
19 | -inline char** GetEnviron() {
20 | - // When Google Test is built as a framework on MacOS X, the environ variable
21 | - // is unavailable. Apple's documentation (man environ) recommends using
22 | - // _NSGetEnviron() instead.
23 | - return *_NSGetEnviron();
24 | -}
25 | -# else
26 | -// Some POSIX platforms expect you to declare environ. extern "C" makes
27 | -// it reside in the global namespace.
28 | -extern "C" char** environ;
29 | -inline char** GetEnviron() { return environ; }
30 | -# endif // GTEST_OS_MAC
31 | -
32 | // The main function for a threadsafe-style death test child process.
33 | // This function is called in a clone()-ed process and thus must avoid
34 | // any potentially unsafe operations like malloc or libc functions.
35 | @@ -921,7 +903,7 @@
36 | // unsafe. Since execve() doesn't search the PATH, the user must
37 | // invoke the test program via a valid path that contains at least
38 | // one path separator.
39 | - execve(args->argv[0], args->argv, GetEnviron());
40 | + execve(args->argv[0], args->argv, NULL);
41 | DeathTestAbort(String::Format("execve(%s, ...) in %s failed: %s",
42 | args->argv[0],
43 | original_dir,
44 |
--------------------------------------------------------------------------------
/llvm-ios/patches/lineeditor-histedit.patch:
--------------------------------------------------------------------------------
1 | --- a/llvm/lib/LineEditor/LineEditor.cpp 2015-03-05 10:30:33.000000000 +0100
2 | +++ b/llvm/lib/LineEditor/LineEditor.cpp 2015-03-05 10:31:38.000000000 +0100
3 | @@ -13,9 +13,6 @@
4 | #include "llvm/Support/Path.h"
5 | #include "llvm/Support/raw_ostream.h"
6 | #include
7 | -#ifdef HAVE_LIBEDIT
8 | -#include
9 | -#endif
10 |
11 | using namespace llvm;
12 |
13 | @@ -90,187 +87,6 @@
14 | return Completer->complete(Buffer, Pos);
15 | }
16 |
17 | -#ifdef HAVE_LIBEDIT
18 | -
19 | -// libedit-based implementation.
20 | -
21 | -struct LineEditor::InternalData {
22 | - LineEditor *LE;
23 | -
24 | - History *Hist;
25 | - EditLine *EL;
26 | -
27 | - unsigned PrevCount;
28 | - std::string ContinuationOutput;
29 | -
30 | - FILE *Out;
31 | -};
32 | -
33 | -static const char *ElGetPromptFn(EditLine *EL) {
34 | - LineEditor::InternalData *Data;
35 | - if (el_get(EL, EL_CLIENTDATA, &Data) == 0)
36 | - return Data->LE->getPrompt().c_str();
37 | - return "> ";
38 | -}
39 | -
40 | -// Handles tab completion.
41 | -//
42 | -// This function is really horrible. But since the alternative is to get into
43 | -// the line editor business, here we are.
44 | -static unsigned char ElCompletionFn(EditLine *EL, int ch) {
45 | - LineEditor::InternalData *Data;
46 | - if (el_get(EL, EL_CLIENTDATA, &Data) == 0) {
47 | - if (!Data->ContinuationOutput.empty()) {
48 | - // This is the continuation of the AK_ShowCompletions branch below.
49 | - FILE *Out = Data->Out;
50 | -
51 | - // Print the required output (see below).
52 | - ::fwrite(Data->ContinuationOutput.c_str(),
53 | - Data->ContinuationOutput.size(), 1, Out);
54 | -
55 | - // Push a sequence of Ctrl-B characters to move the cursor back to its
56 | - // original position.
57 | - std::string Prevs(Data->PrevCount, '\02');
58 | - ::el_push(EL, const_cast(Prevs.c_str()));
59 | -
60 | - Data->ContinuationOutput.clear();
61 | -
62 | - return CC_REFRESH;
63 | - }
64 | -
65 | - const LineInfo *LI = ::el_line(EL);
66 | - LineEditor::CompletionAction Action = Data->LE->getCompletionAction(
67 | - StringRef(LI->buffer, LI->lastchar - LI->buffer),
68 | - LI->cursor - LI->buffer);
69 | - switch (Action.Kind) {
70 | - case LineEditor::CompletionAction::AK_Insert:
71 | - ::el_insertstr(EL, Action.Text.c_str());
72 | - return CC_REFRESH;
73 | -
74 | - case LineEditor::CompletionAction::AK_ShowCompletions:
75 | - if (Action.Completions.empty()) {
76 | - return CC_REFRESH_BEEP;
77 | - } else {
78 | - // Push a Ctrl-E and a tab. The Ctrl-E causes libedit to move the cursor
79 | - // to the end of the line, so that when we emit a newline we will be on
80 | - // a new blank line. The tab causes libedit to call this function again
81 | - // after moving the cursor. There doesn't seem to be anything we can do
82 | - // from here to cause libedit to move the cursor immediately. This will
83 | - // break horribly if the user has rebound their keys, so for now we do
84 | - // not permit user rebinding.
85 | - ::el_push(EL, const_cast("\05\t"));
86 | -
87 | - // This assembles the output for the continuation block above.
88 | - raw_string_ostream OS(Data->ContinuationOutput);
89 | -
90 | - // Move cursor to a blank line.
91 | - OS << "\n";
92 | -
93 | - // Emit the completions.
94 | - for (std::vector::iterator I = Action.Completions.begin(),
95 | - E = Action.Completions.end();
96 | - I != E; ++I) {
97 | - OS << *I << "\n";
98 | - }
99 | -
100 | - // Fool libedit into thinking nothing has changed. Reprint its prompt
101 | - // and the user input. Note that the cursor will remain at the end of
102 | - // the line after this.
103 | - OS << Data->LE->getPrompt()
104 | - << StringRef(LI->buffer, LI->lastchar - LI->buffer);
105 | -
106 | - // This is the number of characters we need to tell libedit to go back:
107 | - // the distance between end of line and the original cursor position.
108 | - Data->PrevCount = LI->lastchar - LI->cursor;
109 | -
110 | - return CC_REFRESH;
111 | - }
112 | - }
113 | - }
114 | - return CC_ERROR;
115 | -}
116 | -
117 | -LineEditor::LineEditor(StringRef ProgName, StringRef HistoryPath, FILE *In,
118 | - FILE *Out, FILE *Err)
119 | - : Prompt((ProgName + "> ").str()), HistoryPath(HistoryPath),
120 | - Data(new InternalData) {
121 | - if (HistoryPath.empty())
122 | - this->HistoryPath = getDefaultHistoryPath(ProgName);
123 | -
124 | - Data->LE = this;
125 | - Data->Out = Out;
126 | -
127 | - Data->Hist = ::history_init();
128 | - assert(Data->Hist);
129 | -
130 | - Data->EL = ::el_init(ProgName.str().c_str(), In, Out, Err);
131 | - assert(Data->EL);
132 | -
133 | - ::el_set(Data->EL, EL_PROMPT, ElGetPromptFn);
134 | - ::el_set(Data->EL, EL_EDITOR, "emacs");
135 | - ::el_set(Data->EL, EL_HIST, history, Data->Hist);
136 | - ::el_set(Data->EL, EL_ADDFN, "tab_complete", "Tab completion function",
137 | - ElCompletionFn);
138 | - ::el_set(Data->EL, EL_BIND, "\t", "tab_complete", NULL);
139 | - ::el_set(Data->EL, EL_BIND, "^r", "em-inc-search-prev",
140 | - NULL); // Cycle through backwards search, entering string
141 | - ::el_set(Data->EL, EL_BIND, "^w", "ed-delete-prev-word",
142 | - NULL); // Delete previous word, behave like bash does.
143 | - ::el_set(Data->EL, EL_BIND, "\033[3~", "ed-delete-next-char",
144 | - NULL); // Fix the delete key.
145 | - ::el_set(Data->EL, EL_CLIENTDATA, Data.get());
146 | -
147 | - HistEvent HE;
148 | - ::history(Data->Hist, &HE, H_SETSIZE, 800);
149 | - ::history(Data->Hist, &HE, H_SETUNIQUE, 1);
150 | - loadHistory();
151 | -}
152 | -
153 | -LineEditor::~LineEditor() {
154 | - saveHistory();
155 | -
156 | - ::history_end(Data->Hist);
157 | - ::el_end(Data->EL);
158 | - ::fwrite("\n", 1, 1, Data->Out);
159 | -}
160 | -
161 | -void LineEditor::saveHistory() {
162 | - if (!HistoryPath.empty()) {
163 | - HistEvent HE;
164 | - ::history(Data->Hist, &HE, H_SAVE, HistoryPath.c_str());
165 | - }
166 | -}
167 | -
168 | -void LineEditor::loadHistory() {
169 | - if (!HistoryPath.empty()) {
170 | - HistEvent HE;
171 | - ::history(Data->Hist, &HE, H_LOAD, HistoryPath.c_str());
172 | - }
173 | -}
174 | -
175 | -Optional LineEditor::readLine() const {
176 | - // Call el_gets to prompt the user and read the user's input.
177 | - int LineLen = 0;
178 | - const char *Line = ::el_gets(Data->EL, &LineLen);
179 | -
180 | - // Either of these may mean end-of-file.
181 | - if (!Line || LineLen == 0)
182 | - return Optional();
183 | -
184 | - // Strip any newlines off the end of the string.
185 | - while (LineLen > 0 &&
186 | - (Line[LineLen - 1] == '\n' || Line[LineLen - 1] == '\r'))
187 | - --LineLen;
188 | -
189 | - HistEvent HE;
190 | - if (LineLen > 0)
191 | - ::history(Data->Hist, &HE, H_ENTER, Line);
192 | -
193 | - return std::string(Line, LineLen);
194 | -}
195 | -
196 | -#else
197 | -
198 | // Simple fgets-based implementation.
199 |
200 | struct LineEditor::InternalData {
201 | @@ -316,4 +132,3 @@
202 | return Line;
203 | }
204 |
205 | -#endif
206 |
--------------------------------------------------------------------------------
/llvm-ios/patches/llvm-unittests-nsgetenviron.patch:
--------------------------------------------------------------------------------
1 | --- a/llvm/unittests/Support/ProgramTest.cpp 2015-03-05 11:00:55.000000000 +0100
2 | +++ b/llvm/unittests/Support/ProgramTest.cpp 2015-03-05 11:01:31.000000000 +0100
3 | @@ -13,12 +13,6 @@
4 | #include "llvm/Support/Program.h"
5 | #include "gtest/gtest.h"
6 | #include
7 | -#if defined(__APPLE__)
8 | -# include
9 | -#elif !defined(_MSC_VER)
10 | -// Forward declare environ in case it's not provided by stdlib.h.
11 | -extern char **environ;
12 | -#endif
13 |
14 | #if defined(LLVM_ON_UNIX)
15 | #include
16 | @@ -58,16 +52,6 @@
17 | ProgramTestStringArg2("program-test-string-arg2");
18 |
19 | static void CopyEnvironment(std::vector &out) {
20 | -#ifdef __APPLE__
21 | - char **envp = *_NSGetEnviron();
22 | -#else
23 | - // environ seems to work for Windows and most other Unices.
24 | - char **envp = environ;
25 | -#endif
26 | - while (*envp != nullptr) {
27 | - out.push_back(*envp);
28 | - ++envp;
29 | - }
30 | }
31 |
32 | #ifdef LLVM_ON_WIN32
33 |
--------------------------------------------------------------------------------
/llvm-ios/patches/support-unix-program-nsgetenviron.patch:
--------------------------------------------------------------------------------
1 | --- a/llvm/lib/Support/Unix/Program.inc 2015-03-05 09:57:56.000000000 +0100
2 | +++ b/llvm/lib/Support/Unix/Program.inc 2015-03-05 09:59:36.000000000 +0100
3 | @@ -42,11 +42,7 @@
4 | #define _RESTRICT_KYWD
5 | #endif
6 | #include
7 | -#if !defined(__APPLE__)
8 | - extern char **environ;
9 | -#else
10 | -#include // _NSGetEnviron
11 | -#endif
12 | +extern char **environ;
13 | #endif
14 |
15 | namespace llvm {
16 | @@ -216,20 +212,12 @@
17 | }
18 | }
19 |
20 | - if (!envp)
21 | -#if !defined(__APPLE__)
22 | - envp = const_cast(environ);
23 | -#else
24 | - // environ is missing in dylibs.
25 | - envp = const_cast(*_NSGetEnviron());
26 | -#endif
27 | -
28 | // Explicitly initialized to prevent what appears to be a valgrind false
29 | // positive.
30 | pid_t PID = 0;
31 | int Err = posix_spawn(&PID, Program.str().c_str(), FileActions,
32 | /*attrp*/nullptr, const_cast(args),
33 | - const_cast(envp));
34 | + NULL);
35 |
36 | if (FileActions)
37 | posix_spawn_file_actions_destroy(FileActions);
38 |
--------------------------------------------------------------------------------
/llvm-ios/scripts/apply-patches.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | SCRIPT_DIR="`dirname \"$0\"`"
4 | SCRIPT_DIR="`( cd \"$SCRIPT_DIR\" && pwd )`"
5 |
6 | SOURCE_DIR="$SCRIPT_DIR/../source"
7 | PATCHES_DIR="$SCRIPT_DIR/../patches"
8 |
9 | find "$PATCHES_DIR" -name *.patch -exec patch -d "$SOURCE_DIR" -p1 -i {} \;
10 |
--------------------------------------------------------------------------------
/llvm-ios/scripts/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Based on:
5 | # https://gist.github.com/SquaredTiki/d5da9d1c1ee78a587c76
6 | #
7 |
8 | SYSROOT_SIM="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk"
9 | SYSROOT_OS="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk"
10 | MIN_VERSION="8.0"
11 |
12 | SCRIPT_DIR="`dirname \"$0\"`"
13 | SCRIPT_DIR="`( cd \"$SCRIPT_DIR\" && pwd )`"
14 | SOURCE_DIR="$SCRIPT_DIR/../source"
15 | LLVM_DIR="$SOURCE_DIR/llvm"
16 |
17 | BUILD_DIR="$SCRIPT_DIR/../build"
18 | INSTALL_DIR="$SCRIPT_DIR/../install"
19 |
20 | function build_clang_for_arch {
21 | local ARCH="$1"
22 | local HOST="$2"
23 | local IOS_MIN_ARG="$3"
24 | local SYSROOT="$4"
25 |
26 | local PREFIX_DIR="$INSTALL_DIR/$ARCH"
27 | rm -rf "$PREFIX_DIR"
28 | mkdir -p "$PREFIX_DIR"
29 |
30 | export CC="clang -arch $ARCH $IOS_MIN_ARG -isysroot $SYSROOT -stdlib=libc++ -Os"
31 | export CXX="clang++ -arch $ARCH $IOS_MIN_ARG -isysroot $SYSROOT -stdlib=libc++ -Os"
32 |
33 | rm -rf "$BUILD_DIR"
34 | mkdir -p "$BUILD_DIR"
35 | cd "$BUILD_DIR"
36 | pwd
37 | "$LLVM_DIR/configure" \
38 | --prefix="$PREFIX_DIR" \
39 | --host="$HOST" \
40 | --enable-optimized \
41 | --disable-assertions \
42 | --disable-debug
43 |
44 | unset CC CXX
45 |
46 | make DEPLOYMENT_TARGET="$IOS_MIN_ARG" VERBOSE=1 -j4
47 | make install
48 | }
49 |
50 | build_clang_for_arch "armv7" "arm-apple-darwin11" "-mios-version-min=$MIN_VERSION" "$SYSROOT_OS"
51 | build_clang_for_arch "arm64" "arm-apple-darwin11" "-mios-version-min=$MIN_VERSION" "$SYSROOT_OS"
52 | build_clang_for_arch "x86_64" "x86_64-apple-darwin11" "-mios-simulator-version-min=$MIN_VERSION" "$SYSROOT_SIM"
53 | build_clang_for_arch "i386" "i386-apple-darwin11" "-mios-simulator-version-min=$MIN_VERSION" "$SYSROOT_SIM"
54 |
--------------------------------------------------------------------------------
/llvm-ios/scripts/clone.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | LLVM_BRANCH=release_36
4 | CLANG_BRANCH=release_36
5 | COMPILER_RT_BRANCH=release_36
6 | MAX_DEPTH=1
7 |
8 | SCRIPT_DIR="`dirname \"$0\"`"
9 | SCRIPT_DIR="`( cd \"$SCRIPT_DIR\" && pwd )`"
10 |
11 | SOURCE_DIR="$SCRIPT_DIR/../source"
12 | rm -rf "$SOURCE_DIR"
13 | mkdir -p "$SOURCE_DIR"
14 |
15 | git clone -b $LLVM_BRANCH --depth $MAX_DEPTH http://llvm.org/git/llvm.git "$SOURCE_DIR/llvm"
16 | git clone -b $CLANG_BRANCH --depth $MAX_DEPTH http://llvm.org/git/clang.git "$SOURCE_DIR/llvm/tools/clang"
17 | git clone -b $COMPILER_RT_BRANCH --depth $MAX_DEPTH http://llvm.org/git/compiler-rt.git "$SOURCE_DIR/llvm/projects/compiler-rt"
18 |
--------------------------------------------------------------------------------
/llvm-ios/scripts/fatty.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | SCRIPT_DIR="`dirname \"$0\"`"
4 | SCRIPT_DIR="`( cd \"$SCRIPT_DIR\" && pwd )`"
5 |
6 | INSTALL_DIR="$SCRIPT_DIR/../install"
7 |
8 | LIB_DIR="$SCRIPT_DIR/../libclang/lib"
9 | HEADERS_DIR="$SCRIPT_DIR/../libclang/include/clang-c"
10 |
11 | rm -rf "$OUTPUT_DIR"
12 | mkdir -p "$LIB_DIR"
13 | mkdir -p "$HEADERS_DIR"
14 |
15 | function create_libclang_for_arch {
16 | ARCH=$1
17 | ILD="$INSTALL_DIR/$ARCH/lib/"
18 | libtool -static -o "$LIB_DIR/libclang-$ARCH.a" \
19 | "$ILD/libclang.a" \
20 | "$ILD/libclangARCMigrate.a" \
21 | "$ILD/libclangAST.a" \
22 | "$ILD/libclangASTMatchers.a" \
23 | "$ILD/libclangAnalysis.a" \
24 | "$ILD/libclangBasic.a" \
25 | "$ILD/libclangCodeGen.a" \
26 | "$ILD/libclangDriver.a" \
27 | "$ILD/libclangDynamicASTMatchers.a" \
28 | "$ILD/libclangEdit.a" \
29 | "$ILD/libclangFormat.a" \
30 | "$ILD/libclangFrontend.a" \
31 | "$ILD/libclangFrontendTool.a" \
32 | "$ILD/libclangIndex.a" \
33 | "$ILD/libclangLex.a" \
34 | "$ILD/libclangParse.a" \
35 | "$ILD/libclangRewrite.a" \
36 | "$ILD/libclangRewriteFrontend.a" \
37 | "$ILD/libclangSema.a" \
38 | "$ILD/libclangSerialization.a" \
39 | "$ILD/libclangStaticAnalyzerCheckers.a" \
40 | "$ILD/libclangStaticAnalyzerCore.a" \
41 | "$ILD/libclangStaticAnalyzerFrontend.a" \
42 | "$ILD/libclangTooling.a" \
43 | "$ILD/libclangToolingCore.a" \
44 | "$ILD/libLLVMAnalysis.a" \
45 | "$ILD/libLLVMSupport.a" \
46 | "$ILD/libLLVMInstCombine.a" \
47 | "$ILD/libLLVMCore.a" \
48 | "$ILD/libLLVMOption.a" \
49 | "$ILD/libLLVMBitReader.a" \
50 | "$ILD/libLLVMMC.a" \
51 | "$ILD/libLLVMMCParser.a"
52 | }
53 |
54 | create_libclang_for_arch "arm64"
55 | create_libclang_for_arch "armv7"
56 | create_libclang_for_arch "x86_64"
57 | create_libclang_for_arch "i386"
58 |
59 | lipo -create "$LIB_DIR/libclang-arm64.a" "$LIB_DIR/libclang-armv7.a" "$LIB_DIR/libclang-i386.a" "$LIB_DIR/libclang-x86_64.a" -output "$LIB_DIR/libclang.a"
60 |
61 | cp "$INSTALL_DIR/armv7/include/clang-c/"* "$HEADERS_DIR"
62 |
63 | ls -la "$HEADERS_DIR"
64 | lipo -info "$LIB_DIR/libclang.a"
65 |
66 |
67 |
--------------------------------------------------------------------------------
/llvm-ios/scripts/magic.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | SCRIPT_DIR="`dirname \"$0\"`"
4 | SCRIPT_DIR="`( cd \"$SCRIPT_DIR\" && pwd )`"
5 | echo "$(tput setab 4) Cloning the necessary projects... $(tput sgr0)"
6 | "$SCRIPT_DIR/clone.sh"
7 | echo "$(tput setab 4) Applyig the needed patches... $(tput sgr0)"
8 | "$SCRIPT_DIR/apply-patches.sh"
9 | echo "$(tput setab 4) Building libclang... $(tput sgr0)"
10 | "$SCRIPT_DIR/build.sh"
11 | echo "$(tput setab 4) Generating a fatty static library... $(tput sgr0)"
12 | "$SCRIPT_DIR/fatty.sh"
13 | echo "$(tput setab 4) And we are done $(tput sgr0)"
14 |
--------------------------------------------------------------------------------