aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-07-23 00:33:23 +0000
committerDouglas Gregor <dgregor@apple.com>2010-07-23 00:33:23 +0000
commitbe2d8c60969e6829a6994a66eb69de663a4dbe89 (patch)
treeed31fe0c9ae71266c78001931d4fc8bbbd6bd598 /clang/tools/c-index-test/c-index-test.c
parentf2d75670b7eee180ea6cb22cfa7c581c9fad26e5 (diff)
downloadllvm-be2d8c60969e6829a6994a66eb69de663a4dbe89.zip
llvm-be2d8c60969e6829a6994a66eb69de663a4dbe89.tar.gz
llvm-be2d8c60969e6829a6994a66eb69de663a4dbe89.tar.bz2
Basic plumbing for generating a precompiled preamble for an
ASTUnit/CXTranslationUnit. We can't actually use this preamble yet, however. llvm-svn: 109202
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r--clang/tools/c-index-test/c-index-test.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 9d56eec..db8ce18 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -28,6 +28,16 @@ char *basename(const char* path)
extern char *basename(const char *);
#endif
+/// \brief Return the default parsing options.
+static unsigned getDefaultParsingOptions() {
+ unsigned options = CXTranslationUnit_DetailedPreprocessingRecord;
+
+ if (getenv("CINDEXTEST_EDITING"))
+ options |= CXTranslationUnit_Editing;
+
+ return options;
+}
+
static void PrintExtent(FILE *out, unsigned begin_line, unsigned begin_column,
unsigned end_line, unsigned end_column) {
fprintf(out, "[%d:%d - %d:%d]", begin_line, begin_column,
@@ -613,11 +623,12 @@ int perform_test_reparse_source(int argc, const char **argv, int trials,
return -1;
}
- TU = clang_createTranslationUnitFromSourceFile(Idx, 0,
- argc - num_unsaved_files,
- argv + num_unsaved_files,
- num_unsaved_files,
- unsaved_files);
+ TU = clang_parseTranslationUnit(Idx, 0,
+ argv + num_unsaved_files,
+ argc - num_unsaved_files,
+ unsaved_files,
+ num_unsaved_files,
+ getDefaultParsingOptions());
if (!TU) {
fprintf(stderr, "Unable to load translation unit!\n");
free_remapped_files(unsaved_files, num_unsaved_files);