From b1c031be513705d924038f497279b9b599868ba1 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 9 Aug 2010 22:28:58 +0000 Subject: [PATCH] Instead of having a specific CXTranslationUnit_* option flag for "editing" mode, introduce a separate function clang_defaultEditingTranslationUnitOptions() that retrieves the set of options. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110613 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang-c/Index.h | 45 ++++++++++++++------------ lib/AST/AttrImpl.cpp | 1 + tools/c-index-test/c-index-test.c | 2 +- tools/libclang/CIndex.cpp | 7 ++-- tools/libclang/libclang.darwin.exports | 1 + tools/libclang/libclang.exports | 1 + 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 0885037321..ff1f89c17f 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -661,16 +661,17 @@ enum CXTranslationUnit_Flags { CXTranslationUnit_DetailedPreprocessingRecord = 0x01, /** - * \brief A flag that indicates that the intent of parsing the - * given translation unit is for live editing of the file. + * \brief Used to indicate that the translation unit is incomplete. * - * This flag is essentially a meta-flag that callers can use to indicate - * that the translation unit is being edited and, therefore, is likely to - * be reparsed many times. It enables an unspecified set of optimizations - * (e.g., the precompiled preamble) geared toward improving the performance - * of \c clang_reparseTranslationUnit(). + * When a translation unit is considered "incomplete", semantic + * analysis that is typically performed at the end of the + * translation unit will be suppressed. For example, this suppresses + * the completion of tentative declarations in C and of + * instantiation of implicitly-instantiation function templates in + * C++. This option is typically used when parsing a header with the + * intent of producing a precompiled header. */ - CXTranslationUnit_Editing = 0x02, + CXTranslationUnit_Incomplete = 0x02, /** * \brief Used to indicate that the translation unit should be built with an @@ -686,21 +687,23 @@ enum CXTranslationUnit_Flags { * clang_reparseTranslationUnit() will re-use the implicit * precompiled header to improve parsing performance. */ - CXTranslationUnit_PrecompiledPreamble = 0x04, - /** - * \brief Used to indicate that the translation unit is incomplete. - * - * When a translation unit is considered "incomplete", semantic - * analysis that is typically performed at the end of the - * translation unit will be suppressed. For example, this suppresses - * the completion of tentative declarations in C and of - * instantiation of implicitly-instantiation function templates in - * C++. This option is typically used when parsing a header with the - * intent of producing a precompiled header. - */ - CXTranslationUnit_Incomplete = 0x08 + CXTranslationUnit_PrecompiledPreamble = 0x04 }; +/** + * \brief Returns the set of flags that is suitable for parsing a translation + * unit that is being edited. + * + * The set of flags returned provide options for \c clang_parseTranslationUnit() + * to indicate that the translation unit is likely to be reparsed many times, + * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly + * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag + * set contains an unspecified set of optimizations (e.g., the precompiled + * preamble) geared toward improving the performance of these routines. The + * set of optimizations enabled may change from one version to the next. + */ +CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(); + /** * \brief Parse the given source file and the translation unit corresponding * to that file. diff --git a/lib/AST/AttrImpl.cpp b/lib/AST/AttrImpl.cpp index d9c0b5af43..d4d6bfe066 100644 --- a/lib/AST/AttrImpl.cpp +++ b/lib/AST/AttrImpl.cpp @@ -130,6 +130,7 @@ DEF_SIMPLE_ATTR_CLONE(VecReturn) DEF_SIMPLE_ATTR_CLONE(WarnUnusedResult) DEF_SIMPLE_ATTR_CLONE(Weak) DEF_SIMPLE_ATTR_CLONE(WeakImport) + DEF_SIMPLE_ATTR_CLONE(WeakRef) DEF_SIMPLE_ATTR_CLONE(X86ForceAlignArgPointer) diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index c3ef794235..be5084b7b6 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -33,7 +33,7 @@ static unsigned getDefaultParsingOptions() { unsigned options = CXTranslationUnit_DetailedPreprocessingRecord; if (getenv("CINDEXTEST_EDITING")) - options |= CXTranslationUnit_Editing; + options |= clang_defaultEditingTranslationUnitOptions(); return options; } diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 344960f813..e8d2cad849 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -1169,6 +1169,10 @@ CXTranslationUnit clang_createTranslationUnit(CXIndex CIdx, 0, 0, true); } +unsigned clang_defaultEditingTranslationUnitOptions() { + return CXTranslationUnit_PrecompiledPreamble; +} + CXTranslationUnit clang_createTranslationUnitFromSourceFile(CXIndex CIdx, const char *source_filename, @@ -1194,9 +1198,6 @@ CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx, CIndexer *CXXIdx = static_cast(CIdx); - // The "editing" option implies other options. - if (options & CXTranslationUnit_Editing) - options |= CXTranslationUnit_PrecompiledPreamble; bool PrecompilePreamble = options & CXTranslationUnit_PrecompiledPreamble; bool CompleteTranslationUnit = ((options & CXTranslationUnit_Incomplete) == 0); diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports index 8ebdf9916e..a53595b7cb 100644 --- a/tools/libclang/libclang.darwin.exports +++ b/tools/libclang/libclang.darwin.exports @@ -14,6 +14,7 @@ _clang_createIndex _clang_createTranslationUnit _clang_createTranslationUnitFromSourceFile _clang_defaultCodeCompleteOptions +_clang_defaultEditingTranslationUnitOptions _clang_defaultDiagnosticDisplayOptions _clang_disposeCodeCompleteResults _clang_disposeDiagnostic diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports index 793b042808..70aad53315 100644 --- a/tools/libclang/libclang.exports +++ b/tools/libclang/libclang.exports @@ -14,6 +14,7 @@ clang_createIndex clang_createTranslationUnit clang_createTranslationUnitFromSourceFile clang_defaultCodeCompleteOptions +clang_defaultEditingTranslationUnitOptions clang_defaultDiagnosticDisplayOptions clang_disposeCodeCompleteResults clang_disposeDiagnostic -- 2.40.0