Skip to content

Commit 5a44304

Browse files
committed
clang: update to clang v4
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
1 parent b06cefa commit 5a44304

16 files changed

+273
-95
lines changed

clang/callingconv_gen.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const (
1717
CallingConv_X86Pascal = C.CXCallingConv_X86Pascal
1818
CallingConv_AAPCS = C.CXCallingConv_AAPCS
1919
CallingConv_AAPCS_VFP = C.CXCallingConv_AAPCS_VFP
20+
CallingConv_X86RegCall = C.CXCallingConv_X86RegCall
2021
CallingConv_IntelOclBicc = C.CXCallingConv_IntelOclBicc
2122
CallingConv_X86_64Win64 = C.CXCallingConv_X86_64Win64
2223
CallingConv_X86_64SysV = C.CXCallingConv_X86_64SysV
@@ -46,6 +47,8 @@ func (cc CallingConv) Spelling() string {
4647
return "CallingConv=AAPCS"
4748
case CallingConv_AAPCS_VFP:
4849
return "CallingConv=AAPCS_VFP"
50+
case CallingConv_X86RegCall:
51+
return "CallingConv=X86RegCall"
4952
case CallingConv_IntelOclBicc:
5053
return "CallingConv=IntelOclBicc"
5154
case CallingConv_X86_64Win64:

clang/cgoflags_dynamic.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !static
12
// +build !static
23

34
package clang

clang/cgoflags_static.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1+
//go:build static
12
// +build static
23

34
package clang
4-
5-
import "C"

clang/clang-c/Index.h

Lines changed: 79 additions & 10 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 35
37+
#define CINDEX_VERSION_MINOR 37
3838

3939
#define CINDEX_VERSION_ENCODE(major, minor) ( \
4040
((major) * 10000) \
@@ -328,7 +328,7 @@ clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file);
328328
*
329329
* \param tu the translation unit
330330
*
331-
* \param file_name the name of the file.
331+
* \param file_name the name of the file.
332332
*
333333
* \returns the file handle for the named file in the translation unit \p tu,
334334
* or a NULL file handle if the file was not a part of this translation unit.
@@ -628,6 +628,15 @@ typedef struct {
628628
CINDEX_LINKAGE CXSourceRangeList *clang_getSkippedRanges(CXTranslationUnit tu,
629629
CXFile file);
630630

631+
/**
632+
* \brief Retrieve all ranges from all files that were skipped by the
633+
* preprocessor.
634+
*
635+
* The preprocessor will skip lines when they are surrounded by an
636+
* if/ifdef/ifndef directive whose condition does not evaluate to true.
637+
*/
638+
CINDEX_LINKAGE CXSourceRangeList *clang_getAllSkippedRanges(CXTranslationUnit tu);
639+
631640
/**
632641
* \brief Destroy the given \c CXSourceRangeList.
633642
*/
@@ -2327,7 +2336,47 @@ enum CXCursorKind {
23272336
*/
23282337
CXCursor_OMPTargetParallelForSimdDirective = 269,
23292338

2330-
CXCursor_LastStmt = CXCursor_OMPTargetParallelForSimdDirective,
2339+
/** \brief OpenMP target simd directive.
2340+
*/
2341+
CXCursor_OMPTargetSimdDirective = 270,
2342+
2343+
/** \brief OpenMP teams distribute directive.
2344+
*/
2345+
CXCursor_OMPTeamsDistributeDirective = 271,
2346+
2347+
/** \brief OpenMP teams distribute simd directive.
2348+
*/
2349+
CXCursor_OMPTeamsDistributeSimdDirective = 272,
2350+
2351+
/** \brief OpenMP teams distribute parallel for simd directive.
2352+
*/
2353+
CXCursor_OMPTeamsDistributeParallelForSimdDirective = 273,
2354+
2355+
/** \brief OpenMP teams distribute parallel for directive.
2356+
*/
2357+
CXCursor_OMPTeamsDistributeParallelForDirective = 274,
2358+
2359+
/** \brief OpenMP target teams directive.
2360+
*/
2361+
CXCursor_OMPTargetTeamsDirective = 275,
2362+
2363+
/** \brief OpenMP target teams distribute directive.
2364+
*/
2365+
CXCursor_OMPTargetTeamsDistributeDirective = 276,
2366+
2367+
/** \brief OpenMP target teams distribute parallel for directive.
2368+
*/
2369+
CXCursor_OMPTargetTeamsDistributeParallelForDirective = 277,
2370+
2371+
/** \brief OpenMP target teams distribute parallel for simd directive.
2372+
*/
2373+
CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
2374+
2375+
/** \brief OpenMP target teams distribute simd directive.
2376+
*/
2377+
CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
2378+
2379+
CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective,
23312380

23322381
/**
23332382
* \brief Cursor that represents the translation unit itself.
@@ -2385,8 +2434,12 @@ enum CXCursorKind {
23852434
* \brief A static_assert or _Static_assert node
23862435
*/
23872436
CXCursor_StaticAssert = 602,
2437+
/**
2438+
* \brief a friend declaration.
2439+
*/
2440+
CXCursor_FriendDecl = 603,
23882441
CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl,
2389-
CXCursor_LastExtraDecl = CXCursor_StaticAssert,
2442+
CXCursor_LastExtraDecl = CXCursor_FriendDecl,
23902443

23912444
/**
23922445
* \brief A code completion overload candidate.
@@ -3003,7 +3056,7 @@ enum CXCallingConv {
30033056
CXCallingConv_X86Pascal = 5,
30043057
CXCallingConv_AAPCS = 6,
30053058
CXCallingConv_AAPCS_VFP = 7,
3006-
/* Value 8 was PnaclCall, but it was never used, so it could safely be re-used. */
3059+
CXCallingConv_X86RegCall = 8,
30073060
CXCallingConv_IntelOclBicc = 9,
30083061
CXCallingConv_X86_64Win64 = 10,
30093062
CXCallingConv_X86_64SysV = 11,
@@ -3493,11 +3546,8 @@ enum CXRefQualifierKind {
34933546
};
34943547

34953548
/**
3496-
* \brief Returns the number of template arguments for given class template
3497-
* specialization, or -1 if type \c T is not a class template specialization.
3498-
*
3499-
* Variadic argument packs count as only one argument, and can not be inspected
3500-
* further.
3549+
* \brief Returns the number of template arguments for given template
3550+
* specialization, or -1 if type \c T is not a template specialization.
35013551
*/
35023552
CINDEX_LINKAGE int clang_Type_getNumTemplateArguments(CXType T);
35033553

@@ -5241,6 +5291,25 @@ CINDEX_LINKAGE CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E);
52415291
*/
52425292
CINDEX_LINKAGE int clang_EvalResult_getAsInt(CXEvalResult E);
52435293

5294+
/**
5295+
* \brief Returns the evaluation result as a long long integer if the
5296+
* kind is Int. This prevents overflows that may happen if the result is
5297+
* returned with clang_EvalResult_getAsInt.
5298+
*/
5299+
CINDEX_LINKAGE long long clang_EvalResult_getAsLongLong(CXEvalResult E);
5300+
5301+
/**
5302+
* \brief Returns a non-zero value if the kind is Int and the evaluation
5303+
* result resulted in an unsigned integer.
5304+
*/
5305+
CINDEX_LINKAGE unsigned clang_EvalResult_isUnsignedInt(CXEvalResult E);
5306+
5307+
/**
5308+
* \brief Returns the evaluation result as an unsigned integer if
5309+
* the kind is Int and clang_EvalResult_isUnsignedInt is non-zero.
5310+
*/
5311+
CINDEX_LINKAGE unsigned long long clang_EvalResult_getAsUnsigned(CXEvalResult E);
5312+
52445313
/**
52455314
* \brief Returns the evaluation result as double if the
52465315
* kind is double.

clang/clang_test.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package clang
22

33
import (
4+
"reflect"
45
"testing"
5-
6-
"github.com/stretchr/testify/assert"
76
)
87

98
func TestBasicParsing(t *testing.T) {
109
idx := NewIndex(0, 1)
1110
defer idx.Dispose()
1211

1312
tu := idx.ParseTranslationUnit("../testdata/basicparsing.c", nil, nil, 0)
14-
assert.True(t, tu.IsValid())
13+
if !tu.IsValid() {
14+
t.Fatal("tu is invalid")
15+
}
1516
defer tu.Dispose()
1617

1718
found := 0
@@ -23,19 +24,25 @@ func TestBasicParsing(t *testing.T) {
2324

2425
switch cursor.Kind() {
2526
case Cursor_FunctionDecl:
26-
assert.Equal(t, "foo", cursor.Spelling())
27+
if "foo" != cursor.Spelling() {
28+
t.Fatalf("want foo but got %s", cursor.Spelling())
29+
}
2730

2831
found++
2932
case Cursor_ParmDecl:
30-
assert.Equal(t, "bar", cursor.Spelling())
33+
if "bar" != cursor.Spelling() {
34+
t.Fatalf("want bar but got %s", cursor.Spelling())
35+
}
3136

3237
found++
3338
}
3439

3540
return ChildVisit_Recurse
3641
})
3742

38-
assert.Equal(t, 2, found, "Did not find all nodes")
43+
if !reflect.DeepEqual(2, found) {
44+
t.Fatal("Did not find all nodes")
45+
}
3946
}
4047

4148
func TestReparse(t *testing.T) {
@@ -47,7 +54,9 @@ func TestReparse(t *testing.T) {
4754
defer idx.Dispose()
4855

4956
tu := idx.ParseTranslationUnit("hello.cpp", nil, us, 0)
50-
assert.True(t, tu.IsValid())
57+
if !tu.IsValid() {
58+
t.Fatal("tu is invalid")
59+
}
5160
defer tu.Dispose()
5261

5362
ok := false

clang/codecompleteresults.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package clang
22

3-
func (ccr *CodeCompleteResults) Diagnostics() []Diagnostic { // TODO this can be generated https://github.com/go-clang/gen/issues/47
3+
// TODO this can be generated https://github.com/go-clang/gen/issues/47
4+
5+
// Diagnostics determine the number of diagnostics produced prior to the
6+
// location where code completion was performed.
7+
func (ccr *CodeCompleteResults) Diagnostics() []Diagnostic {
48
s := make([]Diagnostic, ccr.NumDiagnostics())
59

610
for i := range s {

clang/completion_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@ package clang
33
import (
44
"strings"
55
"testing"
6-
7-
"github.com/stretchr/testify/assert"
86
)
97

108
func TestCompletion(t *testing.T) {
119
idx := NewIndex(0, 0)
1210
defer idx.Dispose()
1311

1412
tu := idx.ParseTranslationUnit("cursor.c", nil, nil, 0)
15-
assert.True(t, tu.IsValid())
13+
if !tu.IsValid() {
14+
t.Fatal("tu is invalid")
15+
}
1616
defer tu.Dispose()
1717

1818
res := tu.CodeCompleteAt("cursor.c", 5, 18, nil, 0)
19-
assert.NotNil(t, res)
19+
if res == nil {
20+
t.Fatal("expected res is non-nil")
21+
}
2022
defer res.Dispose()
2123

2224
if n := len(res.Results()); n < 10 {
@@ -48,5 +50,7 @@ func TestCompletion(t *testing.T) {
4850
}
4951
t.Log(d.Severity(), d.Spelling())
5052
}
51-
assert.True(t, ok)
53+
if !ok {
54+
t.Fatal("not found diagnostics")
55+
}
5256
}

0 commit comments

Comments
 (0)