diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -423,7 +423,7 @@ Preprocessor *PP = &Compiler.getPreprocessor(); Preprocessor *ModuleExpanderPP = PP; - if (Context.getLangOpts().Modules && OverlayFS != nullptr) { + if (Context.getLangOpts().hasModules() && OverlayFS != nullptr) { auto ModuleExpander = std::make_unique( &Compiler, OverlayFS); ModuleExpanderPP = ModuleExpander->getPreprocessor(); diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp --- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp +++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp @@ -80,7 +80,7 @@ Diags.setSourceManager(&Sources); - LangOpts.Modules = false; + LangOpts.ClangModules = false; auto HSO = std::make_shared(); *HSO = Compiler.getHeaderSearchOpts(); diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s bugprone-suspicious-include %t -- -- -isystem %S/Inputs/Headers -fmodules +// RUN: %check_clang_tidy %s bugprone-suspicious-include %t -- -- -isystem %S/Inputs/Headers // clang-format off diff --git a/clang-tools-extra/test/pp-trace/pp-trace-modules.cpp b/clang-tools-extra/test/pp-trace/pp-trace-modules.cpp --- a/clang-tools-extra/test/pp-trace/pp-trace-modules.cpp +++ b/clang-tools-extra/test/pp-trace/pp-trace-modules.cpp @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -- -x objective-c++ -undef -target x86_64 -std=c++11 -fmodules -fcxx-modules -fmodules-cache-path=%t -I%S -I%S/Input | FileCheck --strict-whitespace %s +// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -- -x objective-c++ -undef -target x86_64 -std=c++11 -fmodules -fmodules-cache-path=%t -I%S -I%S/Input | FileCheck --strict-whitespace %s // CHECK: --- diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -159,6 +159,8 @@ "'%0': unable to use AST files with this tool">; def err_drv_no_module_support : Error< "'%0': unable to use module files with this tool">; +def err_drv_clang_module_cxx_module_conflicts : Error < + "Unable to use clang module and c++20 module at the same time.">; def err_drv_clang_unsupported : Error< "the clang compiler does not support '%0'">; def err_drv_clang_unsupported_opt_cxx_darwin_i386 : Error< diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -241,6 +241,8 @@ def err_modules_embed_file_not_found : Error<"file '%0' specified by '-fmodules-embed-file=' not found">, DefaultFatal; +def err_conflicts_clang_module_and_cxx20_module : + Error<"Unable to use clang module and c++20 module at the same time.">; def err_module_header_file_not_found : Error<"module header file '%0' not found">, DefaultFatal; diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def --- a/clang/include/clang/Basic/Features.def +++ b/clang/include/clang/Basic/Features.def @@ -105,7 +105,7 @@ FEATURE(objc_fixed_enum, LangOpts.ObjC) FEATURE(objc_instancetype, LangOpts.ObjC) FEATURE(objc_kindof, LangOpts.ObjC) -FEATURE(objc_modules, LangOpts.ObjC && LangOpts.Modules) +FEATURE(objc_modules, LangOpts.ObjC && LangOpts.ClangModules) FEATURE(objc_nonfragile_abi, LangOpts.ObjCRuntime.isNonFragile()) FEATURE(objc_property_explicit_atomic, true) FEATURE(objc_protocol_qualifier_mangling, true) @@ -222,7 +222,7 @@ FEATURE(is_trivially_constructible, LangOpts.CPlusPlus) FEATURE(is_trivially_copyable, LangOpts.CPlusPlus) FEATURE(is_union, LangOpts.CPlusPlus) -FEATURE(modules, LangOpts.Modules) +FEATURE(modules, LangOpts.hasModules()) FEATURE(safe_stack, LangOpts.Sanitize.has(SanitizerKind::SafeStack)) FEATURE(shadow_call_stack, LangOpts.Sanitize.has(SanitizerKind::ShadowCallStack)) diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h --- a/clang/include/clang/Basic/LangOptions.h +++ b/clang/include/clang/Basic/LangOptions.h @@ -398,6 +398,11 @@ return isCompilingModule() || ModulesLocalVisibility; } + /// are clang module or c++20 module (or c++ module ts) enabled? + bool hasModules() const { + return ClangModules || CPlusPlusModules || ModulesTS; + } + bool isSignedOverflowDefined() const { return getSignedOverflowBehavior() == SOB_Defined; } diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -162,7 +162,7 @@ BENIGN_LANGOPT(EmitAllDecls , 1, 0, "emitting all declarations") LANGOPT(MathErrno , 1, 1, "errno in math functions") BENIGN_LANGOPT(HeinousExtensions , 1, 0, "extensions that we really don't like and may be ripped out at any time") -LANGOPT(Modules , 1, 0, "modules semantics") +LANGOPT(ClangModules , 1, 0, "clang modules semantics") COMPATIBLE_LANGOPT(ModulesTS , 1, 0, "C++ Modules TS syntax") COMPATIBLE_LANGOPT(CPlusPlusModules, 1, 0, "C++ modules syntax") BENIGN_ENUM_LANGOPT(CompilingModule, CompilingModuleKind, 2, CMK_None, diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -2189,7 +2189,7 @@ Flags<[CC1Option]>, HelpText<"Enable support for the C++ Modules TS">, MarshallingInfoFlag>; defm modules : BoolFOption<"modules", - LangOpts<"Modules">, Default, + LangOpts<"ClangModules">, DefaultFalse, PosFlag, NegFlag, BothFlags<[NoXarchOption, CoreOption]>>; def fmodule_maps : Flag <["-"], "fmodule-maps">, Flags<[CoreOption]>, Alias; diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -606,7 +606,7 @@ // FIXME: Find a spare bit on IdentifierInfo and store a // HasModuleMacros flag. if (!II->hasMacroDefinition() || - (!PP.getLangOpts().Modules && + (!PP.getLangOpts().hasModules() && !PP.getLangOpts().ModulesLocalVisibility) || !PP.CurSubmoduleState->VisibleModules.getGeneration()) return nullptr; @@ -1090,7 +1090,7 @@ } bool isMacroDefined(const IdentifierInfo *II) { return II->hasMacroDefinition() && - (!getLangOpts().Modules || (bool)getMacroDefinition(II)); + (!getLangOpts().hasModules() || (bool)getMacroDefinition(II)); } /// Determine whether II is defined as a macro within the module M, diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -1734,7 +1734,7 @@ return true; } edit::Commit commit(*Editor); - if (Ctx.getLangOpts().Modules) + if (Ctx.getLangOpts().ClangModules) commit.insert(Loc, "#ifndef NS_ENUM\n@import Foundation;\n#endif\n"); else commit.insert(Loc, "#ifndef NS_ENUM\n#import \n#endif\n"); diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -4420,7 +4420,7 @@ bool IsScopedUsingClassTag, bool IsFixed) { auto *Enum = new (C, DC) EnumDecl(C, DC, StartLoc, IdLoc, Id, PrevDecl, IsScoped, IsScopedUsingClassTag, IsFixed); - Enum->setMayHaveOutOfDateDef(C.getLangOpts().Modules); + Enum->setMayHaveOutOfDateDef(C.getLangOpts().hasModules()); C.getTypeDeclType(Enum, PrevDecl); return Enum; } @@ -4429,7 +4429,7 @@ EnumDecl *Enum = new (C, ID) EnumDecl(C, nullptr, SourceLocation(), SourceLocation(), nullptr, nullptr, false, false, false); - Enum->setMayHaveOutOfDateDef(C.getLangOpts().Modules); + Enum->setMayHaveOutOfDateDef(C.getLangOpts().hasModules()); return Enum; } @@ -4564,7 +4564,7 @@ IdentifierInfo *Id, RecordDecl* PrevDecl) { RecordDecl *R = new (C, DC) RecordDecl(Record, TK, C, DC, StartLoc, IdLoc, Id, PrevDecl); - R->setMayHaveOutOfDateDef(C.getLangOpts().Modules); + R->setMayHaveOutOfDateDef(C.getLangOpts().hasModules()); C.getTypeDeclType(R, PrevDecl); return R; @@ -4574,7 +4574,7 @@ RecordDecl *R = new (C, ID) RecordDecl(Record, TTK_Struct, C, nullptr, SourceLocation(), SourceLocation(), nullptr, nullptr); - R->setMayHaveOutOfDateDef(C.getLangOpts().Modules); + R->setMayHaveOutOfDateDef(C.getLangOpts().hasModules()); return R; } diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -136,7 +136,7 @@ bool DelayTypeCreation) { auto *R = new (C, DC) CXXRecordDecl(CXXRecord, TK, C, DC, StartLoc, IdLoc, Id, PrevDecl); - R->setMayHaveOutOfDateDef(C.getLangOpts().Modules); + R->setMayHaveOutOfDateDef(C.getLangOpts().hasModules()); // FIXME: DelayTypeCreation seems like such a hack if (!DelayTypeCreation) diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -1503,7 +1503,7 @@ auto *Result = new (C, DC) ObjCInterfaceDecl(C, DC, atLoc, Id, typeParamList, ClassLoc, PrevDecl, isInternal); - Result->Data.setInt(!C.getLangOpts().Modules); + Result->Data.setInt(!C.getLangOpts().ClangModules); C.getObjCInterfaceType(Result, PrevDecl); return Result; } @@ -1513,7 +1513,7 @@ auto *Result = new (C, ID) ObjCInterfaceDecl(C, nullptr, SourceLocation(), nullptr, nullptr, SourceLocation(), nullptr, false); - Result->Data.setInt(!C.getLangOpts().Modules); + Result->Data.setInt(!C.getLangOpts().ClangModules); return Result; } @@ -1899,7 +1899,7 @@ ObjCProtocolDecl *PrevDecl) { auto *Result = new (C, DC) ObjCProtocolDecl(C, DC, Id, nameLoc, atStartLoc, PrevDecl); - Result->Data.setInt(!C.getLangOpts().Modules); + Result->Data.setInt(!C.getLangOpts().ClangModules); return Result; } @@ -1908,7 +1908,7 @@ ObjCProtocolDecl *Result = new (C, ID) ObjCProtocolDecl(C, nullptr, nullptr, SourceLocation(), SourceLocation(), nullptr); - Result->Data.setInt(!C.getLangOpts().Modules); + Result->Data.setInt(!C.getLangOpts().ClangModules); return Result; } diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -551,7 +551,7 @@ SanStats->finish(); if (CodeGenOpts.Autolink && - (Context.getLangOpts().Modules || !LinkerOptionsMetadata.empty())) { + (Context.getLangOpts().hasModules() || !LinkerOptionsMetadata.empty())) { EmitModuleLinkOptions(); } diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3438,24 +3438,22 @@ return false; } -static void RenderModulesOptions(Compilation &C, const Driver &D, +static bool RenderModulesOptions(Compilation &C, const Driver &D, const ArgList &Args, const InputInfo &Input, const InputInfo &Output, - ArgStringList &CmdArgs, bool &HaveModules) { - // -fmodules enables the use of precompiled modules (off by default). - // Users can pass -fno-cxx-modules to turn off modules support for - // C++/Objective-C++ programs. + ArgStringList &CmdArgs, bool HaveCXXModules) { + if (Args.hasFlag(options::OPT_fmodules, options::OPT_fno_modules, false) && + HaveCXXModules) + D.Diag(clang::diag::err_drv_clang_module_cxx_module_conflicts); + + // -fmodules enables the use of clang modules (off by default). bool HaveClangModules = false; if (Args.hasFlag(options::OPT_fmodules, options::OPT_fno_modules, false)) { - bool AllowedInCXX = Args.hasFlag(options::OPT_fcxx_modules, - options::OPT_fno_cxx_modules, true); - if (AllowedInCXX || !types::isCXX(Input.getType())) { - CmdArgs.push_back("-fmodules"); - HaveClangModules = true; - } + CmdArgs.push_back("-fmodules"); + HaveClangModules = true; } - HaveModules |= HaveClangModules; + bool HaveModules = HaveCXXModules || HaveClangModules; if (Args.hasArg(options::OPT_fmodules_ts)) { CmdArgs.push_back("-fmodules-ts"); HaveModules = true; @@ -3610,6 +3608,8 @@ CmdArgs.push_back("-fmodules-validate-system-headers"); Args.AddLastArg(CmdArgs, options::OPT_fmodules_disable_diagnostic_validation); + + return HaveModules; } static void RenderCharacterOptions(const ArgList &Args, const llvm::Triple &T, @@ -6315,12 +6315,15 @@ options::OPT_finline_hint_functions, options::OPT_fno_inline_functions); + bool HaveCXXModules = Args.hasFlag( + options::OPT_fcxx_modules, options::OPT_fno_cxx_modules, + Std && (Std->containsValue("c++2a") || Std->containsValue("c++20") || + Std->containsValue("c++latest"))); + // FIXME: Find a better way to determine whether the language has modules // support by default, or just assume that all languages do. bool HaveModules = - Std && (Std->containsValue("c++2a") || Std->containsValue("c++20") || - Std->containsValue("c++latest")); - RenderModulesOptions(C, D, Args, Input, Output, CmdArgs, HaveModules); + RenderModulesOptions(C, D, Args, Input, Output, CmdArgs, HaveCXXModules); if (Args.hasFlag(options::OPT_fpch_validate_input_files_content, options::OPT_fno_pch_validate_input_files_content, false)) diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -2257,7 +2257,7 @@ } // Disable the preprocessing record if modules are not enabled. - if (!Clang->getLangOpts().Modules) + if (!Clang->getLangOpts().hasModules()) PreprocessorOpts.DetailedRecord = false; std::unique_ptr Act; diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -485,7 +485,7 @@ PP->setPreprocessedOutput(getPreprocessorOutputOpts().ShowCPP); - if (PP->getLangOpts().Modules && PP->getLangOpts().ImplicitModules) { + if (PP->getLangOpts().hasModules() && PP->getLangOpts().ImplicitModules) { std::string ModuleHash = getInvocation().getModuleHash(); PP->getHeaderSearchInfo().setModuleHash(ModuleHash); PP->getHeaderSearchInfo().setModuleCachePath( diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -584,6 +584,10 @@ if (!BeginInvocation(CI)) return false; + if (CI.getLangOpts().ClangModules && CI.getLangOpts().CPlusPlusModules) + CI.getDiagnostics().Report( + diag::err_conflicts_clang_module_and_cxx20_module); + // If we're replaying the build of an AST file, import it and set up // the initial state from its build. if (ReplayASTFile) { @@ -879,7 +883,7 @@ return false; CI.setASTReader(static_cast(FinalReader.get())); CI.getASTContext().setExternalSource(source); - } else if (CI.getLangOpts().Modules || + } else if (CI.getLangOpts().hasModules() || !CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) { // Use PCM or PCH. assert(hasPCHSupport() && "This action does not have PCH support!"); @@ -910,7 +914,7 @@ // If modules are enabled, create the AST reader before creating // any builtins, so that all declarations know that they might be // extended by an external source. - if (CI.getLangOpts().Modules || !CI.hasASTContext() || + if (CI.getLangOpts().hasModules() || !CI.hasASTContext() || !CI.getASTContext().getExternalSource()) { CI.createASTReader(); CI.getASTReader()->setDeserializationListener(DeserialListener, @@ -925,7 +929,7 @@ // Initialize built-in info as long as we aren't using an external AST // source. - if (CI.getLangOpts().Modules || !CI.hasASTContext() || + if (CI.getLangOpts().hasModules() || !CI.hasASTContext() || !CI.getASTContext().getExternalSource()) { Preprocessor &PP = CI.getPreprocessor(); PP.getBuiltinInfo().initializeBuiltins(PP.getIdentifierTable(), @@ -933,7 +937,7 @@ } else { // FIXME: If this is a problem, recover from it by creating a multiplex // source. - assert((!CI.getLangOpts().Modules || CI.getASTReader()) && + assert((!CI.getLangOpts().hasModules() || CI.getASTReader()) && "modules enabled but created an external source that " "doesn't support modules"); } diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -212,7 +212,7 @@ bool GenerateModuleFromModuleMapAction::BeginSourceFileAction( CompilerInstance &CI) { - if (!CI.getLangOpts().Modules) { + if (!CI.getLangOpts().ClangModules) { CI.getDiagnostics().Report(diag::err_module_build_requires_fmodules); return false; } @@ -263,7 +263,7 @@ bool GenerateHeaderModuleAction::PrepareToExecuteAction( CompilerInstance &CI) { - if (!CI.getLangOpts().Modules) { + if (!CI.getLangOpts().hasModules()) { CI.getDiagnostics().Report(diag::err_header_module_requires_modules); return false; } diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -1144,12 +1144,12 @@ break; case tok::pp___public_macro: - if (getLangOpts().Modules || getLangOpts().ModulesLocalVisibility) + if (getLangOpts().hasModules() || getLangOpts().ModulesLocalVisibility) return HandleMacroPublicDirective(Result); break; case tok::pp___private_macro: - if (getLangOpts().Modules || getLangOpts().ModulesLocalVisibility) + if (getLangOpts().hasModules() || getLangOpts().ModulesLocalVisibility) return HandleMacroPrivateDirective(); break; } @@ -2057,7 +2057,8 @@ // Determine whether we should try to import the module for this #include, if // there is one. Don't do so if precompiled module support is disabled or we // are processing this module textually (because we're building the module). - if (Action == Enter && File && SuggestedModule && getLangOpts().Modules && + if (Action == Enter && File && SuggestedModule && + getLangOpts().hasModules() && !isForModuleBuilding(SuggestedModule.getModule(), getLangOpts().CurrentModule, getLangOpts().ModuleName)) { @@ -2143,7 +2144,7 @@ // this file will have no effect. if (Action == Enter && File && !HeaderInfo.ShouldEnterIncludeFile(*this, &File->getFileEntry(), - EnterOnce, getLangOpts().Modules, + EnterOnce, getLangOpts().hasModules(), SuggestedModule.getModule())) { // Even if we've already preprocessed this header once and know that we // don't need to see its contents again, we still need to import it if it's diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -875,7 +875,7 @@ if (((LastTokenWasAt && II.isModulesImport()) || Identifier.is(tok::kw_import)) && !InMacroArgs && !DisableMacroExpansion && - (getLangOpts().Modules || getLangOpts().DebuggerSupport) && + (getLangOpts().hasModules() || getLangOpts().DebuggerSupport) && CurLexerKind != CLK_CachingLexer) { ModuleImportLoc = Identifier.getLocation(); ModuleImportPath.clear(); @@ -1285,7 +1285,7 @@ } Module *Imported = nullptr; - if (getLangOpts().Modules) { + if (getLangOpts().hasModules()) { Imported = TheModuleLoader.loadModule(ModuleImportLoc, ModuleImportPath, Module::Hidden, diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -78,7 +78,7 @@ SingleDecl = ParseObjCPropertyDynamic(AtLoc); break; case tok::objc_import: - if (getLangOpts().Modules || getLangOpts().DebuggerSupport) { + if (getLangOpts().hasModules() || getLangOpts().DebuggerSupport) { SingleDecl = ParseModuleImport(AtLoc); break; } diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -4148,7 +4148,7 @@ Modules[I]->isAvailable() ? CXAvailability_Available : CXAvailability_NotAvailable)); } - } else if (getLangOpts().Modules) { + } else if (getLangOpts().hasModules()) { // Load the named module. Module *Mod = PP.getModuleLoader().loadModule(ImportLoc, Path, Module::AllVisible, @@ -6741,7 +6741,7 @@ Builder.AddPlaceholderChunk("class"); Results.AddResult(Result(Builder.TakeString())); - if (Results.getSema().getLangOpts().Modules) { + if (Results.getSema().getLangOpts().hasModules()) { // @import name Builder.AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt, "import")); Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2218,7 +2218,7 @@ TypedefNameDecl *Decl, LookupResult &Previous) { // This is only interesting when modules are enabled. - if (!S.getLangOpts().Modules && !S.getLangOpts().ModulesLocalVisibility) + if (!S.getLangOpts().hasModules() && !S.getLangOpts().ModulesLocalVisibility) return; // Empty sets are uninteresting. @@ -2444,7 +2444,7 @@ } // Modules always permit redefinition of typedefs, as does C11. - if (getLangOpts().Modules || getLangOpts().C11) + if (getLangOpts().hasModules() || getLangOpts().C11) return; // If we have a redefinition of a typedef in C, emit a warning. This warning @@ -17986,7 +17986,7 @@ Sema::SkipBodyInfo Sema::shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc) { - if (!(getLangOpts().Modules || getLangOpts().ModulesLocalVisibility) || + if (!(getLangOpts().hasModules() || getLangOpts().ModulesLocalVisibility) || !getLangOpts().CPlusPlus) return SkipBodyInfo(); diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1234,7 +1234,7 @@ // If we are using modules, add the decl to the context in order to // serialize something meaningful. - if (getLangOpts().Modules) + if (getLangOpts().ClangModules) PushOnScopeChains(PDecl, TUScope); PDecl->startDefinition(); } else { diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -4892,7 +4892,7 @@ // If we're handling a missing symbol error, using modules, and the // special search all modules option is used, look for a missing import. - if (ErrorRecovery && getLangOpts().Modules && + if (ErrorRecovery && getLangOpts().hasModules() && getLangOpts().ModulesSearchAll) { // The following has the side effect of loading the missing module. getModuleLoader().lookupMissingImports(Typo->getName(), @@ -5463,7 +5463,6 @@ if (Correction.requiresImport()) { NamedDecl *Decl = Correction.getFoundDecl(); assert(Decl && "import required but no declaration to import"); - diagnoseMissingImport(Correction.getCorrectionRange().getBegin(), Decl, MissingImportKind::Declaration, ErrorRecovery); return; diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -11095,7 +11095,7 @@ } // end anonymous namespace void Sema::checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec) { - if (!getLangOpts().Modules) + if (!getLangOpts().hasModules()) return; ExplicitSpecializationVisibilityChecker(*this, Loc).check(Spec); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8492,7 +8492,7 @@ bool Sema::hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete) { // Easy case: if we don't have modules, all declarations are visible. - if (!getLangOpts().Modules && !getLangOpts().ModulesLocalVisibility) + if (!getLangOpts().hasModules() && !getLangOpts().ModulesLocalVisibility) return true; // If this definition was instantiated from a template, map back to the diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -703,7 +703,7 @@ } // Detailed record is important since it is used for the module cache hash. - if (LangOpts.Modules && + if (LangOpts.hasModules() && PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord && Validate) { if (Diags) { Diags->Report(diag::err_pch_pp_detailed_record) << PPOpts.DetailedRecord; @@ -784,7 +784,7 @@ DiagnosticsEngine *Diags, const LangOptions &LangOpts, const PreprocessorOptions &PPOpts) { - if (LangOpts.Modules) { + if (LangOpts.hasModules()) { if (SpecificModuleCachePath != ExistingModuleCachePath && !PPOpts.AllowPCHWithDifferentModulesCachePath) { if (Diags) @@ -1246,7 +1246,7 @@ void ASTReader::Error(StringRef Msg) const { Error(diag::err_fe_pch_malformed, Msg); - if (PP.getLangOpts().Modules && !Diags.isDiagnosticInFlight() && + if (PP.getLangOpts().hasModules() && !Diags.isDiagnosticInFlight() && !PP.getHeaderSearchInfo().getModuleCachePath().empty()) { Diag(diag::note_module_cache_path) << PP.getHeaderSearchInfo().getModuleCachePath(); @@ -2062,7 +2062,7 @@ Deserializing AnIdentifier(this); unsigned PriorGeneration = 0; - if (getContext().getLangOpts().Modules) + if (getContext().getLangOpts().hasModules()) PriorGeneration = IdentifierGeneration[&II]; // If there is a global index, look there first to determine which modules @@ -2089,7 +2089,7 @@ II->setOutOfDate(false); // Update the generation for this identifier. - if (getContext().getLangOpts().Modules) + if (getContext().getLangOpts().hasModules()) IdentifierGeneration[II] = getGeneration(); } @@ -4108,7 +4108,7 @@ return false; if (TriedLoadingGlobalIndex || !UseGlobalIndex || - !PP.getLangOpts().Modules) + !PP.getLangOpts().hasModules()) return true; // Try to load the global index. @@ -4129,8 +4129,8 @@ } bool ASTReader::isGlobalIndexUnavailable() const { - return PP.getLangOpts().Modules && UseGlobalIndex && - !hasGlobalIndex() && TriedLoadingGlobalIndex; + return PP.getLangOpts().hasModules() && UseGlobalIndex && !hasGlobalIndex() && + TriedLoadingGlobalIndex; } static void updateModuleTimestamp(ModuleFile &MF) { @@ -4219,7 +4219,7 @@ /*ImportedBy=*/nullptr, Loaded, 0, 0, ASTFileSignature(), ClientLoadCapabilities)) { ModuleMgr.removeModules(ModuleMgr.begin() + NumModules, - PP.getLangOpts().Modules + PP.getLangOpts().hasModules() ? &PP.getHeaderSearchInfo().getModuleMap() : nullptr); @@ -9325,7 +9325,7 @@ // FIXME: Check for =delete/=default? // FIXME: Complain about ODR violations here? const FunctionDecl *Defn = nullptr; - if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) { + if (!getContext().getLangOpts().hasModules() || !FD->hasBody(Defn)) { FD->setLazyBody(PB->second); } else { auto *NonConstDefn = const_cast(Defn); @@ -9349,7 +9349,7 @@ } ObjCMethodDecl *MD = cast(PB->first); - if (!getContext().getLangOpts().Modules || !MD->hasBody()) + if (!getContext().getLangOpts().hasModules() || !MD->hasBody()) MD->setLazyBody(PB->second); } PendingBodies.clear(); diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -758,7 +758,7 @@ // If this is a definition subject to the ODR, and we already have a // definition, merge this one into it. if (ED->isCompleteDefinition() && - Reader.getContext().getLangOpts().Modules && + Reader.getContext().getLangOpts().hasModules() && Reader.getContext().getLangOpts().CPlusPlus) { EnumDecl *&OldDef = Reader.EnumDefinitions[ED->getCanonicalDecl()]; if (!OldDef) { @@ -1018,7 +1018,7 @@ if (InsertPos) CommonPtr->Specializations.InsertNode(FTInfo, InsertPos); else { - assert(Reader.getContext().getLangOpts().Modules && + assert(Reader.getContext().getLangOpts().hasModules() && "already deserialized this template specialization"); mergeRedeclarable(FD, ExistingInfo->getFunction(), Redecl); } @@ -2564,7 +2564,7 @@ RedeclarableResult &Redecl, DeclID TemplatePatternID) { // If modules are not available, there is no reason to perform this merge. - if (!Reader.getContext().getLangOpts().Modules) + if (!Reader.getContext().getLangOpts().hasModules()) return; // If we're not the canonical declaration, we don't need to merge. @@ -2689,7 +2689,7 @@ /// identical class definitions from two different modules. void ASTDeclReader::mergeMergeable(LifetimeExtendedTemporaryDecl *D) { // If modules are not available, there is no reason to perform this merge. - if (!Reader.getContext().getLangOpts().Modules) + if (!Reader.getContext().getLangOpts().hasModules()) return; LifetimeExtendedTemporaryDecl *LETDecl = D; @@ -2711,7 +2711,7 @@ template void ASTDeclReader::mergeMergeable(Mergeable *D) { // If modules are not available, there is no reason to perform this merge. - if (!Reader.getContext().getLangOpts().Modules) + if (!Reader.getContext().getLangOpts().hasModules()) return; // ODR-based merging is performed in C++ and in some cases (tag types) in C. diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1426,7 +1426,7 @@ WriteInputFiles(Context.SourceMgr, PP.getHeaderSearchInfo().getHeaderSearchOpts(), - PP.getLangOpts().Modules); + PP.getLangOpts().hasModules()); Stream.ExitBlock(); } @@ -3268,7 +3268,7 @@ /// recent declaration in any module that imports this one. static NamedDecl *getDeclForLocalLookup(const LangOptions &LangOpts, NamedDecl *D) { - if (!LangOpts.Modules || !D->isFromASTFile()) + if (!LangOpts.hasModules() || !D->isFromASTFile()) return D; if (Decl *Redecl = D->getPreviousDecl()) { diff --git a/clang/test/ClangScanDeps/Inputs/header-search-pruning/cdb.json b/clang/test/ClangScanDeps/Inputs/header-search-pruning/cdb.json --- a/clang/test/ClangScanDeps/Inputs/header-search-pruning/cdb.json +++ b/clang/test/ClangScanDeps/Inputs/header-search-pruning/cdb.json @@ -1,7 +1,7 @@ [ { "directory": "DIR", - "command": "clang -E DIR/header-search-pruning.cpp -Ibegin -I1 -Ia -I3 -I4 -I5 -I6 -Ib -I8 -Iend DEFINES -fmodules -fcxx-modules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fmodule-map-file=DIR/module.modulemap", + "command": "clang -E DIR/header-search-pruning.cpp -Ibegin -I1 -Ia -I3 -I4 -I5 -I6 -Ib -I8 -Iend DEFINES -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fmodule-map-file=DIR/module.modulemap", "file": "DIR/header-search-pruning.cpp" } ] diff --git a/clang/test/ClangScanDeps/Inputs/module_fmodule_name_cdb.json b/clang/test/ClangScanDeps/Inputs/module_fmodule_name_cdb.json --- a/clang/test/ClangScanDeps/Inputs/module_fmodule_name_cdb.json +++ b/clang/test/ClangScanDeps/Inputs/module_fmodule_name_cdb.json @@ -1,7 +1,7 @@ [ { "directory": "DIR", - "command": "clang -E DIR/modules-fmodule-name-no-module-built.m -IInputs -D INCLUDE_HEADER2 -MD -MF DIR/modules_cdb.d -fmodules -fcxx-modules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fmodule-name=header3 -fimplicit-module-maps", + "command": "clang -E DIR/modules-fmodule-name-no-module-built.m -IInputs -D INCLUDE_HEADER2 -MD -MF DIR/modules_cdb.d -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fmodule-name=header3 -fimplicit-module-maps", "file": "DIR/modules-fmodule-name-no-module-built.m" } ] diff --git a/clang/test/ClangScanDeps/Inputs/modules_cdb.json b/clang/test/ClangScanDeps/Inputs/modules_cdb.json --- a/clang/test/ClangScanDeps/Inputs/modules_cdb.json +++ b/clang/test/ClangScanDeps/Inputs/modules_cdb.json @@ -1,22 +1,22 @@ [ { "directory": "DIR", - "command": "clang -E DIR/modules_cdb_input2.cpp -IInputs -D INCLUDE_HEADER2 -MD -MF DIR/modules_cdb2.d -fmodules -fcxx-modules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps", + "command": "clang -E DIR/modules_cdb_input2.cpp -IInputs -D INCLUDE_HEADER2 -MD -MF DIR/modules_cdb2.d -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps", "file": "DIR/modules_cdb_input2.cpp" }, { "directory": "DIR", - "command": "clang -E DIR/modules_cdb_input.cpp -IInputs -fmodules -fcxx-modules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps", + "command": "clang -E DIR/modules_cdb_input.cpp -IInputs -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps", "file": "DIR/modules_cdb_input.cpp" }, { "directory": "DIR", - "command": "clang -E DIR/modules_cdb_input.cpp -IInputs -fmodules -fcxx-modules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -o a.o", + "command": "clang -E DIR/modules_cdb_input.cpp -IInputs -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -o a.o", "file": "DIR/modules_cdb_input.cpp" }, { "directory": "DIR", - "command": "clang -E DIR/modules_cdb_input.cpp -IInputs -fmodules -fcxx-modules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -o b.o", + "command": "clang -E DIR/modules_cdb_input.cpp -IInputs -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -o b.o", "file": "DIR/modules_cdb_input.cpp" } ] diff --git a/clang/test/ClangScanDeps/Inputs/modules_cdb_by_mod_name.json b/clang/test/ClangScanDeps/Inputs/modules_cdb_by_mod_name.json --- a/clang/test/ClangScanDeps/Inputs/modules_cdb_by_mod_name.json +++ b/clang/test/ClangScanDeps/Inputs/modules_cdb_by_mod_name.json @@ -1,12 +1,12 @@ [ { "directory": "DIR", - "command": "clang -E -IInputs -D INCLUDE_HEADER2 -MD -MF DIR/modules_cdb2.d -fmodules -fcxx-modules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -gmodules -x c++", + "command": "clang -E -IInputs -D INCLUDE_HEADER2 -MD -MF DIR/modules_cdb2.d -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -gmodules -x c++", "file": "" }, { "directory": "DIR", - "command": "clang -E -IInputs -fmodules -fcxx-modules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -x c++", + "command": "clang -E -IInputs -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -x c++", "file": "" }, ] diff --git a/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json b/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json --- a/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json +++ b/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json @@ -1,22 +1,22 @@ [ { "directory": "DIR", - "command": "clang-cl /E /IInputs /D INCLUDE_HEADER2 /clang:-MD /clang:-MF /clang:DIR/modules_cdb2_clangcl.d /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps -- DIR/modules_cdb_input2.cpp", + "command": "clang-cl /E /IInputs /D INCLUDE_HEADER2 /clang:-MD /clang:-MF /clang:DIR/modules_cdb2_clangcl.d /clang:-fmodules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps -- DIR/modules_cdb_input2.cpp", "file": "DIR/modules_cdb_input2.cpp" }, { "directory": "DIR", - "command": "clang-cl /E /IInputs /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps -- DIR/modules_cdb_input.cpp", + "command": "clang-cl /E /IInputs /clang:-fmodules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps -- DIR/modules_cdb_input.cpp", "file": "DIR/modules_cdb_input.cpp" }, { "directory": "DIR", - "command": "clang-cl /E /IInputs /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps -o a.o -- DIR/modules_cdb_input.cpp", + "command": "clang-cl /E /IInputs /clang:-fmodules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps -o a.o -- DIR/modules_cdb_input.cpp", "file": "DIR/modules_cdb_input.cpp" }, { "directory": "DIR", - "command": "clang-cl /E /IInputs /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps -o b.o -- DIR/modules_cdb_input.cpp", + "command": "clang-cl /E /IInputs /clang:-fmodules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps -o b.o -- DIR/modules_cdb_input.cpp", "file": "DIR/modules_cdb_input.cpp" } ] diff --git a/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl_by_mod_name.json b/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl_by_mod_name.json --- a/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl_by_mod_name.json +++ b/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl_by_mod_name.json @@ -1,12 +1,12 @@ [ { "directory": "DIR", - "command": "clang-cl /E /IInputs /D INCLUDE_HEADER2 /clang:-MD /clang:-MF /clang:DIR/modules_cdb2_clangcl.d /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps /clang:-x /clang:c++ --", + "command": "clang-cl /E /IInputs /D INCLUDE_HEADER2 /clang:-MD /clang:-MF /clang:DIR/modules_cdb2_clangcl.d /clang:-fmodules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps /clang:-x /clang:c++ --", "file": "" }, { "directory": "DIR", - "command": "clang-cl /E /IInputs /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps /clang:-x /clang:c++ --", + "command": "clang-cl /E /IInputs /clang:-fmodules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps /clang:-x /clang:c++ --", "file": "" }, ] diff --git a/clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json b/clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json --- a/clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json +++ b/clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json @@ -1,7 +1,7 @@ [ { "directory": "DIR", - "command": "clang -E DIR/modules_cdb_input.cpp -FFRAMEWORKS -fmodules -fcxx-modules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -pedantic -Werror", + "command": "clang -E DIR/modules_cdb_input.cpp -FFRAMEWORKS -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -fimplicit-module-maps -pedantic -Werror", "file": "DIR/modules_cdb_input.cpp" } ] diff --git a/clang/test/Driver/conflict-clang-module-and-cxx20-module.cpp b/clang/test/Driver/conflict-clang-module-and-cxx20-module.cpp new file mode 100644 --- /dev/null +++ b/clang/test/Driver/conflict-clang-module-and-cxx20-module.cpp @@ -0,0 +1,7 @@ +// RUN: %clangxx -### -c %s -std=c++20 -fmodules 2>&1 | FileCheck %s +// RUN: %clangxx -### -c %s -std=c++2a -fmodules 2>&1 | FileCheck %s +// RUN: %clangxx -### -c %s -std=c++20 -fmodules -fno-cxx-modules 2>&1 | FileCheck %s --check-prefix=FINE +// RUN: %clangxx -### -c %s -fcxx-modules -fmodules -fcxx-modules 2>&1 | FileCheck %s + +// CHECK: error: Unable to use clang module and c++20 module at the same time. +// FINE-NOT: error: Unable to use clang module and c++20 module at the same time. diff --git a/clang/test/Driver/modules.mm b/clang/test/Driver/modules.mm --- a/clang/test/Driver/modules.mm +++ b/clang/test/Driver/modules.mm @@ -1,11 +1,11 @@ // RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s -// RUN: %clang -fcxx-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s -// RUN: %clang -fmodules -fno-cxx-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MODULES %s +// RUN: %clang -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-CLANG-MODULES %s +// RUN: %clang -fmodules -fno-cxx-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-CLANG-MODULES %s // CHECK-NO-MODULES-NOT: -fmodules +// CHECK-HAS-CLANG-MODULES: -fmodules -// RUN: %clang -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s -// RUN: %clang -fmodules -fno-cxx-modules -fcxx-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s -// CHECK-HAS-MODULES: -fmodules +// RUN: %clang -fmodules -fcxx-modules -fcxx-modules -### %s 2>&1 | FileCheck -check-prefix=CHECK-CONFLICT %s +// CHECK-CONFLICT: error // RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MAPS %s // RUN: %clang -fimplicit-module-maps -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MAPS %s diff --git a/clang/test/Modules/cxx20.cpp b/clang/test/Modules/cxx20.cpp --- a/clang/test/Modules/cxx20.cpp +++ b/clang/test/Modules/cxx20.cpp @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -x c++ -std=c++20 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/cxx20 %s -verify -fno-modules-error-recovery +// RUN: %clang_cc1 -x c++ -std=c++20 -fmodules-cache-path=%t -fmodules -fno-cxx-modules -fimplicit-module-maps -I %S/Inputs/cxx20 %s -verify -fno-modules-error-recovery // expected-no-diagnostics diff --git a/clang/test/Modules/ms-enums.cpp b/clang/test/Modules/ms-enums.cpp --- a/clang/test/Modules/ms-enums.cpp +++ b/clang/test/Modules/ms-enums.cpp @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -fms-compatibility -x c++ -std=c++20 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/ms-enums %s -verify -fno-modules-error-recovery +// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -fms-compatibility -x c++ -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/ms-enums %s -verify -fno-modules-error-recovery #include "B.h" // expected-note@A.h:1 {{declaration here is not visible}} diff --git a/clang/test/SemaCXX/compare-modules-cxx2a.cpp b/clang/test/SemaCXX/compare-modules-cxx2a.cpp --- a/clang/test/SemaCXX/compare-modules-cxx2a.cpp +++ b/clang/test/SemaCXX/compare-modules-cxx2a.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -I%S/Inputs %s -fno-modules-error-recovery +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -verify -std=c++2a -fmodules -fno-cxx-modules -I%S/Inputs %s -fno-modules-error-recovery #pragma clang module build compare module compare { diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp --- a/clang/tools/libclang/Indexing.cpp +++ b/clang/tools/libclang/Indexing.cpp @@ -604,7 +604,7 @@ PPOpts.DetailedRecord = true; } - if (!requestedToGetTU && !CInvok->getLangOpts()->Modules) + if (!requestedToGetTU && !CInvok->getLangOpts()->hasModules()) PPOpts.DetailedRecord = false; // Unless the user specified that they want the preamble on the first parse