forked from neslib/Neslib.Clang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Neslib.Clang.Api.pas
5851 lines (5248 loc) · 205 KB
/
Neslib.Clang.Api.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit Neslib.Clang.Api;
{< LibClang 14.0.0 Header Translation }
{$IFNDEF MSWINDOWS}
{$MESSAGE Error 'Clang for Delphi (currently) only works on Windows'}
{$ENDIF}
{$MINENUMSIZE 4}
interface
const
LIBCLANG = 'libclang.dll';
type
time_t = LongInt;
SIZE_T = NativeUInt;
PSIZE_T = ^SIZE_T;
{$REGION 'CXErrorCode.h'}
(*===-- clang-c/CXErrorCode.h - C Index Error Codes --------------*- C -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header provides the CXErrorCode enumerators. *|
|* *|
\*===----------------------------------------------------------------------===*)
(**
* Error codes returned by libclang routines.
*
* Zero (\c CXError_Success) is the only error code indicating success. Other
* error codes, including not yet assigned non-zero values, indicate errors.
*)
type
TCXErrorCode = Integer;
PCXErrorCode = ^TCXErrorCode;
const
CXError_Success = 0;
CXError_Failure = 1;
CXError_Crashed = 2;
CXError_InvalidArguments = 3;
CXError_ASTReadError = 4;
{$ENDREGION 'CXErrorCode.h'}
{$REGION 'CXString.h'}
(*===-- clang-c/CXString.h - C Index strings --------------------*- C -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header provides the interface to C Index strings. *|
|* *|
\*===----------------------------------------------------------------------===*)
(**
* \defgroup CINDEX_STRING String manipulation routines
* \ingroup CINDEX
*
* @{
*)
(**
* A character string.
*
* The \c CXString type is used to return strings from the interface when
* the ownership of that string might differ from one call to the next.
* Use \c clang_getCString() to retrieve the string data and, once finished
* with the string data, call \c clang_disposeString() to free the string.
*)
type
{$IFDEF WIN32}
{ Some C APIs return a TCXString record.
However, when a returned value fits into 64-Bits on Win32, then Delphi
doesn't return a TCXString record correctly. So we use an UInt64 instead. }
TCXString = UInt64;
{$ELSE}
TCXString = record
data: Pointer;
private_flags: Cardinal;
end;
{$ENDIF}
PCXString = ^TCXString;
type
TCXStringSet = record
Strings: PCXString;
Count: Cardinal;
end;
PCXStringSet = ^TCXStringSet;
(**
* Retrieve the character data associated with the given string.
*)
function clang_getCString(_string: TCXString): PAnsiChar; cdecl external LIBCLANG;
(**
* Free the given string.
*)
procedure clang_disposeString(_string: TCXString); cdecl external LIBCLANG;
(**
* Free the given string set.
*)
procedure clang_disposeStringSet(_set: PCXStringSet); cdecl external LIBCLANG;
{$ENDREGION 'CXString.h'}
{$REGION 'CXCompilationDatabase.h'}
(*===-- clang-c/CXCompilationDatabase.h - Compilation database ---*- C -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header provides a public interface to use CompilationDatabase without *|
|* the full Clang C++ API. *|
|* *|
\*===----------------------------------------------------------------------===*)
(** \defgroup COMPILATIONDB CompilationDatabase functions
* \ingroup CINDEX
*
* @{
*)
(**
* A compilation database holds all information used to compile files in a
* project. For each file in the database, it can be queried for the working
* directory or the command line used for the compiler invocation.
*
* Must be freed by \c clang_CompilationDatabase_dispose
*)
type TCXCompilationDatabase = Pointer;
(**
* Contains the results of a search in the compilation database
*
* When searching for the compile command for a file, the compilation db can
* return several commands, as the file may have been compiled with
* different options in different places of the project. This choice of compile
* commands is wrapped in this opaque data structure. It must be freed by
* \c clang_CompileCommands_dispose.
*)
type TCXCompileCommands = Pointer;
(**
* Represents the command line invocation to compile a specific file.
*)
type TCXCompileCommand = Pointer;
(**
* Error codes for Compilation Database
*)
type
TCXCompilationDatabase_Error = Integer;
PCXCompilationDatabase_Error = ^TCXCompilationDatabase_Error;
const
CXCompilationDatabase_NoError = 0;
CXCompilationDatabase_CanNotLoadDatabase = 1;
(**
* Creates a compilation database from the database found in directory
* buildDir. For example, CMake can output a compile_commands.json which can
* be used to build the database.
*
* It must be freed by \c clang_CompilationDatabase_dispose.
*)
function clang_CompilationDatabase_fromDirectory(const BuildDir: PAnsiChar; ErrorCode: PCXCompilationDatabase_Error): TCXCompilationDatabase; cdecl external LIBCLANG;
(**
* Free the given compilation database
*)
procedure clang_CompilationDatabase_dispose(p1: TCXCompilationDatabase); cdecl external LIBCLANG;
(**
* Find the compile commands used for a file. The compile commands
* must be freed by \c clang_CompileCommands_dispose.
*)
function clang_CompilationDatabase_getCompileCommands(p1: TCXCompilationDatabase; const CompleteFileName: PAnsiChar): TCXCompileCommands; cdecl external LIBCLANG;
(**
* Get all the compile commands in the given compilation database.
*)
function clang_CompilationDatabase_getAllCompileCommands(p1: TCXCompilationDatabase): TCXCompileCommands; cdecl external LIBCLANG;
(**
* Free the given CompileCommands
*)
procedure clang_CompileCommands_dispose(p1: TCXCompileCommands); cdecl external LIBCLANG;
(**
* Get the number of CompileCommand we have for a file
*)
function clang_CompileCommands_getSize(p1: TCXCompileCommands): Cardinal; cdecl external LIBCLANG;
(**
* Get the I'th CompileCommand for a file
*
* Note : 0 <= i < clang_CompileCommands_getSize(CXCompileCommands)
*)
function clang_CompileCommands_getCommand(p1: TCXCompileCommands; I: Cardinal): TCXCompileCommand; cdecl external LIBCLANG;
(**
* Get the working directory where the CompileCommand was executed from
*)
function clang_CompileCommand_getDirectory(p1: TCXCompileCommand): TCXString; cdecl external LIBCLANG;
(**
* Get the filename associated with the CompileCommand.
*)
function clang_CompileCommand_getFilename(p1: TCXCompileCommand): TCXString; cdecl external LIBCLANG;
(**
* Get the number of arguments in the compiler invocation.
*
*)
function clang_CompileCommand_getNumArgs(p1: TCXCompileCommand): Cardinal; cdecl external LIBCLANG;
(**
* Get the I'th argument value in the compiler invocations
*
* Invariant :
* - argument 0 is the compiler executable
*)
function clang_CompileCommand_getArg(p1: TCXCompileCommand; I: Cardinal): TCXString; cdecl external LIBCLANG;
(**
* Get the number of source mappings for the compiler invocation.
*)
function clang_CompileCommand_getNumMappedSources(p1: TCXCompileCommand): Cardinal; cdecl external LIBCLANG;
(**
* Get the I'th mapped source path for the compiler invocation.
*)
function clang_CompileCommand_getMappedSourcePath(p1: TCXCompileCommand; I: Cardinal): TCXString; cdecl external LIBCLANG;
(**
* Get the I'th mapped source content for the compiler invocation.
*)
function clang_CompileCommand_getMappedSourceContent(p1: TCXCompileCommand; I: Cardinal): TCXString; cdecl external LIBCLANG;
{$ENDREGION 'CXCompilationDatabase.h'}
{$REGION 'BuildSystem.h'}
(*==-- clang-c/BuildSystem.h - Utilities for use by build systems -*- C -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header provides various utilities for use by build systems. *|
|* *|
\*===----------------------------------------------------------------------===*)
(**
* \defgroup BUILD_SYSTEM Build system utilities
* @{
*)
(**
* Return the timestamp for use with Clang's
* \c -fbuild-session-timestamp= option.
*)
function clang_getBuildSessionTimestamp(): UInt64; cdecl external LIBCLANG;
(**
* Object encapsulating information about overlaying virtual
* file/directories over the real file system.
*)
type TCXVirtualFileOverlay = Pointer;
(**
* Create a \c CXVirtualFileOverlay object.
* Must be disposed with \c clang_VirtualFileOverlay_dispose().
*
* \param options is reserved, always pass 0.
*)
function clang_VirtualFileOverlay_create(options: Cardinal): TCXVirtualFileOverlay; cdecl external LIBCLANG;
(**
* Map an absolute virtual file path to an absolute real one.
* The virtual path must be canonicalized (not contain "."/"..").
* \returns 0 for success, non-zero to indicate an error.
*)
function clang_VirtualFileOverlay_addFileMapping(p1: TCXVirtualFileOverlay; const virtualPath: PAnsiChar; const realPath: PAnsiChar): TCXErrorCode; cdecl external LIBCLANG;
(**
* Set the case sensitivity for the \c CXVirtualFileOverlay object.
* The \c CXVirtualFileOverlay object is case-sensitive by default, this
* option can be used to override the default.
* \returns 0 for success, non-zero to indicate an error.
*)
function clang_VirtualFileOverlay_setCaseSensitivity(p1: TCXVirtualFileOverlay; caseSensitive: Integer): TCXErrorCode; cdecl external LIBCLANG;
(**
* Write out the \c CXVirtualFileOverlay object to a char buffer.
*
* \param options is reserved, always pass 0.
* \param out_buffer_ptr pointer to receive the buffer pointer, which should be
* disposed using \c clang_free().
* \param out_buffer_size pointer to receive the buffer size.
* \returns 0 for success, non-zero to indicate an error.
*)
function clang_VirtualFileOverlay_writeToBuffer(p1: TCXVirtualFileOverlay; options: Cardinal; out_buffer_ptr: PPAnsiChar; out_buffer_size: PCardinal): TCXErrorCode; cdecl external LIBCLANG;
(**
* free memory allocated by libclang, such as the buffer returned by
* \c CXVirtualFileOverlay() or \c clang_ModuleMapDescriptor_writeToBuffer().
*
* \param buffer memory pointer to free.
*)
procedure clang_free(buffer: Pointer); cdecl external LIBCLANG;
(**
* Dispose a \c CXVirtualFileOverlay object.
*)
procedure clang_VirtualFileOverlay_dispose(p1: TCXVirtualFileOverlay); cdecl external LIBCLANG;
(**
* Object encapsulating information about a module.map file.
*)
type TCXModuleMapDescriptor = Pointer;
(**
* Create a \c CXModuleMapDescriptor object.
* Must be disposed with \c clang_ModuleMapDescriptor_dispose().
*
* \param options is reserved, always pass 0.
*)
function clang_ModuleMapDescriptor_create(options: Cardinal): TCXModuleMapDescriptor; cdecl external LIBCLANG;
(**
* Sets the framework module name that the module.map describes.
* \returns 0 for success, non-zero to indicate an error.
*)
function clang_ModuleMapDescriptor_setFrameworkModuleName(p1: TCXModuleMapDescriptor; const name: PAnsiChar): TCXErrorCode; cdecl external LIBCLANG;
(**
* Sets the umbrealla header name that the module.map describes.
* \returns 0 for success, non-zero to indicate an error.
*)
function clang_ModuleMapDescriptor_setUmbrellaHeader(p1: TCXModuleMapDescriptor; const name: PAnsiChar): TCXErrorCode; cdecl external LIBCLANG;
(**
* Write out the \c CXModuleMapDescriptor object to a char buffer.
*
* \param options is reserved, always pass 0.
* \param out_buffer_ptr pointer to receive the buffer pointer, which should be
* disposed using \c clang_free().
* \param out_buffer_size pointer to receive the buffer size.
* \returns 0 for success, non-zero to indicate an error.
*)
function clang_ModuleMapDescriptor_writeToBuffer(p1: TCXModuleMapDescriptor; options: Cardinal; out_buffer_ptr: PPAnsiChar; out_buffer_size: PCardinal): TCXErrorCode; cdecl external LIBCLANG;
(**
* Dispose a \c CXModuleMapDescriptor object.
*)
procedure clang_ModuleMapDescriptor_dispose(p1: TCXModuleMapDescriptor); cdecl external LIBCLANG;
{$ENDREGION 'BuildSystem.h'}
{$REGION 'Index.h'}
(*===-- clang-c/Index.h - Indexing Public C Interface -------------*- C -*-===*\
|* *|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|* Exceptions. *|
|* See https://llvm.org/LICENSE.txt for license information. *|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header provides a public interface to a Clang library for extracting *|
|* high-level symbol information from source files without exposing the full *|
|* Clang C++ API. *|
|* *|
\*===----------------------------------------------------------------------===*)
(**
* The version constants for the libclang API.
* CINDEX_VERSION_MINOR should increase when there are API additions.
* CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
*
* The policy about the libclang API was always to keep it source and ABI
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
*)
const CINDEX_VERSION_MAJOR = 0;
const CINDEX_VERSION_MINOR = 62;
{!#define CINDEX_VERSION_ENCODE(major, minor) (
((major) * 10000)
+ ((minor) * 1))}
const CINDEX_VERSION = (CINDEX_VERSION_MAJOR * 10000) + CINDEX_VERSION_MINOR;
{!#define CINDEX_VERSION_STRINGIZE_(major, minor)
#major"."#minor}
{!#define CINDEX_VERSION_STRINGIZE(major, minor)
CINDEX_VERSION_STRINGIZE_(major, minor)}
const CINDEX_VERSION_STRING = '0.60';
(** \defgroup CINDEX libclang: C Interface to Clang
*
* The C Interface to Clang provides a relatively small API that exposes
* facilities for parsing source code into an abstract syntax tree (AST),
* loading already-parsed ASTs, traversing the AST, associating
* physical source locations with elements within the AST, and other
* facilities that support Clang-based development tools.
*
* This C interface to Clang will never provide all of the information
* representation stored in Clang's C++ AST, nor should it: the intent is to
* maintain an API that is relatively stable from one release to the next,
* providing only the basic functionality needed to support development tools.
*
* To avoid namespace pollution, data types are prefixed with "CX" and
* functions are prefixed with "clang_".
*
* @{
*)
(**
* An "index" that consists of a set of translation units that would
* typically be linked together into an executable or library.
*)
type TCXIndex = Pointer;
(**
* An opaque type representing target information for a given translation
* unit.
*)
type TCXTargetInfo = Pointer;
(**
* A single translation unit, which resides in an index.
*)
type TCXTranslationUnit = Pointer;
type PCXTranslationUnit = ^TCXTranslationUnit;
(**
* Opaque pointer representing client data that will be passed through
* to various callbacks and visitors.
*)
type TCXClientData = Pointer;
(**
* Provides the contents of a file that has not yet been saved to disk.
*
* Each CXUnsavedFile instance provides the name of a file on the
* system along with the current contents of that file that have not
* yet been saved to disk.
*)
type
TCXUnsavedFile = record
Filename: PAnsiChar;
Contents: PAnsiChar;
Length: Longword;
end;
PCXUnsavedFile = ^TCXUnsavedFile;
(**
* Describes the availability of a particular entity, which indicates
* whether the use of this entity will result in a warning or error due to
* it being deprecated or unavailable.
*)
type
TCXAvailabilityKind = Integer;
const
CXAvailability_Available = 0;
CXAvailability_Deprecated = CXAvailability_Available + 1;
CXAvailability_NotAvailable = CXAvailability_Deprecated + 1;
CXAvailability_NotAccessible = CXAvailability_NotAvailable + 1;
(**
* Describes a version number of the form major.minor.subminor.
*)
type
TCXVersion = record
Major: Integer;
Minor: Integer;
Subminor: Integer;
end;
PCXVersion = ^TCXVersion;
(**
* Describes the exception specification of a cursor.
*
* A negative value indicates that the cursor is not a function declaration.
*)
type
TCXCursor_ExceptionSpecificationKind = Integer;
const
CXCursor_ExceptionSpecificationKind_None = 0;
CXCursor_ExceptionSpecificationKind_DynamicNone = CXCursor_ExceptionSpecificationKind_None + 1;
CXCursor_ExceptionSpecificationKind_Dynamic = CXCursor_ExceptionSpecificationKind_DynamicNone + 1;
CXCursor_ExceptionSpecificationKind_MSAny = CXCursor_ExceptionSpecificationKind_Dynamic + 1;
CXCursor_ExceptionSpecificationKind_BasicNoexcept = CXCursor_ExceptionSpecificationKind_MSAny + 1;
CXCursor_ExceptionSpecificationKind_ComputedNoexcept = CXCursor_ExceptionSpecificationKind_BasicNoexcept + 1;
CXCursor_ExceptionSpecificationKind_Unevaluated = CXCursor_ExceptionSpecificationKind_ComputedNoexcept + 1;
CXCursor_ExceptionSpecificationKind_Uninstantiated = CXCursor_ExceptionSpecificationKind_Unevaluated + 1;
CXCursor_ExceptionSpecificationKind_Unparsed = CXCursor_ExceptionSpecificationKind_Uninstantiated + 1;
CXCursor_ExceptionSpecificationKind_NoThrow = CXCursor_ExceptionSpecificationKind_Unparsed + 1;
(**
* Provides a shared context for creating translation units.
*
* It provides two options:
*
* - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local"
* declarations (when loading any new translation units). A "local" declaration
* is one that belongs in the translation unit itself and not in a precompiled
* header that was used by the translation unit. If zero, all declarations
* will be enumerated.
*
* Here is an example:
*
* \code
* // excludeDeclsFromPCH = 1, displayDiagnostics=1
* Idx = clang_createIndex(1, 1);
*
* // IndexTest.pch was produced with the following command:
* // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch"
* TU = clang_createTranslationUnit(Idx, "IndexTest.pch");
*
* // This will load all the symbols from 'IndexTest.pch'
* clang_visitChildren(clang_getTranslationUnitCursor(TU),
* TranslationUnitVisitor, 0);
* clang_disposeTranslationUnit(TU);
*
* // This will load all the symbols from 'IndexTest.c', excluding symbols
* // from 'IndexTest.pch'.
* char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" };
* TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args,
* 0, 0);
* clang_visitChildren(clang_getTranslationUnitCursor(TU),
* TranslationUnitVisitor, 0);
* clang_disposeTranslationUnit(TU);
* \endcode
*
* This process of creating the 'pch', loading it separately, and using it (via
* -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks
* (which gives the indexer the same performance benefit as the compiler).
*)
function clang_createIndex(excludeDeclarationsFromPCH: Integer; displayDiagnostics: Integer): TCXIndex; cdecl external LIBCLANG;
(**
* Destroy the given index.
*
* The index must not be destroyed until all of the translation units created
* within that index have been destroyed.
*)
procedure clang_disposeIndex(index: TCXIndex); cdecl external LIBCLANG;
type
TCXGlobalOptFlags = Integer;
const
CXGlobalOpt_None = $0;
CXGlobalOpt_ThreadBackgroundPriorityForIndexing = $1;
CXGlobalOpt_ThreadBackgroundPriorityForEditing = $2;
CXGlobalOpt_ThreadBackgroundPriorityForAll = CXGlobalOpt_ThreadBackgroundPriorityForIndexing
or CXGlobalOpt_ThreadBackgroundPriorityForEditing;
(**
* Sets general options associated with a CXIndex.
*
* For example:
* \code
* CXIndex idx = ...;
* clang_CXIndex_setGlobalOptions(idx,
* clang_CXIndex_getGlobalOptions(idx) |
* CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
* \endcode
*
* \param options A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags.
*)
procedure clang_CXIndex_setGlobalOptions(p1: TCXIndex; options: Cardinal); cdecl external LIBCLANG;
(**
* Gets the general options associated with a CXIndex.
*
* \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that
* are associated with the given CXIndex object.
*)
function clang_CXIndex_getGlobalOptions(p1: TCXIndex): Cardinal; cdecl external LIBCLANG;
(**
* 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..
*)
procedure clang_CXIndex_setInvocationEmissionPathOption(p1: TCXIndex; const Path: PAnsiChar); cdecl external LIBCLANG;
(**
* \defgroup CINDEX_FILES File manipulation routines
*
* @{
*)
(**
* A particular source file that is part of a translation unit.
*)
type TCXFile = Pointer;
type PCXFile = ^TCXFile;
(**
* Retrieve the complete file and path name of the given file.
*)
function clang_getFileName(SFile: TCXFile): TCXString; cdecl external LIBCLANG;
(**
* Retrieve the last modification time of the given file.
*)
function clang_getFileTime(SFile: TCXFile): time_t; cdecl external LIBCLANG;
(**
* Uniquely identifies a CXFile, that refers to the same underlying file,
* across an indexing session.
*)
type
TCXFileUniqueID = record
data: array [0..3-1] of UInt64;
end;
PCXFileUniqueID = ^TCXFileUniqueID;
(**
* Retrieve the unique ID for the given \c file.
*
* \param file the file to get the ID for.
* \param outID stores the returned CXFileUniqueID.
* \returns If there was a failure getting the unique ID, returns non-zero,
* otherwise returns 0.
*)
function clang_getFileUniqueID(_file: TCXFile; outID: PCXFileUniqueID): Integer; cdecl external LIBCLANG;
(**
* Determine whether the given header is guarded against
* multiple inclusions, either with the conventional
* \#ifndef/\#define/\#endif macro guards or with \#pragma once.
*)
function clang_isFileMultipleIncludeGuarded(tu: TCXTranslationUnit; _file: TCXFile): Cardinal; cdecl external LIBCLANG;
(**
* Retrieve a file handle within the given translation unit.
*
* \param tu the translation unit
*
* \param file_name the name of the file.
*
* \returns the file handle for the named file in the translation unit \p tu,
* or a NULL file handle if the file was not a part of this translation unit.
*)
function clang_getFile(tu: TCXTranslationUnit; const file_name: PAnsiChar): TCXFile; cdecl external LIBCLANG;
(**
* 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.
*)
function clang_getFileContents(tu: TCXTranslationUnit; _file: TCXFile; size: PSIZE_T): PAnsiChar; cdecl external LIBCLANG;
(**
* Returns non-zero if the \c file1 and \c file2 point to the same file,
* or they are both NULL.
*)
function clang_File_isEqual(file1: TCXFile; file2: TCXFile): Integer; cdecl external LIBCLANG;
(**
* Returns the real path name of \c file.
*
* An empty string may be returned. Use \c clang_getFileName() in that case.
*)
function clang_File_tryGetRealPathName(_file: TCXFile): TCXString; cdecl external LIBCLANG;
(**
* @}
*)
(**
* \defgroup CINDEX_LOCATIONS Physical source locations
*
* Clang represents physical source locations in its abstract syntax tree in
* great detail, with file, line, and column information for the majority of
* the tokens parsed in the source code. These data types and functions are
* used to represent source location information, either for a particular
* point in the program or for a range of points in the program, and extract
* specific location information from those data types.
*
* @{
*)
(**
* Identifies a specific source location within a translation
* unit.
*
* Use clang_getExpansionLocation() or clang_getSpellingLocation()
* to map a source location to a particular file, line, and column.
*)
type
TCXSourceLocation = record
ptr_data: array [0..2-1] of Pointer;
int_data: Cardinal;
end;
PCXSourceLocation = ^TCXSourceLocation;
(**
* Identifies a half-open character range in the source code.
*
* Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the
* starting and end locations from a source range, respectively.
*)
type
TCXSourceRange = record
ptr_data: array [0..2-1] of Pointer;
begin_int_data: Cardinal;
end_int_data: Cardinal;
end;
PCXSourceRange = ^TCXSourceRange;
(**
* Retrieve a NULL (invalid) source location.
*)
function clang_getNullLocation(): TCXSourceLocation; cdecl external LIBCLANG;
(**
* Determine whether two source locations, which must refer into
* the same translation unit, refer to exactly the same point in the source
* code.
*
* \returns non-zero if the source locations refer to the same location, zero
* if they refer to different locations.
*)
function clang_equalLocations(loc1: TCXSourceLocation; loc2: TCXSourceLocation): Cardinal; cdecl external LIBCLANG;
(**
* Retrieves the source location associated with a given file/line/column
* in a particular translation unit.
*)
function clang_getLocation(tu: TCXTranslationUnit; _file: TCXFile; line: Cardinal; column: Cardinal): TCXSourceLocation; cdecl external LIBCLANG;
(**
* Retrieves the source location associated with a given character offset
* in a particular translation unit.
*)
function clang_getLocationForOffset(tu: TCXTranslationUnit; _file: TCXFile; offset: Cardinal): TCXSourceLocation; cdecl external LIBCLANG;
(**
* Returns non-zero if the given source location is in a system header.
*)
function clang_Location_isInSystemHeader(location: TCXSourceLocation): Integer; cdecl external LIBCLANG;
(**
* Returns non-zero if the given source location is in the main file of
* the corresponding translation unit.
*)
function clang_Location_isFromMainFile(location: TCXSourceLocation): Integer; cdecl external LIBCLANG;
(**
* Retrieve a NULL (invalid) source range.
*)
function clang_getNullRange(): TCXSourceRange; cdecl external LIBCLANG;
(**
* Retrieve a source range given the beginning and ending source
* locations.
*)
function clang_getRange(_begin: TCXSourceLocation; _end: TCXSourceLocation): TCXSourceRange; cdecl external LIBCLANG;
(**
* Determine whether two ranges are equivalent.
*
* \returns non-zero if the ranges are the same, zero if they differ.
*)
function clang_equalRanges(range1: TCXSourceRange; range2: TCXSourceRange): Cardinal; cdecl external LIBCLANG;
(**
* Returns non-zero if \p range is null.
*)
function clang_Range_isNull(range: TCXSourceRange): Integer; cdecl external LIBCLANG;
(**
* Retrieve the file, line, column, and offset represented by
* the given source location.
*
* If the location refers into a macro expansion, retrieves the
* location of the macro expansion.
*
* \param location the location within a source file that will be decomposed
* into its parts.
*
* \param file [out] if non-NULL, will be set to the file to which the given
* source location points.
*
* \param line [out] if non-NULL, will be set to the line to which the given
* source location points.
*
* \param column [out] if non-NULL, will be set to the column to which the given
* source location points.
*
* \param offset [out] if non-NULL, will be set to the offset into the
* buffer to which the given source location points.
*)
procedure clang_getExpansionLocation(location: TCXSourceLocation; _file: PCXFile; line: PCardinal; column: PCardinal; offset: PCardinal); cdecl external LIBCLANG;
(**
* Retrieve the file, line and column represented by the given source
* location, as specified in a # line directive.
*
* Example: given the following source code in a file somefile.c
*
* \code
* #123 "dummy.c" 1
*
* static int func(void)
* {
* return 0;
* }
* \endcode
*
* the location information returned by this function would be
*
* File: dummy.c Line: 124 Column: 12
*
* whereas clang_getExpansionLocation would have returned
*
* File: somefile.c Line: 3 Column: 12
*
* \param location the location within a source file that will be decomposed
* into its parts.
*
* \param filename [out] if non-NULL, will be set to the filename of the
* source location. Note that filenames returned will be for "virtual" files,
* which don't necessarily exist on the machine running clang - e.g. when
* parsing preprocessed output obtained from a different environment. If
* a non-NULL value is passed in, remember to dispose of the returned value
* using \c clang_disposeString() once you've finished with it. For an invalid
* source location, an empty string is returned.
*
* \param line [out] if non-NULL, will be set to the line number of the
* source location. For an invalid source location, zero is returned.
*
* \param column [out] if non-NULL, will be set to the column number of the
* source location. For an invalid source location, zero is returned.
*)
procedure clang_getPresumedLocation(location: TCXSourceLocation; filename: PCXString; line: PCardinal; column: PCardinal); cdecl external LIBCLANG;
(**
* Legacy API to retrieve the file, line, column, and offset represented
* by the given source location.
*
* This interface has been replaced by the newer interface
* #clang_getExpansionLocation(). See that interface's documentation for
* details.
*)
procedure clang_getInstantiationLocation(location: TCXSourceLocation; _file: PCXFile; line: PCardinal; column: PCardinal; offset: PCardinal); cdecl external LIBCLANG;
(**
* Retrieve the file, line, column, and offset represented by
* the given source location.
*
* If the location refers into a macro instantiation, return where the
* location was originally spelled in the source file.
*
* \param location the location within a source file that will be decomposed
* into its parts.
*
* \param file [out] if non-NULL, will be set to the file to which the given
* source location points.
*
* \param line [out] if non-NULL, will be set to the line to which the given
* source location points.
*
* \param column [out] if non-NULL, will be set to the column to which the given
* source location points.
*
* \param offset [out] if non-NULL, will be set to the offset into the
* buffer to which the given source location points.
*)
procedure clang_getSpellingLocation(location: TCXSourceLocation; _file: PCXFile; line: PCardinal; column: PCardinal; offset: PCardinal); cdecl external LIBCLANG;
(**
* Retrieve the file, line, column, and offset represented by
* the given source location.
*
* If the location refers into a macro expansion, return where the macro was
* expanded or where the macro argument was written, if the location points at
* a macro argument.
*
* \param location the location within a source file that will be decomposed
* into its parts.
*
* \param file [out] if non-NULL, will be set to the file to which the given
* source location points.
*
* \param line [out] if non-NULL, will be set to the line to which the given
* source location points.
*
* \param column [out] if non-NULL, will be set to the column to which the given
* source location points.
*
* \param offset [out] if non-NULL, will be set to the offset into the
* buffer to which the given source location points.
*)
procedure clang_getFileLocation(location: TCXSourceLocation; _file: PCXFile; line: PCardinal; column: PCardinal; offset: PCardinal); cdecl external LIBCLANG;
(**
* Retrieve a source location representing the first character within a
* source range.
*)
function clang_getRangeStart(range: TCXSourceRange): TCXSourceLocation; cdecl external LIBCLANG;
(**
* Retrieve a source location representing the last character within a
* source range.
*)
function clang_getRangeEnd(range: TCXSourceRange): TCXSourceLocation; cdecl external LIBCLANG;
(**
* Identifies an array of ranges.
*)
type
TCXSourceRangeList = record
count: Cardinal;
ranges: PCXSourceRange;
end;
PCXSourceRangeList = ^TCXSourceRangeList;
(**
* Retrieve all ranges that were skipped by the preprocessor.
*
* The preprocessor will skip lines when they are surrounded by an
* if/ifdef/ifndef directive whose condition does not evaluate to true.
*)
function clang_getSkippedRanges(tu: TCXTranslationUnit; _file: TCXFile): PCXSourceRangeList; cdecl external LIBCLANG;
(**
* Retrieve all ranges from all files that were skipped by the
* preprocessor.
*
* The preprocessor will skip lines when they are surrounded by an
* if/ifdef/ifndef directive whose condition does not evaluate to true.
*)
function clang_getAllSkippedRanges(tu: TCXTranslationUnit): PCXSourceRangeList; cdecl external LIBCLANG;
(**
* Destroy the given \c CXSourceRangeList.
*)
procedure clang_disposeSourceRangeList(ranges: PCXSourceRangeList); cdecl external LIBCLANG;
(**
* @}
*)
(**
* \defgroup CINDEX_DIAG Diagnostic reporting
*
* @{
*)
(**
* Describes the severity of a particular diagnostic.
*)
type
TCXDiagnosticSeverity = Integer;
const
CXDiagnostic_Ignored = 0;
CXDiagnostic_Note = 1;
CXDiagnostic_Warning = 2;
CXDiagnostic_Error = 3;
CXDiagnostic_Fatal = 4;
(**
* A single diagnostic, containing the diagnostic's severity,
* location, text, source ranges, and fix-it hints.
*)