Ejemplo n.º 1
0
func CreateIndex(exclude_decl_from_pch, display_diags bool) Index {
	var arg1, arg2 C.int
	if exclude_decl_from_pch {
		arg1 = 1
	} else {
		arg1 = 0
	}
	if display_diags {
		arg2 = 1
	} else {
		arg1 = 0
	}
	p := C.clang_createIndex(arg1, arg2)
	return Index{p}
}
Ejemplo n.º 2
0
/*
	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).
*/
func NewIndex(excludeDeclarationsFromPCH int32, displayDiagnostics int32) Index {
	return Index{C.clang_createIndex(C.int(excludeDeclarationsFromPCH), C.int(displayDiagnostics))}
}
Ejemplo n.º 3
0
// NewIndex 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:
//
//   // 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);
//
// 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).
func NewIndex(excludeDeclarationsFromPCH, displayDiagnostics int) Index {
	idx := C.clang_createIndex(C.int(excludeDeclarationsFromPCH),
		C.int(displayDiagnostics))
	return Index{idx}
}