From: Rainer Orth Date: Mon, 5 Aug 2019 13:59:26 +0000 (+0000) Subject: Move LangStandard*, InputKind::Language to Basic X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3656d7fcf5dc0d1f72b7f417ce7c79b9881e344;p=clang Move LangStandard*, InputKind::Language to Basic This patch is a prerequisite for using LangStandard from Driver in https://reviews.llvm.org/D64793. It moves LangStandard* and InputKind::Language to Basic. It is mostly mechanical, with only a few changes of note: - enum Language has been changed into enum class Language : uint8_t to avoid a clash between OpenCL in enum Language and OpenCL in enum LangFeatures and not to increase the size of class InputKind. - Now that getLangStandardForName, which is currently unused, also checks both canonical and alias names, I've introduced a helper getLangKind which factors out a code pattern already used 3 times. The patch has been tested on x86_64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu. There's a companion patch for lldb which uses LangStandard.h (https://reviews.llvm.org/D65717). While polly includes isl which in turn uses InputKind::C, that part of the code isn't even built inside the llvm tree. I've posted a patch to allow for both InputKind::C and Language::C upstream (https://groups.google.com/forum/#!topic/isl-development/6oEvNWOSQFE). Differential Revision: https://reviews.llvm.org/D65562 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367864 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Frontend/LangStandard.h b/include/clang/Basic/LangStandard.h similarity index 60% rename from include/clang/Frontend/LangStandard.h rename to include/clang/Basic/LangStandard.h index 244f14c793..e7deb7d646 100644 --- a/include/clang/Frontend/LangStandard.h +++ b/include/clang/Basic/LangStandard.h @@ -6,16 +6,37 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_FRONTEND_LANGSTANDARD_H -#define LLVM_CLANG_FRONTEND_LANGSTANDARD_H +#ifndef LLVM_CLANG_BASIC_LANGSTANDARD_H +#define LLVM_CLANG_BASIC_LANGSTANDARD_H #include "clang/Basic/LLVM.h" -#include "clang/Frontend/FrontendOptions.h" #include "llvm/ADT/StringRef.h" namespace clang { -namespace frontend { +/// The language for the input, used to select and validate the language +/// standard and possible actions. +enum class Language : uint8_t { + Unknown, + + /// Assembly: we accept this only so that we can preprocess it. + Asm, + + /// LLVM IR: we accept this so that we can run the optimizer on it, + /// and compile it to assembly or object code. + LLVM_IR, + + ///@{ Languages that the frontend can parse and compile. + C, + CXX, + ObjC, + ObjCXX, + OpenCL, + CUDA, + RenderScript, + HIP, + ///@} +}; enum LangFeatures { LineComment = (1 << 0), @@ -35,22 +56,20 @@ enum LangFeatures { OpenCL = (1 << 14) }; -} - /// LangStandard - Information about the properties of a particular language /// standard. struct LangStandard { enum Kind { #define LANGSTANDARD(id, name, lang, desc, features) \ lang_##id, -#include "clang/Frontend/LangStandards.def" +#include "clang/Basic/LangStandards.def" lang_unspecified }; const char *ShortName; const char *Description; unsigned Flags; - InputKind::Language Language; + clang::Language Language; public: /// getName - Get the name of this standard. @@ -60,54 +79,54 @@ public: const char *getDescription() const { return Description; } /// Get the language that this standard describes. - InputKind::Language getLanguage() const { return Language; } + clang::Language getLanguage() const { return Language; } /// Language supports '//' comments. - bool hasLineComments() const { return Flags & frontend::LineComment; } + bool hasLineComments() const { return Flags & LineComment; } /// isC99 - Language is a superset of C99. - bool isC99() const { return Flags & frontend::C99; } + bool isC99() const { return Flags & C99; } /// isC11 - Language is a superset of C11. - bool isC11() const { return Flags & frontend::C11; } + bool isC11() const { return Flags & C11; } /// isC17 - Language is a superset of C17. - bool isC17() const { return Flags & frontend::C17; } + bool isC17() const { return Flags & C17; } /// isC2x - Language is a superset of C2x. - bool isC2x() const { return Flags & frontend::C2x; } + bool isC2x() const { return Flags & C2x; } /// isCPlusPlus - Language is a C++ variant. - bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; } + bool isCPlusPlus() const { return Flags & CPlusPlus; } /// isCPlusPlus11 - Language is a C++11 variant (or later). - bool isCPlusPlus11() const { return Flags & frontend::CPlusPlus11; } + bool isCPlusPlus11() const { return Flags & CPlusPlus11; } /// isCPlusPlus14 - Language is a C++14 variant (or later). - bool isCPlusPlus14() const { return Flags & frontend::CPlusPlus14; } + bool isCPlusPlus14() const { return Flags & CPlusPlus14; } /// isCPlusPlus17 - Language is a C++17 variant (or later). - bool isCPlusPlus17() const { return Flags & frontend::CPlusPlus17; } + bool isCPlusPlus17() const { return Flags & CPlusPlus17; } /// isCPlusPlus2a - Language is a post-C++17 variant (or later). - bool isCPlusPlus2a() const { return Flags & frontend::CPlusPlus2a; } - + bool isCPlusPlus2a() const { return Flags & CPlusPlus2a; } /// hasDigraphs - Language supports digraphs. - bool hasDigraphs() const { return Flags & frontend::Digraphs; } + bool hasDigraphs() const { return Flags & Digraphs; } /// isGNUMode - Language includes GNU extensions. - bool isGNUMode() const { return Flags & frontend::GNUMode; } + bool isGNUMode() const { return Flags & GNUMode; } /// hasHexFloats - Language supports hexadecimal float constants. - bool hasHexFloats() const { return Flags & frontend::HexFloat; } + bool hasHexFloats() const { return Flags & HexFloat; } /// hasImplicitInt - Language allows variables to be typed as int implicitly. - bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; } + bool hasImplicitInt() const { return Flags & ImplicitInt; } /// isOpenCL - Language is a OpenCL variant. - bool isOpenCL() const { return Flags & frontend::OpenCL; } + bool isOpenCL() const { return Flags & OpenCL; } + static Kind getLangKind(StringRef Name); static const LangStandard &getLangStandardForKind(Kind K); static const LangStandard *getLangStandardForName(StringRef Name); }; diff --git a/include/clang/Frontend/LangStandards.def b/include/clang/Basic/LangStandards.def similarity index 98% rename from include/clang/Frontend/LangStandards.def rename to include/clang/Basic/LangStandards.def index 72ea23562e..537ab2c793 100644 --- a/include/clang/Frontend/LangStandards.def +++ b/include/clang/Basic/LangStandards.def @@ -14,7 +14,7 @@ /// /// \param IDENT - The name of the standard as a C++ identifier. /// \param NAME - The name of the standard. -/// \param LANG - The InputKind::Language for which this is a standard. +/// \param LANG - The Language for which this is a standard. /// \param DESC - A short description of the standard. /// \param FEATURES - The standard features as flags, these are enums from the /// clang::frontend namespace, which is assumed to be be available. diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 3c3497705e..dc904781df 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -2637,7 +2637,7 @@ def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>, const char *Values = #define LANGSTANDARD(id, name, lang, desc, features) name "," #define LANGSTANDARD_ALIAS(id, alias) alias "," - #include "clang/Frontend/LangStandards.def" + #include "clang/Basic/LangStandards.def" ; }]>; def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>, diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h index 413134be4c..191d2ae9c7 100644 --- a/include/clang/Frontend/CompilerInvocation.h +++ b/include/clang/Frontend/CompilerInvocation.h @@ -14,9 +14,9 @@ #include "clang/Basic/FileSystemOptions.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/LangStandard.h" #include "clang/Frontend/DependencyOutputOptions.h" #include "clang/Frontend/FrontendOptions.h" -#include "clang/Frontend/LangStandard.h" #include "clang/Frontend/MigratorOptions.h" #include "clang/Frontend/PreprocessorOutputOptions.h" #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h index a9bdfd395f..d9d961ccbb 100644 --- a/include/clang/Frontend/FrontendOptions.h +++ b/include/clang/Frontend/FrontendOptions.h @@ -10,15 +10,16 @@ #define LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H #include "clang/AST/ASTDumperUtils.h" +#include "clang/Basic/LangStandard.h" #include "clang/Frontend/CommandLineSourceLoc.h" -#include "clang/Serialization/ModuleFileExtension.h" #include "clang/Sema/CodeCompleteOptions.h" +#include "clang/Serialization/ModuleFileExtension.h" #include "llvm/ADT/StringRef.h" #include #include #include -#include #include +#include namespace llvm { @@ -143,35 +144,11 @@ enum ActionKind { /// The kind of a file that we've been handed as an input. class InputKind { private: - unsigned Lang : 4; + Language Lang; unsigned Fmt : 3; unsigned Preprocessed : 1; public: - /// The language for the input, used to select and validate the language - /// standard and possible actions. - enum Language { - Unknown, - - /// Assembly: we accept this only so that we can preprocess it. - Asm, - - /// LLVM IR: we accept this so that we can run the optimizer on it, - /// and compile it to assembly or object code. - LLVM_IR, - - ///@{ Languages that the frontend can parse and compile. - C, - CXX, - ObjC, - ObjCXX, - OpenCL, - CUDA, - RenderScript, - HIP, - ///@} - }; - /// The input file format. enum Format { Source, @@ -179,7 +156,7 @@ public: Precompiled }; - constexpr InputKind(Language L = Unknown, Format F = Source, + constexpr InputKind(Language L = Language::Unknown, Format F = Source, bool PP = false) : Lang(L), Fmt(F), Preprocessed(PP) {} @@ -188,10 +165,12 @@ public: bool isPreprocessed() const { return Preprocessed; } /// Is the input kind fully-unknown? - bool isUnknown() const { return Lang == Unknown && Fmt == Source; } + bool isUnknown() const { return Lang == Language::Unknown && Fmt == Source; } /// Is the language of the input some dialect of Objective-C? - bool isObjectiveC() const { return Lang == ObjC || Lang == ObjCXX; } + bool isObjectiveC() const { + return Lang == Language::ObjC || Lang == Language::ObjCXX; + } InputKind getPreprocessed() const { return InputKind(getLanguage(), getFormat(), true); @@ -467,9 +446,9 @@ public: IncludeTimestamps(true), TimeTraceGranularity(500) {} /// getInputKindForExtension - Return the appropriate input kind for a file - /// extension. For example, "c" would return InputKind::C. + /// extension. For example, "c" would return Language::C. /// - /// \return The input kind for the extension, or InputKind::Unknown if the + /// \return The input kind for the extension, or Language::Unknown if the /// extension is not recognized. static InputKind getInputKindForExtension(StringRef Extension); }; diff --git a/include/clang/module.modulemap b/include/clang/module.modulemap index 1f32ffe0c1..56fb4b57b1 100644 --- a/include/clang/module.modulemap +++ b/include/clang/module.modulemap @@ -100,7 +100,7 @@ module Clang_Frontend { requires cplusplus umbrella "Frontend" - textual header "Frontend/LangStandards.def" + textual header "Basic/LangStandards.def" module * { export * } } diff --git a/lib/Basic/CMakeLists.txt b/lib/Basic/CMakeLists.txt index 18dd7d61fb..b4d6ced4d5 100644 --- a/lib/Basic/CMakeLists.txt +++ b/lib/Basic/CMakeLists.txt @@ -50,6 +50,7 @@ add_clang_library(clangBasic FixedPoint.cpp IdentifierTable.cpp LangOptions.cpp + LangStandards.cpp Module.cpp ObjCRuntime.cpp OpenMPKinds.cpp diff --git a/lib/Frontend/LangStandards.cpp b/lib/Basic/LangStandards.cpp similarity index 60% rename from lib/Frontend/LangStandards.cpp rename to lib/Basic/LangStandards.cpp index 05087eb41f..ee27bfd121 100644 --- a/lib/Frontend/LangStandards.cpp +++ b/lib/Basic/LangStandards.cpp @@ -6,15 +6,14 @@ // //===----------------------------------------------------------------------===// -#include "clang/Frontend/LangStandard.h" +#include "clang/Basic/LangStandard.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/ErrorHandling.h" using namespace clang; -using namespace clang::frontend; -#define LANGSTANDARD(id, name, lang, desc, features) \ -static const LangStandard Lang_##id = { name, desc, features, InputKind::lang }; -#include "clang/Frontend/LangStandards.def" +#define LANGSTANDARD(id, name, lang, desc, features) \ + static const LangStandard Lang_##id = {name, desc, features, Language::lang}; +#include "clang/Basic/LangStandards.def" const LangStandard &LangStandard::getLangStandardForKind(Kind K) { switch (K) { @@ -22,17 +21,21 @@ const LangStandard &LangStandard::getLangStandardForKind(Kind K) { llvm::report_fatal_error("getLangStandardForKind() on unspecified kind"); #define LANGSTANDARD(id, name, lang, desc, features) \ case lang_##id: return Lang_##id; -#include "clang/Frontend/LangStandards.def" +#include "clang/Basic/LangStandards.def" } llvm_unreachable("Invalid language kind!"); } +LangStandard::Kind LangStandard::getLangKind(StringRef Name) { + return llvm::StringSwitch(Name) +#define LANGSTANDARD(id, name, lang, desc, features) .Case(name, lang_##id) +#define LANGSTANDARD_ALIAS(id, alias) .Case(alias, lang_##id) +#include "clang/Basic/LangStandards.def" + .Default(lang_unspecified); +} + const LangStandard *LangStandard::getLangStandardForName(StringRef Name) { - Kind K = llvm::StringSwitch(Name) -#define LANGSTANDARD(id, name, lang, desc, features) \ - .Case(name, lang_##id) -#include "clang/Frontend/LangStandards.def" - .Default(lang_unspecified); + Kind K = getLangKind(Name); if (K == lang_unspecified) return nullptr; diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp index 8ca866e75d..59662f8294 100644 --- a/lib/CodeGen/CodeGenAction.cpp +++ b/lib/CodeGen/CodeGenAction.cpp @@ -15,6 +15,7 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclGroup.h" #include "clang/Basic/FileManager.h" +#include "clang/Basic/LangStandard.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" #include "clang/CodeGen/BackendUtil.h" @@ -1014,7 +1015,7 @@ CodeGenAction::loadModule(MemoryBufferRef MBRef) { void CodeGenAction::ExecuteAction() { // If this is an IR file, we have to treat it specially. - if (getCurrentFileKind().getLanguage() == InputKind::LLVM_IR) { + if (getCurrentFileKind().getLanguage() == Language::LLVM_IR) { BackendAction BA = static_cast(Act); CompilerInstance &CI = getCompilerInstance(); std::unique_ptr OS = diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index fe5eb4e5d1..df0d6d4fe5 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -30,6 +30,7 @@ #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/LangStandard.h" #include "clang/Basic/Module.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/SourceManager.h" @@ -1153,7 +1154,7 @@ bool ASTUnit::Parse(std::shared_ptr PCHContainerOps, InputKind::Source && "FIXME: AST inputs not yet supported here!"); assert(Clang->getFrontendOpts().Inputs[0].getKind().getLanguage() != - InputKind::LLVM_IR && + Language::LLVM_IR && "IR inputs not support here!"); // Configure the various subsystems. @@ -1586,7 +1587,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction( InputKind::Source && "FIXME: AST inputs not yet supported here!"); assert(Clang->getFrontendOpts().Inputs[0].getKind().getLanguage() != - InputKind::LLVM_IR && + Language::LLVM_IR && "IR inputs not support here!"); // Configure the various subsystems. @@ -2210,7 +2211,7 @@ void ASTUnit::CodeComplete( InputKind::Source && "FIXME: AST inputs not yet supported here!"); assert(Clang->getFrontendOpts().Inputs[0].getKind().getLanguage() != - InputKind::LLVM_IR && + Language::LLVM_IR && "IR inputs not support here!"); // Use the source and file managers that we were given. @@ -2667,17 +2668,17 @@ bool ASTUnit::isModuleFile() const { InputKind ASTUnit::getInputKind() const { auto &LangOpts = getLangOpts(); - InputKind::Language Lang; + Language Lang; if (LangOpts.OpenCL) - Lang = InputKind::OpenCL; + Lang = Language::OpenCL; else if (LangOpts.CUDA) - Lang = InputKind::CUDA; + Lang = Language::CUDA; else if (LangOpts.RenderScript) - Lang = InputKind::RenderScript; + Lang = Language::RenderScript; else if (LangOpts.CPlusPlus) - Lang = LangOpts.ObjC ? InputKind::ObjCXX : InputKind::CXX; + Lang = LangOpts.ObjC ? Language::ObjCXX : Language::CXX; else - Lang = LangOpts.ObjC ? InputKind::ObjC : InputKind::C; + Lang = LangOpts.ObjC ? Language::ObjC : Language::C; InputKind::Format Fmt = InputKind::Source; if (LangOpts.getCompilingModule() == LangOptions::CMK_ModuleMap) diff --git a/lib/Frontend/CMakeLists.txt b/lib/Frontend/CMakeLists.txt index fbc3487d43..0e23b92e2d 100644 --- a/lib/Frontend/CMakeLists.txt +++ b/lib/Frontend/CMakeLists.txt @@ -32,7 +32,6 @@ add_clang_library(clangFrontend HeaderIncludeGen.cpp InitHeaderSearch.cpp InitPreprocessor.cpp - LangStandards.cpp LayoutOverrideSource.cpp LogDiagnosticPrinter.cpp ModuleDependencyCollector.cpp diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index a556f4e0df..6948e1f2d6 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -13,6 +13,7 @@ #include "clang/Basic/CharInfo.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/FileManager.h" +#include "clang/Basic/LangStandard.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/Stack.h" #include "clang/Basic/TargetInfo.h" @@ -1002,14 +1003,14 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { /// Determine the appropriate source input kind based on language /// options. -static InputKind::Language getLanguageFromOptions(const LangOptions &LangOpts) { +static Language getLanguageFromOptions(const LangOptions &LangOpts) { if (LangOpts.OpenCL) - return InputKind::OpenCL; + return Language::OpenCL; if (LangOpts.CUDA) - return InputKind::CUDA; + return Language::CUDA; if (LangOpts.ObjC) - return LangOpts.CPlusPlus ? InputKind::ObjCXX : InputKind::ObjC; - return LangOpts.CPlusPlus ? InputKind::CXX : InputKind::C; + return LangOpts.CPlusPlus ? Language::ObjCXX : Language::ObjC; + return LangOpts.CPlusPlus ? Language::CXX : Language::C; } /// Compile a module file for the given module, using the options diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 6bf4fbcbb2..d1e9b14aeb 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -18,6 +18,7 @@ #include "clang/Basic/FileSystemOptions.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/LangStandard.h" #include "clang/Basic/ObjCRuntime.h" #include "clang/Basic/Sanitizers.h" #include "clang/Basic/SourceLocation.h" @@ -34,7 +35,6 @@ #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/Frontend/FrontendOptions.h" #include "clang/Frontend/FrontendPluginRegistry.h" -#include "clang/Frontend/LangStandard.h" #include "clang/Frontend/MigratorOptions.h" #include "clang/Frontend/PreprocessorOutputOptions.h" #include "clang/Frontend/Utils.h" @@ -122,7 +122,7 @@ CompilerInvocationBase::~CompilerInvocationBase() = default; static unsigned getOptimizationLevel(ArgList &Args, InputKind IK, DiagnosticsEngine &Diags) { unsigned DefaultOpt = llvm::CodeGenOpt::None; - if (IK.getLanguage() == InputKind::OpenCL && !Args.hasArg(OPT_cl_opt_disable)) + if (IK.getLanguage() == Language::OpenCL && !Args.hasArg(OPT_cl_opt_disable)) DefaultOpt = llvm::CodeGenOpt::Default; if (Arg *A = Args.getLastArg(options::OPT_O_Group)) { @@ -944,7 +944,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit, false); Opts.EnableSplitLTOUnit = Args.hasArg(OPT_fsplit_lto_unit); if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) { - if (IK.getLanguage() != InputKind::LLVM_IR) + if (IK.getLanguage() != Language::LLVM_IR) Diags.Report(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args) << "-x ir"; Opts.ThinLTOIndexFile = Args.getLastArgValue(OPT_fthinlto_index_EQ); @@ -1285,7 +1285,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, if (Opts.DiagnosticsWithHotness && !UsingProfile && // An IR file will contain PGO as metadata - IK.getLanguage() != InputKind::LLVM_IR) + IK.getLanguage() != Language::LLVM_IR) Diags.Report(diag::warn_drv_diagnostics_hotness_requires_pgo) << "-fdiagnostics-show-hotness"; @@ -1902,7 +1902,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, << "ARC migration" << "ObjC migration"; } - InputKind DashX(InputKind::Unknown); + InputKind DashX(Language::Unknown); if (const Arg *A = Args.getLastArg(OPT_x)) { StringRef XValue = A->getValue(); @@ -1915,33 +1915,33 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, // Principal languages. DashX = llvm::StringSwitch(XValue) - .Case("c", InputKind::C) - .Case("cl", InputKind::OpenCL) - .Case("cuda", InputKind::CUDA) - .Case("hip", InputKind::HIP) - .Case("c++", InputKind::CXX) - .Case("objective-c", InputKind::ObjC) - .Case("objective-c++", InputKind::ObjCXX) - .Case("renderscript", InputKind::RenderScript) - .Default(InputKind::Unknown); + .Case("c", Language::C) + .Case("cl", Language::OpenCL) + .Case("cuda", Language::CUDA) + .Case("hip", Language::HIP) + .Case("c++", Language::CXX) + .Case("objective-c", Language::ObjC) + .Case("objective-c++", Language::ObjCXX) + .Case("renderscript", Language::RenderScript) + .Default(Language::Unknown); // "objc[++]-cpp-output" is an acceptable synonym for // "objective-c[++]-cpp-output". if (DashX.isUnknown() && Preprocessed && !IsHeaderFile && !ModuleMap) DashX = llvm::StringSwitch(XValue) - .Case("objc", InputKind::ObjC) - .Case("objc++", InputKind::ObjCXX) - .Default(InputKind::Unknown); + .Case("objc", Language::ObjC) + .Case("objc++", Language::ObjCXX) + .Default(Language::Unknown); // Some special cases cannot be combined with suffixes. if (DashX.isUnknown() && !Preprocessed && !ModuleMap && !IsHeaderFile) DashX = llvm::StringSwitch(XValue) - .Case("cpp-output", InputKind(InputKind::C).getPreprocessed()) - .Case("assembler-with-cpp", InputKind::Asm) + .Case("cpp-output", InputKind(Language::C).getPreprocessed()) + .Case("assembler-with-cpp", Language::Asm) .Cases("ast", "pcm", - InputKind(InputKind::Unknown, InputKind::Precompiled)) - .Case("ir", InputKind::LLVM_IR) - .Default(InputKind::Unknown); + InputKind(Language::Unknown, InputKind::Precompiled)) + .Case("ir", Language::LLVM_IR) + .Default(Language::Unknown); if (DashX.isUnknown()) Diags.Report(diag::err_drv_invalid_value) @@ -1965,7 +1965,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, StringRef(Inputs[i]).rsplit('.').second); // FIXME: Warn on this? if (IK.isUnknown()) - IK = InputKind::C; + IK = Language::C; // FIXME: Remove this hack. if (i == 0) DashX = IK; @@ -2139,7 +2139,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, // FIXME: Perhaps a better model would be for a single source file to have // multiple language standards (C / C++ std, ObjC std, OpenCL std, OpenMP std) // simultaneously active? - if (IK.getLanguage() == InputKind::Asm) { + if (IK.getLanguage() == Language::Asm) { Opts.AsmPreprocessor = 1; } else if (IK.isObjectiveC()) { Opts.ObjC = 1; @@ -2148,17 +2148,17 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, if (LangStd == LangStandard::lang_unspecified) { // Based on the base language, pick one. switch (IK.getLanguage()) { - case InputKind::Unknown: - case InputKind::LLVM_IR: + case Language::Unknown: + case Language::LLVM_IR: llvm_unreachable("Invalid input kind!"); - case InputKind::OpenCL: + case Language::OpenCL: LangStd = LangStandard::lang_opencl10; break; - case InputKind::CUDA: + case Language::CUDA: LangStd = LangStandard::lang_cuda; break; - case InputKind::Asm: - case InputKind::C: + case Language::Asm: + case Language::C: #if defined(CLANG_DEFAULT_STD_C) LangStd = CLANG_DEFAULT_STD_C; #else @@ -2169,25 +2169,25 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, LangStd = LangStandard::lang_gnu11; #endif break; - case InputKind::ObjC: + case Language::ObjC: #if defined(CLANG_DEFAULT_STD_C) LangStd = CLANG_DEFAULT_STD_C; #else LangStd = LangStandard::lang_gnu11; #endif break; - case InputKind::CXX: - case InputKind::ObjCXX: + case Language::CXX: + case Language::ObjCXX: #if defined(CLANG_DEFAULT_STD_CXX) LangStd = CLANG_DEFAULT_STD_CXX; #else LangStd = LangStandard::lang_gnucxx14; #endif break; - case InputKind::RenderScript: + case Language::RenderScript: LangStd = LangStandard::lang_c99; break; - case InputKind::HIP: + case Language::HIP: LangStd = LangStandard::lang_hip; break; } @@ -2244,13 +2244,13 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, } } - Opts.HIP = IK.getLanguage() == InputKind::HIP; - Opts.CUDA = IK.getLanguage() == InputKind::CUDA || Opts.HIP; + Opts.HIP = IK.getLanguage() == Language::HIP; + Opts.CUDA = IK.getLanguage() == Language::CUDA || Opts.HIP; if (Opts.CUDA) // Set default FP_CONTRACT to FAST. Opts.setDefaultFPContractMode(LangOptions::FPC_Fast); - Opts.RenderScript = IK.getLanguage() == InputKind::RenderScript; + Opts.RenderScript = IK.getLanguage() == Language::RenderScript; if (Opts.RenderScript) { Opts.NativeHalfType = 1; Opts.NativeHalfArgsAndReturns = 1; @@ -2298,32 +2298,31 @@ static Visibility parseVisibility(Arg *arg, ArgList &args, static bool IsInputCompatibleWithStandard(InputKind IK, const LangStandard &S) { switch (IK.getLanguage()) { - case InputKind::Unknown: - case InputKind::LLVM_IR: + case Language::Unknown: + case Language::LLVM_IR: llvm_unreachable("should not parse language flags for this input"); - case InputKind::C: - case InputKind::ObjC: - case InputKind::RenderScript: - return S.getLanguage() == InputKind::C; + case Language::C: + case Language::ObjC: + case Language::RenderScript: + return S.getLanguage() == Language::C; - case InputKind::OpenCL: - return S.getLanguage() == InputKind::OpenCL; + case Language::OpenCL: + return S.getLanguage() == Language::OpenCL; - case InputKind::CXX: - case InputKind::ObjCXX: - return S.getLanguage() == InputKind::CXX; + case Language::CXX: + case Language::ObjCXX: + return S.getLanguage() == Language::CXX; - case InputKind::CUDA: + case Language::CUDA: // FIXME: What -std= values should be permitted for CUDA compilations? - return S.getLanguage() == InputKind::CUDA || - S.getLanguage() == InputKind::CXX; + return S.getLanguage() == Language::CUDA || + S.getLanguage() == Language::CXX; - case InputKind::HIP: - return S.getLanguage() == InputKind::CXX || - S.getLanguage() == InputKind::HIP; + case Language::HIP: + return S.getLanguage() == Language::CXX || S.getLanguage() == Language::HIP; - case InputKind::Asm: + case Language::Asm: // Accept (and ignore) all -std= values. // FIXME: The -std= value is not ignored; it affects the tokenization // and preprocessing rules if we're preprocessing this asm input. @@ -2336,29 +2335,29 @@ static bool IsInputCompatibleWithStandard(InputKind IK, /// Get language name for given input kind. static const StringRef GetInputKindName(InputKind IK) { switch (IK.getLanguage()) { - case InputKind::C: + case Language::C: return "C"; - case InputKind::ObjC: + case Language::ObjC: return "Objective-C"; - case InputKind::CXX: + case Language::CXX: return "C++"; - case InputKind::ObjCXX: + case Language::ObjCXX: return "Objective-C++"; - case InputKind::OpenCL: + case Language::OpenCL: return "OpenCL"; - case InputKind::CUDA: + case Language::CUDA: return "CUDA"; - case InputKind::RenderScript: + case Language::RenderScript: return "RenderScript"; - case InputKind::HIP: + case Language::HIP: return "HIP"; - case InputKind::Asm: + case Language::Asm: return "Asm"; - case InputKind::LLVM_IR: + case Language::LLVM_IR: return "LLVM IR"; - case InputKind::Unknown: + case Language::Unknown: break; } llvm_unreachable("unknown input language"); @@ -2371,13 +2370,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, // FIXME: Cleanup per-file based stuff. LangStandard::Kind LangStd = LangStandard::lang_unspecified; if (const Arg *A = Args.getLastArg(OPT_std_EQ)) { - LangStd = llvm::StringSwitch(A->getValue()) -#define LANGSTANDARD(id, name, lang, desc, features) \ - .Case(name, LangStandard::lang_##id) -#define LANGSTANDARD_ALIAS(id, alias) \ - .Case(alias, LangStandard::lang_##id) -#include "clang/Frontend/LangStandards.def" - .Default(LangStandard::lang_unspecified); + LangStd = LangStandard::getLangKind(A->getValue()); if (LangStd == LangStandard::lang_unspecified) { Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << A->getValue(); @@ -2395,13 +2388,13 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, #define LANGSTANDARD_ALIAS(id, alias) \ if (KindValue == LangStandard::lang_##id) ++NumAliases; #define LANGSTANDARD_ALIAS_DEPR(id, alias) -#include "clang/Frontend/LangStandards.def" +#include "clang/Basic/LangStandards.def" Diag << NumAliases; #define LANGSTANDARD(id, name, lang, desc, features) #define LANGSTANDARD_ALIAS(id, alias) \ if (KindValue == LangStandard::lang_##id) Diag << alias; #define LANGSTANDARD_ALIAS_DEPR(id, alias) -#include "clang/Frontend/LangStandards.def" +#include "clang/Basic/LangStandards.def" } } } else { @@ -3391,7 +3384,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, Res.getFileSystemOpts().WorkingDir); llvm::Triple T(Res.getTargetOpts().Triple); if (DashX.getFormat() == InputKind::Precompiled || - DashX.getLanguage() == InputKind::LLVM_IR) { + DashX.getLanguage() == Language::LLVM_IR) { // ObjCAAutoRefCount and Sanitize LangOpts are used to setup the // PassManager in BackendUtil.cpp. They need to be initializd no matter // what the input type is. @@ -3405,7 +3398,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, Diags, LangOpts.Sanitize); } else { // Other LangOpts are only initialized when the input is not AST or LLVM IR. - // FIXME: Should we really be calling this for an InputKind::Asm input? + // FIXME: Should we really be calling this for an Language::Asm input? ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(), Res.getPreprocessorOpts(), Diags); if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC) diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp index d74984c6bc..fdbb270a75 100644 --- a/lib/Frontend/FrontendAction.cpp +++ b/lib/Frontend/FrontendAction.cpp @@ -10,6 +10,7 @@ #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclGroup.h" +#include "clang/Basic/LangStandard.h" #include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendDiagnostic.h" @@ -683,7 +684,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, CI.getSourceManager().setAllFilesAreTransient(true); // IR files bypass the rest of initialization. - if (Input.getKind().getLanguage() == InputKind::LLVM_IR) { + if (Input.getKind().getLanguage() == Language::LLVM_IR) { assert(hasIRSupport() && "This action does not have IR file support!"); diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index 1bea322ced..14db8788c7 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -9,6 +9,7 @@ #include "clang/Frontend/FrontendActions.h" #include "clang/AST/ASTConsumer.h" #include "clang/Basic/FileManager.h" +#include "clang/Basic/LangStandard.h" #include "clang/Frontend/ASTConsumers.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendDiagnostic.h" @@ -832,19 +833,19 @@ void PrintPreprocessedAction::ExecuteAction() { void PrintPreambleAction::ExecuteAction() { switch (getCurrentFileKind().getLanguage()) { - case InputKind::C: - case InputKind::CXX: - case InputKind::ObjC: - case InputKind::ObjCXX: - case InputKind::OpenCL: - case InputKind::CUDA: - case InputKind::HIP: + case Language::C: + case Language::CXX: + case Language::ObjC: + case Language::ObjCXX: + case Language::OpenCL: + case Language::CUDA: + case Language::HIP: break; - case InputKind::Unknown: - case InputKind::Asm: - case InputKind::LLVM_IR: - case InputKind::RenderScript: + case Language::Unknown: + case Language::Asm: + case Language::LLVM_IR: + case Language::RenderScript: // We can't do anything with these. return; } diff --git a/lib/Frontend/FrontendOptions.cpp b/lib/Frontend/FrontendOptions.cpp index 6ccb2c3956..5c1fbf889c 100644 --- a/lib/Frontend/FrontendOptions.cpp +++ b/lib/Frontend/FrontendOptions.cpp @@ -7,28 +7,29 @@ //===----------------------------------------------------------------------===// #include "clang/Frontend/FrontendOptions.h" +#include "clang/Basic/LangStandard.h" #include "llvm/ADT/StringSwitch.h" using namespace clang; InputKind FrontendOptions::getInputKindForExtension(StringRef Extension) { return llvm::StringSwitch(Extension) - .Cases("ast", "pcm", InputKind(InputKind::Unknown, InputKind::Precompiled)) - .Case("c", InputKind::C) - .Cases("S", "s", InputKind::Asm) - .Case("i", InputKind(InputKind::C).getPreprocessed()) - .Case("ii", InputKind(InputKind::CXX).getPreprocessed()) - .Case("cui", InputKind(InputKind::CUDA).getPreprocessed()) - .Case("m", InputKind::ObjC) - .Case("mi", InputKind(InputKind::ObjC).getPreprocessed()) - .Cases("mm", "M", InputKind::ObjCXX) - .Case("mii", InputKind(InputKind::ObjCXX).getPreprocessed()) - .Cases("C", "cc", "cp", InputKind::CXX) - .Cases("cpp", "CPP", "c++", "cxx", "hpp", InputKind::CXX) - .Case("cppm", InputKind::CXX) - .Case("iim", InputKind(InputKind::CXX).getPreprocessed()) - .Case("cl", InputKind::OpenCL) - .Case("cu", InputKind::CUDA) - .Cases("ll", "bc", InputKind::LLVM_IR) - .Default(InputKind::Unknown); + .Cases("ast", "pcm", InputKind(Language::Unknown, InputKind::Precompiled)) + .Case("c", Language::C) + .Cases("S", "s", Language::Asm) + .Case("i", InputKind(Language::C).getPreprocessed()) + .Case("ii", InputKind(Language::CXX).getPreprocessed()) + .Case("cui", InputKind(Language::CUDA).getPreprocessed()) + .Case("m", Language::ObjC) + .Case("mi", InputKind(Language::ObjC).getPreprocessed()) + .Cases("mm", "M", Language::ObjCXX) + .Case("mii", InputKind(Language::ObjCXX).getPreprocessed()) + .Cases("C", "cc", "cp", Language::CXX) + .Cases("cpp", "CPP", "c++", "cxx", "hpp", Language::CXX) + .Case("cppm", Language::CXX) + .Case("iim", InputKind(Language::CXX).getPreprocessed()) + .Case("cl", Language::OpenCL) + .Case("cu", Language::CUDA) + .Cases("ll", "bc", Language::LLVM_IR) + .Default(Language::Unknown); } diff --git a/lib/Frontend/PrecompiledPreamble.cpp b/lib/Frontend/PrecompiledPreamble.cpp index 55eb1ff069..842ffe2470 100644 --- a/lib/Frontend/PrecompiledPreamble.cpp +++ b/lib/Frontend/PrecompiledPreamble.cpp @@ -12,6 +12,7 @@ #include "clang/Frontend/PrecompiledPreamble.h" #include "clang/AST/DeclObjC.h" +#include "clang/Basic/LangStandard.h" #include "clang/Basic/TargetInfo.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/CompilerInvocation.h" @@ -303,7 +304,7 @@ llvm::ErrorOr PrecompiledPreamble::Build( Clang->getFrontendOpts().Inputs[0].getKind().getFormat() != InputKind::Source || Clang->getFrontendOpts().Inputs[0].getKind().getLanguage() == - InputKind::LLVM_IR) { + Language::LLVM_IR) { return BuildPreambleError::BadInputs; } diff --git a/lib/Frontend/Rewrite/FrontendActions.cpp b/lib/Frontend/Rewrite/FrontendActions.cpp index c00e05e055..b871ee9a03 100644 --- a/lib/Frontend/Rewrite/FrontendActions.cpp +++ b/lib/Frontend/Rewrite/FrontendActions.cpp @@ -9,6 +9,7 @@ #include "clang/Rewrite/Frontend/FrontendActions.h" #include "clang/AST/ASTConsumer.h" #include "clang/Basic/CharInfo.h" +#include "clang/Basic/LangStandard.h" #include "clang/Config/config.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendActions.h" @@ -250,7 +251,7 @@ public: Instance.getFrontendOpts().DisableFree = false; Instance.getFrontendOpts().Inputs.clear(); Instance.getFrontendOpts().Inputs.emplace_back( - Filename, InputKind(InputKind::Unknown, InputKind::Precompiled)); + Filename, InputKind(Language::Unknown, InputKind::Precompiled)); Instance.getFrontendOpts().ModuleFiles.clear(); Instance.getFrontendOpts().ModuleMapFiles.clear(); // Don't recursively rewrite imports. We handle them all at the top level. diff --git a/lib/StaticAnalyzer/Frontend/ModelInjector.cpp b/lib/StaticAnalyzer/Frontend/ModelInjector.cpp index fe5f59045c..687fda75db 100644 --- a/lib/StaticAnalyzer/Frontend/ModelInjector.cpp +++ b/lib/StaticAnalyzer/Frontend/ModelInjector.cpp @@ -9,6 +9,7 @@ #include "ModelInjector.h" #include "clang/AST/Decl.h" #include "clang/Basic/IdentifierTable.h" +#include "clang/Basic/LangStandard.h" #include "clang/Basic/Stack.h" #include "clang/Frontend/ASTUnit.h" #include "clang/Frontend/CompilerInstance.h" @@ -65,7 +66,7 @@ void ModelInjector::onBodySynthesis(const NamedDecl *D) { auto Invocation = std::make_shared(CI.getInvocation()); FrontendOptions &FrontendOpts = Invocation->getFrontendOpts(); - InputKind IK = InputKind::CXX; // FIXME + InputKind IK = Language::CXX; // FIXME FrontendOpts.Inputs.clear(); FrontendOpts.Inputs.emplace_back(fileName, IK); FrontendOpts.DisableFree = true; diff --git a/lib/Tooling/InterpolatingCompilationDatabase.cpp b/lib/Tooling/InterpolatingCompilationDatabase.cpp index 53c8dd448f..aa1d696a1d 100644 --- a/lib/Tooling/InterpolatingCompilationDatabase.cpp +++ b/lib/Tooling/InterpolatingCompilationDatabase.cpp @@ -42,9 +42,9 @@ // //===----------------------------------------------------------------------===// +#include "clang/Basic/LangStandard.h" #include "clang/Driver/Options.h" #include "clang/Driver/Types.h" -#include "clang/Frontend/LangStandard.h" #include "clang/Tooling/CompilationDatabase.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" @@ -249,15 +249,15 @@ private: } // Map the language from the --std flag to that of the -x flag. - static types::ID toType(InputKind::Language Lang) { + static types::ID toType(Language Lang) { switch (Lang) { - case InputKind::C: + case Language::C: return types::TY_C; - case InputKind::CXX: + case Language::CXX: return types::TY_CXX; - case InputKind::ObjC: + case Language::ObjC: return types::TY_ObjC; - case InputKind::ObjCXX: + case Language::ObjCXX: return types::TY_ObjCXX; default: return types::TY_INVALID; @@ -297,15 +297,8 @@ private: // Try to interpret the argument as '-std='. Optional tryParseStdArg(const llvm::opt::Arg &Arg) { using namespace driver::options; - if (Arg.getOption().matches(ClangCLMode ? OPT__SLASH_std : OPT_std_EQ)) { - return llvm::StringSwitch(Arg.getValue()) -#define LANGSTANDARD(id, name, lang, ...) .Case(name, LangStandard::lang_##id) -#define LANGSTANDARD_ALIAS(id, alias) .Case(alias, LangStandard::lang_##id) -#include "clang/Frontend/LangStandards.def" -#undef LANGSTANDARD_ALIAS -#undef LANGSTANDARD - .Default(LangStandard::lang_unspecified); - } + if (Arg.getOption().matches(ClangCLMode ? OPT__SLASH_std : OPT_std_EQ)) + return LangStandard::getLangKind(Arg.getValue()); return None; } }; diff --git a/unittests/Frontend/CodeGenActionTest.cpp b/unittests/Frontend/CodeGenActionTest.cpp index 7576c91966..455ec705f8 100644 --- a/unittests/Frontend/CodeGenActionTest.cpp +++ b/unittests/Frontend/CodeGenActionTest.cpp @@ -10,8 +10,9 @@ // //===----------------------------------------------------------------------===// -#include "clang/CodeGen/BackendUtil.h" #include "clang/CodeGen/CodeGenAction.h" +#include "clang/Basic/LangStandard.h" +#include "clang/CodeGen/BackendUtil.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Lex/PreprocessorOptions.h" #include "gtest/gtest.h" @@ -45,7 +46,7 @@ TEST(CodeGenTest, TestNullCodeGen) { "test.cc", MemoryBuffer::getMemBuffer("").release()); Invocation->getFrontendOpts().Inputs.push_back( - FrontendInputFile("test.cc", InputKind::CXX)); + FrontendInputFile("test.cc", Language::CXX)); Invocation->getFrontendOpts().ProgramAction = EmitLLVM; Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu"; CompilerInstance Compiler; diff --git a/unittests/Frontend/FrontendActionTest.cpp b/unittests/Frontend/FrontendActionTest.cpp index 20356c6d83..082d2f695d 100644 --- a/unittests/Frontend/FrontendActionTest.cpp +++ b/unittests/Frontend/FrontendActionTest.cpp @@ -10,6 +10,7 @@ #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" #include "clang/AST/RecursiveASTVisitor.h" +#include "clang/Basic/LangStandard.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/FrontendActions.h" @@ -84,7 +85,7 @@ TEST(ASTFrontendAction, Sanity) { "test.cc", MemoryBuffer::getMemBuffer("int main() { float x; }").release()); invocation->getFrontendOpts().Inputs.push_back( - FrontendInputFile("test.cc", InputKind::CXX)); + FrontendInputFile("test.cc", Language::CXX)); invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly; invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu"; CompilerInstance compiler; @@ -104,7 +105,7 @@ TEST(ASTFrontendAction, IncrementalParsing) { "test.cc", MemoryBuffer::getMemBuffer("int main() { float x; }").release()); invocation->getFrontendOpts().Inputs.push_back( - FrontendInputFile("test.cc", InputKind::CXX)); + FrontendInputFile("test.cc", Language::CXX)); invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly; invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu"; CompilerInstance compiler; @@ -131,7 +132,7 @@ TEST(ASTFrontendAction, LateTemplateIncrementalParsing) { "};\n" "B c() { return B(); }\n").release()); invocation->getFrontendOpts().Inputs.push_back( - FrontendInputFile("test.cc", InputKind::CXX)); + FrontendInputFile("test.cc", Language::CXX)); invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly; invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu"; CompilerInstance compiler; @@ -177,7 +178,7 @@ TEST(PreprocessorFrontendAction, EndSourceFile) { "test.cc", MemoryBuffer::getMemBuffer("int main() { float x; }").release()); Invocation->getFrontendOpts().Inputs.push_back( - FrontendInputFile("test.cc", InputKind::CXX)); + FrontendInputFile("test.cc", Language::CXX)); Invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly; Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu"; CompilerInstance Compiler; @@ -238,7 +239,7 @@ TEST(ASTFrontendAction, ExternalSemaSource) { "int main() { foo(); }") .release()); Invocation->getFrontendOpts().Inputs.push_back( - FrontendInputFile("test.cc", InputKind::CXX)); + FrontendInputFile("test.cc", Language::CXX)); Invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly; Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu"; CompilerInstance Compiler; @@ -270,7 +271,7 @@ TEST(GeneratePCHFrontendAction, CacheGeneratedPCH) { "test.h", MemoryBuffer::getMemBuffer("int foo(void) { return 1; }\n").release()); Invocation->getFrontendOpts().Inputs.push_back( - FrontendInputFile("test.h", InputKind::C)); + FrontendInputFile("test.h", Language::C)); Invocation->getFrontendOpts().OutputFile = StringRef(PCHFilename); Invocation->getFrontendOpts().ProgramAction = frontend::GeneratePCH; Invocation->getTargetOpts().Triple = "x86_64-apple-darwin19.0.0"; diff --git a/unittests/Frontend/OutputStreamTest.cpp b/unittests/Frontend/OutputStreamTest.cpp index 1ac875ffb3..a973582f5d 100644 --- a/unittests/Frontend/OutputStreamTest.cpp +++ b/unittests/Frontend/OutputStreamTest.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "clang/Basic/LangStandard.h" #include "clang/CodeGen/BackendUtil.h" #include "clang/CodeGen/CodeGenAction.h" #include "clang/Frontend/CompilerInstance.h" @@ -24,7 +25,7 @@ TEST(FrontendOutputTests, TestOutputStream) { Invocation->getPreprocessorOpts().addRemappedFile( "test.cc", MemoryBuffer::getMemBuffer("").release()); Invocation->getFrontendOpts().Inputs.push_back( - FrontendInputFile("test.cc", InputKind::CXX)); + FrontendInputFile("test.cc", Language::CXX)); Invocation->getFrontendOpts().ProgramAction = EmitBC; Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu"; CompilerInstance Compiler;