Skip to content

Commit

Permalink
clang: update to clang v6
Browse files Browse the repository at this point in the history
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
  • Loading branch information
zchee committed Nov 17, 2021
1 parent 3a02f4a commit 0e8790f
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 12 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- "main"

env:
LLVM_VERSION: 5
LLVM_VERSION: 6

jobs:
test:
Expand All @@ -20,13 +20,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Test in Docker
run: |
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export CC := clang
export CXX := clang++

LLVM_LIBDIR?=$(shell llvm-config --libdir)
LLVM_VERSION?=5
LLVM_VERSION?=6

all: test

Expand Down
58 changes: 56 additions & 2 deletions clang/clang-c/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
*/
#define CINDEX_VERSION_MAJOR 0
#define CINDEX_VERSION_MINOR 43
#define CINDEX_VERSION_MINOR 45

#define CINDEX_VERSION_ENCODE(major, minor) ( \
((major) * 10000) \
Expand Down Expand Up @@ -335,6 +335,16 @@ CINDEX_LINKAGE void clang_CXIndex_setGlobalOptions(CXIndex, unsigned options);
*/
CINDEX_LINKAGE unsigned clang_CXIndex_getGlobalOptions(CXIndex);

/**
* \brief Sets the invocation emission path option in a CXIndex.
*
* The invocation emission path specifies a path which will contain log
* files for certain libclang invocations. A null value (default) implies that
* libclang invocations are not logged..
*/
CINDEX_LINKAGE void
clang_CXIndex_setInvocationEmissionPathOption(CXIndex, const char *Path);

/**
* \defgroup CINDEX_FILES File manipulation routines
*
Expand Down Expand Up @@ -395,6 +405,21 @@ clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
CINDEX_LINKAGE CXFile clang_getFile(CXTranslationUnit tu,
const char *file_name);

/**
* \brief Retrieve the buffer associated with the given file.
*
* \param tu the translation unit
*
* \param file the file for which to retrieve the buffer.
*
* \param size [out] if non-NULL, will be set to the size of the buffer.
*
* \returns a pointer to the buffer in memory that holds the contents of
* \p file, or a NULL pointer when the file is not loaded.
*/
CINDEX_LINKAGE const char *clang_getFileContents(CXTranslationUnit tu,
CXFile file, size_t *size);

/**
* \brief Returns non-zero if the \c file1 and \c file2 point to the same file,
* or they are both NULL.
Expand Down Expand Up @@ -2838,6 +2863,22 @@ enum CXLanguageKind {
*/
CINDEX_LINKAGE enum CXLanguageKind clang_getCursorLanguage(CXCursor cursor);

/**
* \brief Describe the "thread-local storage (TLS) kind" of the declaration
* referred to by a cursor.
*/
enum CXTLSKind {
CXTLS_None = 0,
CXTLS_Dynamic,
CXTLS_Static
};

/**
* \brief Determine the "thread-local storage (TLS) kind" of the declaration
* referred to by a cursor.
*/
CINDEX_LINKAGE enum CXTLSKind clang_getCursorTLSKind(CXCursor cursor);

/**
* \brief Returns the translation unit that a cursor originated from.
*/
Expand Down Expand Up @@ -3117,8 +3158,9 @@ enum CXTypeKind {
CXType_ObjCSel = 29,
CXType_Float128 = 30,
CXType_Half = 31,
CXType_Float16 = 32,
CXType_FirstBuiltin = CXType_Void,
CXType_LastBuiltin = CXType_Half,
CXType_LastBuiltin = CXType_Float16,

CXType_Complex = 100,
CXType_Pointer = 101,
Expand Down Expand Up @@ -4277,6 +4319,12 @@ CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
*/
CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);

/**
* \brief Retrieve the CXStrings representing the mangled symbols of the ObjC
* class interface or implementation at the cursor.
*/
CINDEX_LINKAGE CXStringSet *clang_Cursor_getObjCManglings(CXCursor);

/**
* @}
*/
Expand Down Expand Up @@ -4420,6 +4468,12 @@ CINDEX_LINKAGE unsigned clang_CXXMethod_isStatic(CXCursor C);
*/
CINDEX_LINKAGE unsigned clang_CXXMethod_isVirtual(CXCursor C);

/**
* \brief Determine if a C++ record is abstract, i.e. whether a class or struct
* has a pure virtual member function.
*/
CINDEX_LINKAGE unsigned clang_CXXRecord_isAbstract(CXCursor C);

/**
* \brief Determine if an enum declaration refers to a scoped enum.
*/
Expand Down
26 changes: 25 additions & 1 deletion clang/cursor_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ func (c Cursor) Language() LanguageKind {
return LanguageKind(C.clang_getCursorLanguage(c.c))
}

// Determine the "thread-local storage (TLS) kind" of the declaration referred to by a cursor.
func (c Cursor) TLSKind() TLSKind {
return TLSKind(C.clang_getCursorTLSKind(c.c))
}

// Returns the translation unit that a cursor originated from.
func (c Cursor) TranslationUnit() TranslationUnit {
return TranslationUnit{C.clang_Cursor_getTranslationUnit(c.c)}
Expand Down Expand Up @@ -875,7 +880,7 @@ func (c Cursor) Mangling() string {
}

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

var gop_o *StringSet
Expand All @@ -886,6 +891,18 @@ func (c Cursor) Manglings() *StringSet {
return gop_o
}

// Retrieve the CXStrings representing the mangled symbols of the ObjC class interface or implementation at the cursor.
func (c Cursor) ObjCManglings() *StringSet {
o := C.clang_Cursor_getObjCManglings(c.c)

var gop_o *StringSet
if o != nil {
gop_o = &StringSet{*o}
}

return gop_o
}

// Given a CXCursor_ModuleImportDecl cursor, return the associated module.
func (c Cursor) Module() Module {
return Module{C.clang_Cursor_getModule(c.c)}
Expand Down Expand Up @@ -954,6 +971,13 @@ func (c Cursor) CXXMethod_IsVirtual() bool {
return o != C.uint(0)
}

// Determine if a C++ record is abstract, i.e. whether a class or struct has a pure virtual member function.
func (c Cursor) CXXRecord_IsAbstract() bool {
o := C.clang_CXXRecord_isAbstract(c.c)

return o != C.uint(0)
}

// Determine if an enum declaration refers to a scoped enum.
func (c Cursor) EnumDecl_IsScoped() bool {
o := C.clang_EnumDecl_isScoped(c.c)
Expand Down
14 changes: 14 additions & 0 deletions clang/index_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ func (i Index) GlobalOptions() uint32 {
return uint32(C.clang_CXIndex_getGlobalOptions(i.c))
}

/*
Sets the invocation emission path option in a CXIndex.
The invocation emission path specifies a path which will contain log
files for certain libclang invocations. A null value (default) implies that
libclang invocations are not logged..
*/
func (i Index) SetInvocationEmissionPathOption(path string) {
c_path := C.CString(path)
defer C.free(unsafe.Pointer(c_path))

C.clang_CXIndex_setInvocationEmissionPathOption(i.c, c_path)
}

/*
Return the CXTranslationUnit for a given source file and the provided
command line arguments one would pass to the compiler.
Expand Down
32 changes: 32 additions & 0 deletions clang/tlskind_gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package clang

// #include "./clang-c/Index.h"
// #include "go-clang.h"
import "C"
import "fmt"

// Describe the "thread-local storage (TLS) kind" of the declaration referred to by a cursor.
type TLSKind uint32

const (
TLS_None TLSKind = C.CXTLS_None
TLS_Dynamic = C.CXTLS_Dynamic
TLS_Static = C.CXTLS_Static
)

func (tlsk TLSKind) Spelling() string {
switch tlsk {
case TLS_None:
return "TLS=None"
case TLS_Dynamic:
return "TLS=Dynamic"
case TLS_Static:
return "TLS=Static"
}

return fmt.Sprintf("TLSKind unknown %d", int(tlsk))
}

func (tlsk TLSKind) String() string {
return tlsk.Spelling()
}
2 changes: 2 additions & 0 deletions clang/typekind_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const (
// A type whose specific kind is not exposed via this interface.
Type_Half = C.CXType_Half
// A type whose specific kind is not exposed via this interface.
Type_Float16 = C.CXType_Float16
// A type whose specific kind is not exposed via this interface.
Type_FirstBuiltin = C.CXType_FirstBuiltin
// A type whose specific kind is not exposed via this interface.
Type_LastBuiltin = C.CXType_LastBuiltin
Expand Down

0 comments on commit 0e8790f

Please sign in to comment.