Skip to content

Commit 0e8790f

Browse files
committed
clang: update to clang v6
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
1 parent 3a02f4a commit 0e8790f

File tree

7 files changed

+131
-12
lines changed

7 files changed

+131
-12
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- "main"
1010

1111
env:
12-
LLVM_VERSION: 5
12+
LLVM_VERSION: 6
1313

1414
jobs:
1515
test:
@@ -20,13 +20,6 @@ jobs:
2020
- name: Checkout
2121
uses: actions/checkout@v2
2222

23-
- name: Login to GitHub Container Registry
24-
uses: docker/login-action@v1
25-
with:
26-
registry: ghcr.io
27-
username: ${{ github.actor }}
28-
password: ${{ secrets.GHCR_TOKEN }}
29-
3023
- name: Test in Docker
3124
run: |
3225
docker container run -t --mount type=bind,src=$PWD,dst=/go/src/github.com/go-clang/bootstrap -w /go/src/github.com/go-clang/bootstrap ghcr.io/go-clang/base:${LLVM_VERSION} make test

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export CC := clang
44
export CXX := clang++
55

66
LLVM_LIBDIR?=$(shell llvm-config --libdir)
7-
LLVM_VERSION?=5
7+
LLVM_VERSION?=6
88

99
all: test
1010

clang/clang-c/Index.h

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
3535
*/
3636
#define CINDEX_VERSION_MAJOR 0
37-
#define CINDEX_VERSION_MINOR 43
37+
#define CINDEX_VERSION_MINOR 45
3838

3939
#define CINDEX_VERSION_ENCODE(major, minor) ( \
4040
((major) * 10000) \
@@ -335,6 +335,16 @@ CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
335335
*/
336336
CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);
337337

338+
/**
339+
* \brief Sets the invocation emission path option in a CXIndex.
340+
*
341+
* The invocation emission path specifies a path which will contain log
342+
* files for certain libclang invocations. A null value (default) implies that
343+
* libclang invocations are not logged..
344+
*/
345+
CINDEX_LINKAGE void
346+
clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);
347+
338348
/**
339349
* \defgroup CINDEX_FILES File manipulation routines
340350
*
@@ -395,6 +405,21 @@ clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
395405
CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
396406
const char *file_name);
397407

408+
/**
409+
* \brief Retrieve the buffer associated with the given file.
410+
*
411+
* \param tu the translation unit
412+
*
413+
* \param file the file for which to retrieve the buffer.
414+
*
415+
* \param size [out] if non-NULL, will be set to the size of the buffer.
416+
*
417+
* \returns a pointer to the buffer in memory that holds the contents of
418+
* \p file, or a NULL pointer when the file is not loaded.
419+
*/
420+
CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
421+
CXFile file, size_t *size);
422+
398423
/**
399424
* \brief Returns non-zero if the \c file1 and \c file2 point to the same file,
400425
* or they are both NULL.
@@ -2838,6 +2863,22 @@ enum CXLanguageKind {
28382863
*/
28392864
CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);
28402865

2866+
/**
2867+
* \brief Describe the "thread-local storage (TLS) kind" of the declaration
2868+
* referred to by a cursor.
2869+
*/
2870+
enum CXTLSKind {
2871+
CXTLS_None = 0,
2872+
CXTLS_Dynamic,
2873+
CXTLS_Static
2874+
};
2875+
2876+
/**
2877+
* \brief Determine the "thread-local storage (TLS) kind" of the declaration
2878+
* referred to by a cursor.
2879+
*/
2880+
CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);
2881+
28412882
/**
28422883
* \brief Returns the translation unit that a cursor originated from.
28432884
*/
@@ -3117,8 +3158,9 @@ enum CXTypeKind {
31173158
CXType_ObjCSel = 29,
31183159
CXType_Float128 = 30,
31193160
CXType_Half = 31,
3161+
CXType_Float16 = 32,
31203162
CXType_FirstBuiltin = CXType_Void,
3121-
CXType_LastBuiltin = CXType_Half,
3163+
CXType_LastBuiltin = CXType_Float16,
31223164

31233165
CXType_Complex = 100,
31243166
CXType_Pointer = 101,
@@ -4277,6 +4319,12 @@ CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
42774319
*/
42784320
CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
42794321

4322+
/**
4323+
* \brief Retrieve the CXStrings representing the mangled symbols of the ObjC
4324+
* class interface or implementation at the cursor.
4325+
*/
4326+
CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);
4327+
42804328
/**
42814329
* @}
42824330
*/
@@ -4420,6 +4468,12 @@ CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
44204468
*/
44214469
CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);
44224470

4471+
/**
4472+
* \brief Determine if a C++ record is abstract, i.e. whether a class or struct
4473+
* has a pure virtual member function.
4474+
*/
4475+
CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);
4476+
44234477
/**
44244478
* \brief Determine if an enum declaration refers to a scoped enum.
44254479
*/

clang/cursor_gen.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ func (c Cursor) Language() LanguageKind {
109109
return LanguageKind(C.clang_getCursorLanguage(c.c))
110110
}
111111

112+
// Determine the "thread-local storage (TLS) kind" of the declaration referred to by a cursor.
113+
func (c Cursor) TLSKind() TLSKind {
114+
return TLSKind(C.clang_getCursorTLSKind(c.c))
115+
}
116+
112117
// Returns the translation unit that a cursor originated from.
113118
func (c Cursor) TranslationUnit() TranslationUnit {
114119
return TranslationUnit{C.clang_Cursor_getTranslationUnit(c.c)}
@@ -875,7 +880,7 @@ func (c Cursor) Mangling() string {
875880
}
876881

877882
// Retrieve the CXStrings representing the mangled symbols of the C++ constructor or destructor at the cursor.
878-
func (c Cursor) Manglings() *StringSet {
883+
func (c Cursor) CXXManglings() *StringSet {
879884
o := C.clang_Cursor_getCXXManglings(c.c)
880885

881886
var gop_o *StringSet
@@ -886,6 +891,18 @@ func (c Cursor) Manglings() *StringSet {
886891
return gop_o
887892
}
888893

894+
// Retrieve the CXStrings representing the mangled symbols of the ObjC class interface or implementation at the cursor.
895+
func (c Cursor) ObjCManglings() *StringSet {
896+
o := C.clang_Cursor_getObjCManglings(c.c)
897+
898+
var gop_o *StringSet
899+
if o != nil {
900+
gop_o = &StringSet{*o}
901+
}
902+
903+
return gop_o
904+
}
905+
889906
// Given a CXCursor_ModuleImportDecl cursor, return the associated module.
890907
func (c Cursor) Module() Module {
891908
return Module{C.clang_Cursor_getModule(c.c)}
@@ -954,6 +971,13 @@ func (c Cursor) CXXMethod_IsVirtual() bool {
954971
return o != C.uint(0)
955972
}
956973

974+
// Determine if a C++ record is abstract, i.e. whether a class or struct has a pure virtual member function.
975+
func (c Cursor) CXXRecord_IsAbstract() bool {
976+
o := C.clang_CXXRecord_isAbstract(c.c)
977+
978+
return o != C.uint(0)
979+
}
980+
957981
// Determine if an enum declaration refers to a scoped enum.
958982
func (c Cursor) EnumDecl_IsScoped() bool {
959983
o := C.clang_EnumDecl_isScoped(c.c)

clang/index_gen.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ func (i Index) GlobalOptions() uint32 {
9494
return uint32(C.clang_CXIndex_getGlobalOptions(i.c))
9595
}
9696

97+
/*
98+
Sets the invocation emission path option in a CXIndex.
99+
100+
The invocation emission path specifies a path which will contain log
101+
files for certain libclang invocations. A null value (default) implies that
102+
libclang invocations are not logged..
103+
*/
104+
func (i Index) SetInvocationEmissionPathOption(path string) {
105+
c_path := C.CString(path)
106+
defer C.free(unsafe.Pointer(c_path))
107+
108+
C.clang_CXIndex_setInvocationEmissionPathOption(i.c, c_path)
109+
}
110+
97111
/*
98112
Return the CXTranslationUnit for a given source file and the provided
99113
command line arguments one would pass to the compiler.

clang/tlskind_gen.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package clang
2+
3+
// #include "./clang-c/Index.h"
4+
// #include "go-clang.h"
5+
import "C"
6+
import "fmt"
7+
8+
// Describe the "thread-local storage (TLS) kind" of the declaration referred to by a cursor.
9+
type TLSKind uint32
10+
11+
const (
12+
TLS_None TLSKind = C.CXTLS_None
13+
TLS_Dynamic = C.CXTLS_Dynamic
14+
TLS_Static = C.CXTLS_Static
15+
)
16+
17+
func (tlsk TLSKind) Spelling() string {
18+
switch tlsk {
19+
case TLS_None:
20+
return "TLS=None"
21+
case TLS_Dynamic:
22+
return "TLS=Dynamic"
23+
case TLS_Static:
24+
return "TLS=Static"
25+
}
26+
27+
return fmt.Sprintf("TLSKind unknown %d", int(tlsk))
28+
}
29+
30+
func (tlsk TLSKind) String() string {
31+
return tlsk.Spelling()
32+
}

clang/typekind_gen.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ const (
7373
// A type whose specific kind is not exposed via this interface.
7474
Type_Half = C.CXType_Half
7575
// A type whose specific kind is not exposed via this interface.
76+
Type_Float16 = C.CXType_Float16
77+
// A type whose specific kind is not exposed via this interface.
7678
Type_FirstBuiltin = C.CXType_FirstBuiltin
7779
// A type whose specific kind is not exposed via this interface.
7880
Type_LastBuiltin = C.CXType_LastBuiltin

0 commit comments

Comments
 (0)