diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index d05510e28142..904585f1082a 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -4494,7 +4494,12 @@ typedef enum { * \brief Implicit function/class template instantiations should be indexed. * If this is not set, implicit instantiations will be ignored. */ - CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4 + CXIndexOpt_IndexImplicitTemplateInstantiations = 0x4, + + /** + * \brief Suppress all compiler warnings when parsing for indexing. + */ + CXIndexOpt_SuppressWarnings = 0x8 } CXIndexOptFlags; /** diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp index aad6e02fe986..85b638530f10 100644 --- a/clang/tools/libclang/Indexing.cpp +++ b/clang/tools/libclang/Indexing.cpp @@ -346,6 +346,9 @@ static void clang_indexSourceFile_Impl(void *UserData) { if (!requestedToGetTU) CInvok->getPreprocessorOpts().DetailedRecord = false; + if (index_options & CXIndexOpt_SuppressWarnings) + CInvok->getDiagnosticOpts().IgnoreWarnings = true; + ASTUnit *Unit = ASTUnit::create(CInvok.getPtr(), Diags, /*CaptureDiagnostics=*/true); OwningPtr CXTU(new CXTUOwner(MakeCXTranslationUnit(Unit)));