Skip to content

Commit c25ed8d

Browse files
committed
make the screader can work on the clang-10
1 parent a7a3274 commit c25ed8d

13 files changed

+7025
-153
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
22
PROJECT(scread)
33

44
ADD_EXECUTABLE(scread scread.c)
5-
INCLUDE_DIRECTORIES(./clang-c/)
5+
INCLUDE_DIRECTORIES(./include/)
66

77
#Need to do more about find library#
88
FIND_LIBRARY(LIBCLANG_PATH clang HINTS /usr/local/lib/)
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
11
/*==-- clang-c/BuildSystem.h - Utilities for use by build systems -*- C -*-===*\
22
|* *|
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. *|
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 *|
77
|* *|
88
|*===----------------------------------------------------------------------===*|
99
|* *|
1010
|* This header provides various utilities for use by build systems. *|
1111
|* *|
1212
\*===----------------------------------------------------------------------===*/
1313

14-
#ifndef CLANG_C_BUILD_SYSTEM_H
15-
#define CLANG_C_BUILD_SYSTEM_H
14+
#ifndef LLVM_CLANG_C_BUILDSYSTEM_H
15+
#define LLVM_CLANG_C_BUILDSYSTEM_H
1616

17-
#include "clang-c/Platform.h"
1817
#include "clang-c/CXErrorCode.h"
1918
#include "clang-c/CXString.h"
19+
#include "clang-c/ExternC.h"
20+
#include "clang-c/Platform.h"
2021

21-
#ifdef __cplusplus
22-
extern "C" {
23-
#endif
22+
LLVM_CLANG_C_EXTERN_C_BEGIN
2423

2524
/**
2625
* \defgroup BUILD_SYSTEM Build system utilities
2726
* @{
2827
*/
2928

3029
/**
31-
* \brief Return the timestamp for use with Clang's
30+
* Return the timestamp for use with Clang's
3231
* \c -fbuild-session-timestamp= option.
3332
*/
3433
CINDEX_LINKAGE unsigned long long clang_getBuildSessionTimestamp(void);
3534

3635
/**
37-
* \brief Object encapsulating information about overlaying virtual
36+
* Object encapsulating information about overlaying virtual
3837
* file/directories over the real file system.
3938
*/
4039
typedef struct CXVirtualFileOverlayImpl *CXVirtualFileOverlay;
4140

4241
/**
43-
* \brief Create a \c CXVirtualFileOverlay object.
42+
* Create a \c CXVirtualFileOverlay object.
4443
* Must be disposed with \c clang_VirtualFileOverlay_dispose().
4544
*
4645
* \param options is reserved, always pass 0.
@@ -49,7 +48,7 @@ CINDEX_LINKAGE CXVirtualFileOverlay
4948
clang_VirtualFileOverlay_create(unsigned options);
5049

5150
/**
52-
* \brief Map an absolute virtual file path to an absolute real one.
51+
* Map an absolute virtual file path to an absolute real one.
5352
* The virtual path must be canonicalized (not contain "."/"..").
5453
* \returns 0 for success, non-zero to indicate an error.
5554
*/
@@ -59,21 +58,21 @@ clang_VirtualFileOverlay_addFileMapping(CXVirtualFileOverlay,
5958
const char *realPath);
6059

6160
/**
62-
* \brief Set the case sensitivity for the \c CXVirtualFileOverlay object.
61+
* Set the case sensitivity for the \c CXVirtualFileOverlay object.
6362
* The \c CXVirtualFileOverlay object is case-sensitive by default, this
6463
* option can be used to override the default.
6564
* \returns 0 for success, non-zero to indicate an error.
6665
*/
6766
CINDEX_LINKAGE enum CXErrorCode
6867
clang_VirtualFileOverlay_setCaseSensitivity(CXVirtualFileOverlay,
69-
int caseSensitive);
68+
int caseSensitive);
7069

7170
/**
72-
* \brief Write out the \c CXVirtualFileOverlay object to a char buffer.
71+
* Write out the \c CXVirtualFileOverlay object to a char buffer.
7372
*
7473
* \param options is reserved, always pass 0.
7574
* \param out_buffer_ptr pointer to receive the buffer pointer, which should be
76-
* disposed using \c free().
75+
* disposed using \c clang_free().
7776
* \param out_buffer_size pointer to receive the buffer size.
7877
* \returns 0 for success, non-zero to indicate an error.
7978
*/
@@ -83,17 +82,25 @@ clang_VirtualFileOverlay_writeToBuffer(CXVirtualFileOverlay, unsigned options,
8382
unsigned *out_buffer_size);
8483

8584
/**
86-
* \brief Dispose a \c CXVirtualFileOverlay object.
85+
* free memory allocated by libclang, such as the buffer returned by
86+
* \c CXVirtualFileOverlay() or \c clang_ModuleMapDescriptor_writeToBuffer().
87+
*
88+
* \param buffer memory pointer to free.
89+
*/
90+
CINDEX_LINKAGE void clang_free(void *buffer);
91+
92+
/**
93+
* Dispose a \c CXVirtualFileOverlay object.
8794
*/
8895
CINDEX_LINKAGE void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay);
8996

9097
/**
91-
* \brief Object encapsulating information about a module.map file.
98+
* Object encapsulating information about a module.map file.
9299
*/
93100
typedef struct CXModuleMapDescriptorImpl *CXModuleMapDescriptor;
94101

95102
/**
96-
* \brief Create a \c CXModuleMapDescriptor object.
103+
* Create a \c CXModuleMapDescriptor object.
97104
* Must be disposed with \c clang_ModuleMapDescriptor_dispose().
98105
*
99106
* \param options is reserved, always pass 0.
@@ -102,27 +109,27 @@ CINDEX_LINKAGE CXModuleMapDescriptor
102109
clang_ModuleMapDescriptor_create(unsigned options);
103110

104111
/**
105-
* \brief Sets the framework module name that the module.map describes.
112+
* Sets the framework module name that the module.map describes.
106113
* \returns 0 for success, non-zero to indicate an error.
107114
*/
108115
CINDEX_LINKAGE enum CXErrorCode
109116
clang_ModuleMapDescriptor_setFrameworkModuleName(CXModuleMapDescriptor,
110117
const char *name);
111118

112119
/**
113-
* \brief Sets the umbrealla header name that the module.map describes.
120+
* Sets the umbrealla header name that the module.map describes.
114121
* \returns 0 for success, non-zero to indicate an error.
115122
*/
116123
CINDEX_LINKAGE enum CXErrorCode
117124
clang_ModuleMapDescriptor_setUmbrellaHeader(CXModuleMapDescriptor,
118125
const char *name);
119126

120127
/**
121-
* \brief Write out the \c CXModuleMapDescriptor object to a char buffer.
128+
* Write out the \c CXModuleMapDescriptor object to a char buffer.
122129
*
123130
* \param options is reserved, always pass 0.
124131
* \param out_buffer_ptr pointer to receive the buffer pointer, which should be
125-
* disposed using \c free().
132+
* disposed using \c clang_free().
126133
* \param out_buffer_size pointer to receive the buffer size.
127134
* \returns 0 for success, non-zero to indicate an error.
128135
*/
@@ -132,17 +139,15 @@ clang_ModuleMapDescriptor_writeToBuffer(CXModuleMapDescriptor, unsigned options,
132139
unsigned *out_buffer_size);
133140

134141
/**
135-
* \brief Dispose a \c CXModuleMapDescriptor object.
142+
* Dispose a \c CXModuleMapDescriptor object.
136143
*/
137144
CINDEX_LINKAGE void clang_ModuleMapDescriptor_dispose(CXModuleMapDescriptor);
138145

139146
/**
140147
* @}
141148
*/
142149

143-
#ifdef __cplusplus
144-
}
145-
#endif
150+
LLVM_CLANG_C_EXTERN_C_END
146151

147152
#endif /* CLANG_C_BUILD_SYSTEM_H */
148153

Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
/*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- C -*-===*\
22
|* *|
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. *|
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 *|
77
|* *|
88
|*===----------------------------------------------------------------------===*|
99
|* *|
10-
|* This header provides a public inferface to use CompilationDatabase without *|
10+
|* This header provides a public interface to use CompilationDatabase without *|
1111
|* the full Clang C++ API. *|
1212
|* *|
1313
\*===----------------------------------------------------------------------===*/
1414

15-
#ifndef CLANG_CXCOMPILATIONDATABASE_H
16-
#define CLANG_CXCOMPILATIONDATABASE_H
15+
#ifndef LLVM_CLANG_C_CXCOMPILATIONDATABASE_H
16+
#define LLVM_CLANG_C_CXCOMPILATIONDATABASE_H
1717

18-
#include "clang-c/Platform.h"
1918
#include "clang-c/CXString.h"
19+
#include "clang-c/ExternC.h"
20+
#include "clang-c/Platform.h"
2021

21-
#ifdef __cplusplus
22-
extern "C" {
23-
#endif
22+
LLVM_CLANG_C_EXTERN_C_BEGIN
2423

2524
/** \defgroup COMPILATIONDB CompilationDatabase functions
2625
* \ingroup CINDEX
@@ -38,7 +37,7 @@ extern "C" {
3837
typedef void * CXCompilationDatabase;
3938

4039
/**
41-
* \brief Contains the results of a search in the compilation database
40+
* Contains the results of a search in the compilation database
4241
*
4342
* When searching for the compile command for a file, the compilation db can
4443
* return several commands, as the file may have been compiled with
@@ -49,28 +48,28 @@ typedef void * CXCompilationDatabase;
4948
typedef void * CXCompileCommands;
5049

5150
/**
52-
* \brief Represents the command line invocation to compile a specific file.
51+
* Represents the command line invocation to compile a specific file.
5352
*/
5453
typedef void * CXCompileCommand;
5554

5655
/**
57-
* \brief Error codes for Compilation Database
56+
* Error codes for Compilation Database
5857
*/
5958
typedef enum {
6059
/*
61-
* \brief No error occurred
60+
* No error occurred
6261
*/
6362
CXCompilationDatabase_NoError = 0,
6463

6564
/*
66-
* \brief Database can not be loaded
65+
* Database can not be loaded
6766
*/
6867
CXCompilationDatabase_CanNotLoadDatabase = 1
6968

7069
} CXCompilationDatabase_Error;
7170

7271
/**
73-
* \brief Creates a compilation database from the database found in directory
72+
* Creates a compilation database from the database found in directory
7473
* buildDir. For example, CMake can output a compile_commands.json which can
7574
* be used to build the database.
7675
*
@@ -81,59 +80,65 @@ clang_CompilationDatabase_fromDirectory(const char *BuildDir,
8180
CXCompilationDatabase_Error *ErrorCode);
8281

8382
/**
84-
* \brief Free the given compilation database
83+
* Free the given compilation database
8584
*/
8685
CINDEX_LINKAGE void
8786
clang_CompilationDatabase_dispose(CXCompilationDatabase);
8887

8988
/**
90-
* \brief Find the compile commands used for a file. The compile commands
89+
* Find the compile commands used for a file. The compile commands
9190
* must be freed by \c clang_CompileCommands_dispose.
9291
*/
9392
CINDEX_LINKAGE CXCompileCommands
9493
clang_CompilationDatabase_getCompileCommands(CXCompilationDatabase,
9594
const char *CompleteFileName);
9695

9796
/**
98-
* \brief Get all the compile commands in the given compilation database.
97+
* Get all the compile commands in the given compilation database.
9998
*/
10099
CINDEX_LINKAGE CXCompileCommands
101100
clang_CompilationDatabase_getAllCompileCommands(CXCompilationDatabase);
102101

103102
/**
104-
* \brief Free the given CompileCommands
103+
* Free the given CompileCommands
105104
*/
106105
CINDEX_LINKAGE void clang_CompileCommands_dispose(CXCompileCommands);
107106

108107
/**
109-
* \brief Get the number of CompileCommand we have for a file
108+
* Get the number of CompileCommand we have for a file
110109
*/
111110
CINDEX_LINKAGE unsigned
112111
clang_CompileCommands_getSize(CXCompileCommands);
113112

114113
/**
115-
* \brief Get the I'th CompileCommand for a file
114+
* Get the I'th CompileCommand for a file
116115
*
117116
* Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands)
118117
*/
119118
CINDEX_LINKAGE CXCompileCommand
120119
clang_CompileCommands_getCommand(CXCompileCommands, unsigned I);
121120

122121
/**
123-
* \brief Get the working directory where the CompileCommand was executed from
122+
* Get the working directory where the CompileCommand was executed from
124123
*/
125124
CINDEX_LINKAGE CXString
126125
clang_CompileCommand_getDirectory(CXCompileCommand);
127126

128127
/**
129-
* \brief Get the number of arguments in the compiler invocation.
128+
* Get the filename associated with the CompileCommand.
129+
*/
130+
CINDEX_LINKAGE CXString
131+
clang_CompileCommand_getFilename(CXCompileCommand);
132+
133+
/**
134+
* Get the number of arguments in the compiler invocation.
130135
*
131136
*/
132137
CINDEX_LINKAGE unsigned
133138
clang_CompileCommand_getNumArgs(CXCompileCommand);
134139

135140
/**
136-
* \brief Get the I'th argument value in the compiler invocations
141+
* Get the I'th argument value in the compiler invocations
137142
*
138143
* Invariant :
139144
* - argument 0 is the compiler executable
@@ -142,19 +147,19 @@ CINDEX_LINKAGE CXString
142147
clang_CompileCommand_getArg(CXCompileCommand, unsigned I);
143148

144149
/**
145-
* \brief Get the number of source mappings for the compiler invocation.
150+
* Get the number of source mappings for the compiler invocation.
146151
*/
147152
CINDEX_LINKAGE unsigned
148153
clang_CompileCommand_getNumMappedSources(CXCompileCommand);
149154

150155
/**
151-
* \brief Get the I'th mapped source path for the compiler invocation.
156+
* Get the I'th mapped source path for the compiler invocation.
152157
*/
153158
CINDEX_LINKAGE CXString
154159
clang_CompileCommand_getMappedSourcePath(CXCompileCommand, unsigned I);
155160

156161
/**
157-
* \brief Get the I'th mapped source content for the compiler invocation.
162+
* Get the I'th mapped source content for the compiler invocation.
158163
*/
159164
CINDEX_LINKAGE CXString
160165
clang_CompileCommand_getMappedSourceContent(CXCompileCommand, unsigned I);
@@ -163,8 +168,7 @@ clang_CompileCommand_getMappedSourceContent(CXCompileCommand, unsigned I);
163168
* @}
164169
*/
165170

166-
#ifdef __cplusplus
167-
}
168-
#endif
171+
LLVM_CLANG_C_EXTERN_C_END
172+
169173
#endif
170174

0 commit comments

Comments
 (0)