diff --git a/clang-tools-extra/clang-query/Query.cpp b/clang-tools-extra/clang-query/Query.cpp index ca2a285e9eb7..e33612a2e16d 100644 --- a/clang-tools-extra/clang-query/Query.cpp +++ b/clang-tools-extra/clang-query/Query.cpp @@ -156,8 +156,7 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const { if (QS.DetailedASTOutput) { OS << "Binding for \"" << BI->first << "\":\n"; const ASTContext &Ctx = AST->getASTContext(); - const SourceManager &SM = Ctx.getSourceManager(); - ASTDumper Dumper(OS, Ctx, SM.getDiagnostics().getShowColors()); + ASTDumper Dumper(OS, Ctx, AST->getDiagnostics().getShowColors()); Dumper.SetTraversalKind(QS.TK); Dumper.Visit(BI->second); OS << "\n"; diff --git a/clang-tools-extra/clang-query/tool/ClangQuery.cpp b/clang-tools-extra/clang-query/tool/ClangQuery.cpp index 31c7f12251c9..45a355073945 100644 --- a/clang-tools-extra/clang-query/tool/ClangQuery.cpp +++ b/clang-tools-extra/clang-query/tool/ClangQuery.cpp @@ -49,6 +49,14 @@ using namespace llvm; static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage); static cl::OptionCategory ClangQueryCategory("clang-query options"); +static cl::opt + UseColor("use-color", + cl::desc( + R"(Use colors in detailed AST output. If not set, colors +will be used if the terminal connected to +standard output supports colors.)"), + cl::init(false), cl::cat(ClangQueryCategory)); + static cl::list Commands("c", cl::desc("Specify command to run"), cl::value_desc("command"), cl::cat(ClangQueryCategory)); @@ -109,6 +117,19 @@ int main(int argc, const char **argv) { ClangTool Tool(OptionsParser->getCompilations(), OptionsParser->getSourcePathList()); + + if (UseColor.getNumOccurrences() > 0) { + ArgumentsAdjuster colorAdjustor = [](const CommandLineArguments &Args, StringRef /*unused*/) { + CommandLineArguments AdjustedArgs = Args; + if (UseColor) + AdjustedArgs.push_back("-fdiagnostics-color"); + else + AdjustedArgs.push_back("-fno-diagnostics-color"); + return AdjustedArgs; + }; + Tool.appendArgumentsAdjuster(colorAdjustor); + } + std::vector> ASTs; int ASTStatus = 0; switch (Tool.buildASTs(ASTs)) { diff --git a/clang-tools-extra/clangd/Config.h b/clang-tools-extra/clangd/Config.h index 79e94ef6fe37..675e721c7e64 100644 --- a/clang-tools-extra/clangd/Config.h +++ b/clang-tools-extra/clangd/Config.h @@ -28,6 +28,7 @@ #include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringSet.h" #include #include @@ -77,6 +78,12 @@ struct Config { llvm::Optional External; } Index; + /// Controls warnings and errors when parsing code. + struct { + bool SuppressAll = false; + llvm::StringSet<> Suppress; + } Diagnostics; + /// Style of the codebase. struct { // Namespaces that should always be fully qualified, meaning no "using" diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp b/clang-tools-extra/clangd/ConfigCompile.cpp index 2040ea4649fe..f2e6d544e6c9 100644 --- a/clang-tools-extra/clangd/ConfigCompile.cpp +++ b/clang-tools-extra/clangd/ConfigCompile.cpp @@ -27,6 +27,7 @@ #include "Config.h" #include "ConfigFragment.h" #include "ConfigProvider.h" +#include "Diagnostics.h" #include "Features.inc" #include "TidyProvider.h" #include "support/Logger.h" @@ -187,6 +188,7 @@ struct FragmentCompiler { compile(std::move(F.If)); compile(std::move(F.CompileFlags)); compile(std::move(F.Index)); + compile(std::move(F.Diagnostics)); compile(std::move(F.ClangTidy)); } @@ -328,6 +330,27 @@ struct FragmentCompiler { }); } + void compile(Fragment::DiagnosticsBlock &&F) { + std::vector Normalized; + for (const auto &Suppressed : F.Suppress) { + if (*Suppressed == "*") { + Out.Apply.push_back([&](const Params &, Config &C) { + C.Diagnostics.SuppressAll = true; + C.Diagnostics.Suppress.clear(); + }); + return; + } + Normalized.push_back(normalizeSuppressedCode(*Suppressed)); + } + if (!Normalized.empty()) + Out.Apply.push_back([Normalized](const Params &, Config &C) { + if (C.Diagnostics.SuppressAll) + return; + for (llvm::StringRef N : Normalized) + C.Diagnostics.Suppress.insert(N); + }); + } + void compile(Fragment::StyleBlock &&F) { if (!F.FullyQualifiedNamespaces.empty()) { std::vector FullyQualifiedNamespaces; diff --git a/clang-tools-extra/clangd/ConfigFragment.h b/clang-tools-extra/clangd/ConfigFragment.h index 0e4ce638fc72..c491ec5ee68c 100644 --- a/clang-tools-extra/clangd/ConfigFragment.h +++ b/clang-tools-extra/clangd/ConfigFragment.h @@ -181,6 +181,24 @@ struct Fragment { }; IndexBlock Index; + /// Controls behavior of diagnostics (errors and warnings). + struct DiagnosticsBlock { + /// Diagnostic codes that should be suppressed. + /// + /// Valid values are: + /// - *, to disable all diagnostics + /// - diagnostic codes exposed by clangd (e.g unknown_type, -Wunused-result) + /// - clang internal diagnostic codes (e.g. err_unknown_type) + /// - warning categories (e.g. unused-result) + /// - clang-tidy check names (e.g. bugprone-narrowing-conversions) + /// + /// This is a simple filter. Diagnostics can be controlled in other ways + /// (e.g. by disabling a clang-tidy check, or the -Wunused compile flag). + /// This often has other advantages, such as skipping some analysis. + std::vector> Suppress; + }; + DiagnosticsBlock Diagnostics; + // Describes the style of the codebase, beyond formatting. struct StyleBlock { // Namespaces that should always be fully qualified, meaning no "using" @@ -195,6 +213,7 @@ struct Fragment { /// /// The settings are merged with any settings found in .clang-tidy /// configiration files with these ones taking precedence. + // FIXME: move this to Diagnostics.Tidy. struct ClangTidyBlock { std::vector> Add; /// List of checks to disable. diff --git a/clang-tools-extra/clangd/Diagnostics.cpp b/clang-tools-extra/clangd/Diagnostics.cpp index 7b59cedb0f67..d2982636c807 100644 --- a/clang-tools-extra/clangd/Diagnostics.cpp +++ b/clang-tools-extra/clangd/Diagnostics.cpp @@ -801,5 +801,23 @@ void StoreDiags::flushLastDiag() { Output.push_back(std::move(*LastDiag)); } +bool isBuiltinDiagnosticSuppressed(unsigned ID, + const llvm::StringSet<> &Suppress) { + if (const char *CodePtr = getDiagnosticCode(ID)) { + if (Suppress.contains(normalizeSuppressedCode(CodePtr))) + return true; + } + StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(ID); + if (!Warning.empty() && Suppress.contains(Warning)) + return true; + return false; +} + +llvm::StringRef normalizeSuppressedCode(llvm::StringRef Code) { + Code.consume_front("err_"); + Code.consume_front("-W"); + return Code; +} + } // namespace clangd } // namespace clang diff --git a/clang-tools-extra/clangd/Diagnostics.h b/clang-tools-extra/clangd/Diagnostics.h index e1c3bcafcbf7..6a432db23cc2 100644 --- a/clang-tools-extra/clangd/Diagnostics.h +++ b/clang-tools-extra/clangd/Diagnostics.h @@ -159,6 +159,15 @@ class StoreDiags : public DiagnosticConsumer { bool LastPrimaryDiagnosticWasSuppressed = false; }; +/// Determine whether a (non-clang-tidy) diagnostic is suppressed by config. +bool isBuiltinDiagnosticSuppressed(unsigned ID, + const llvm::StringSet<> &Suppressed); +/// Take a user-specified diagnostic code, and convert it to a normalized form +/// stored in the config and consumed by isBuiltinDiagnosticsSuppressed. +/// +/// (This strips err_ and -W prefix so we can match with or without them.) +llvm::StringRef normalizeSuppressedCode(llvm::StringRef); + } // namespace clangd } // namespace clang diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp index a8c4eea54540..403d3fe3e64f 100644 --- a/clang-tools-extra/clangd/ParsedAST.cpp +++ b/clang-tools-extra/clangd/ParsedAST.cpp @@ -12,6 +12,7 @@ #include "../clang-tidy/ClangTidyModuleRegistry.h" #include "AST.h" #include "Compiler.h" +#include "Config.h" #include "Diagnostics.h" #include "Headers.h" #include "IncludeFixer.h" @@ -315,12 +316,18 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs, Check->registerMatchers(&CTFinder); } - if (!CTChecks.empty()) { - ASTDiags.setLevelAdjuster([&CTContext](DiagnosticsEngine::Level DiagLevel, - const clang::Diagnostic &Info) { + ASTDiags.setLevelAdjuster([&, &Cfg(Config::current())]( + DiagnosticsEngine::Level DiagLevel, + const clang::Diagnostic &Info) { + if (Cfg.Diagnostics.SuppressAll || + isBuiltinDiagnosticSuppressed(Info.getID(), Cfg.Diagnostics.Suppress)) + return DiagnosticsEngine::Ignored; + if (!CTChecks.empty()) { std::string CheckName = CTContext->getCheckName(Info.getID()); bool IsClangTidyDiag = !CheckName.empty(); if (IsClangTidyDiag) { + if (Cfg.Diagnostics.Suppress.contains(CheckName)) + return DiagnosticsEngine::Ignored; // Check for suppression comment. Skip the check for diagnostics not // in the main file, because we don't want that function to query the // source buffer for preamble files. For the same reason, we ask @@ -342,9 +349,9 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs, return DiagnosticsEngine::Error; } } - return DiagLevel; - }); - } + } + return DiagLevel; + }); } // Add IncludeFixer which can recover diagnostics caused by missing includes diff --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp index 578f69821e4d..dde8e644f15a 100644 --- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp +++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp @@ -11,6 +11,7 @@ #include "ConfigTesting.h" #include "Features.inc" #include "TestFS.h" +#include "clang/Basic/DiagnosticSema.h" #include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" @@ -30,6 +31,7 @@ using ::testing::ElementsAre; using ::testing::IsEmpty; using ::testing::SizeIs; using ::testing::StartsWith; +using ::testing::UnorderedElementsAre; class ConfigCompileTests : public ::testing::Test { protected: @@ -183,6 +185,39 @@ TEST_F(ConfigCompileTests, PathSpecMatch) { } } +TEST_F(ConfigCompileTests, DiagnosticSuppression) { + Frag.Diagnostics.Suppress.emplace_back("bugprone-use-after-move"); + Frag.Diagnostics.Suppress.emplace_back("unreachable-code"); + Frag.Diagnostics.Suppress.emplace_back("-Wunused-variable"); + Frag.Diagnostics.Suppress.emplace_back("typecheck_bool_condition"); + Frag.Diagnostics.Suppress.emplace_back("err_unexpected_friend"); + Frag.Diagnostics.Suppress.emplace_back("warn_alloca"); + EXPECT_TRUE(compileAndApply()); + EXPECT_THAT(Conf.Diagnostics.Suppress.keys(), + UnorderedElementsAre("bugprone-use-after-move", + "unreachable-code", "unused-variable", + "typecheck_bool_condition", + "unexpected_friend", "warn_alloca")); + EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::warn_unreachable, + Conf.Diagnostics.Suppress)); + // Subcategory not respected/suppressed. + EXPECT_FALSE(isBuiltinDiagnosticSuppressed(diag::warn_unreachable_break, + Conf.Diagnostics.Suppress)); + EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::warn_unused_variable, + Conf.Diagnostics.Suppress)); + EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::err_typecheck_bool_condition, + Conf.Diagnostics.Suppress)); + EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::err_unexpected_friend, + Conf.Diagnostics.Suppress)); + EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::warn_alloca, + Conf.Diagnostics.Suppress)); + + Frag.Diagnostics.Suppress.emplace_back("*"); + EXPECT_TRUE(compileAndApply()); + EXPECT_TRUE(Conf.Diagnostics.SuppressAll); + EXPECT_THAT(Conf.Diagnostics.Suppress, IsEmpty()); +} + TEST_F(ConfigCompileTests, Tidy) { Frag.ClangTidy.Add.emplace_back("bugprone-use-after-move"); Frag.ClangTidy.Add.emplace_back("llvm-*"); diff --git a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp index 4039a9be71a0..25d468ba604a 100644 --- a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp +++ b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp @@ -98,7 +98,7 @@ TEST(ParseYAML, Locations) { YAML.range()); } -TEST(ParseYAML, Diagnostics) { +TEST(ParseYAML, ConfigDiagnostics) { CapturedDiags Diags; Annotations YAML(R"yaml( If: diff --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp index c6a14aeeb469..b1e748d18097 100644 --- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp +++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "Annotations.h" +#include "Config.h" #include "Diagnostics.h" #include "ParsedAST.h" #include "Protocol.h" @@ -16,6 +17,7 @@ #include "TestTU.h" #include "TidyProvider.h" #include "index/MemIndex.h" +#include "support/Context.h" #include "support/Path.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticSema.h" @@ -371,6 +373,28 @@ TEST(DiagnosticTest, NoMultipleDiagnosticInFlight) { DiagSource(Diag::ClangTidy), DiagName("modernize-loop-convert")))); } +TEST(DiagnosticTest, RespectsDiagnosticConfig) { + Annotations Main(R"cpp( + // error-ok + void x() { + [[unknown]](); + $ret[[return]] 42; + } + )cpp"); + auto TU = TestTU::withCode(Main.code()); + EXPECT_THAT( + TU.build().getDiagnostics(), + ElementsAre(Diag(Main.range(), "use of undeclared identifier 'unknown'"), + Diag(Main.range("ret"), + "void function 'x' should not return a value"))); + Config Cfg; + Cfg.Diagnostics.Suppress.insert("return-type"); + WithContextValue WithCfg(Config::Key, std::move(Cfg)); + EXPECT_THAT(TU.build().getDiagnostics(), + ElementsAre(Diag(Main.range(), + "use of undeclared identifier 'unknown'"))); +} + TEST(DiagnosticTest, ClangTidySuppressionComment) { Annotations Main(R"cpp( int main() { diff --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp index 7e36cff7afa6..924cfd03cba7 100644 --- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1838,6 +1838,20 @@ TEST_F(SymbolCollectorTest, UndefOfModuleMacro) { EXPECT_THAT(TU.headerSymbols(), Not(Contains(QName("X")))); } +TEST_F(SymbolCollectorTest, NoCrashOnObjCMethodCStyleParam) { + auto TU = TestTU::withCode(R"objc( + @interface Foo + - (void)fun:(bool)foo, bool bar; + @end + )objc"); + TU.ExtraArgs.push_back("-xobjective-c++"); + + TU.build(); + // We mostly care about not crashing. + EXPECT_THAT(TU.headerSymbols(), + UnorderedElementsAre(QName("Foo"), QName("Foo::fun:"))); +} + } // namespace } // namespace clangd } // namespace clang diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index 27dcee83a538..3141dd5510fc 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -195,23 +195,84 @@ the configuration (without a prefix: ``Auto``). -**AlignConsecutiveAssignments** (``bool``) - If ``true``, aligns consecutive assignments. +**AlignConsecutiveAssignments** (``AlignConsecutiveStyle``) + Style of aligning consecutive assignments. - This will align the assignment operators of consecutive lines. This - will result in formattings like + ``Consecutive`` will result in formattings like: .. code-block:: c++ - int aaaa = 12; - int b = 23; - int ccc = 23; + int a = 1; + int somelongname = 2; + double c = 3; -**AlignConsecutiveBitFields** (``bool``) - If ``true``, aligns consecutive bitfield members. + Possible values: + + * ``ACS_None`` (in configuration: ``None``) + Do not align assignments on consecutive lines. + + * ``ACS_Consecutive`` (in configuration: ``Consecutive``) + Align assignments on consecutive lines. This will result in + formattings like: + + .. code-block:: c++ + + int a = 1; + int somelongname = 2; + double c = 3; + + int d = 3; + /* A comment. */ + double e = 4; + + * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``) + Same as ACS_Consecutive, but also spans over empty lines, e.g. + + .. code-block:: c++ + + int a = 1; + int somelongname = 2; + double c = 3; + + int d = 3; + /* A comment. */ + double e = 4; + + * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``) + Same as ACS_Consecutive, but also spans over lines only containing + comments, e.g. + + .. code-block:: c++ + + int a = 1; + int somelongname = 2; + double c = 3; + + int d = 3; + /* A comment. */ + double e = 4; + + * ``ACS_AcrossEmptyLinesAndComments`` + (in configuration: ``AcrossEmptyLinesAndComments``) + + Same as ACS_Consecutive, but also spans over lines only containing + comments and empty lines, e.g. + + .. code-block:: c++ + + int a = 1; + int somelongname = 2; + double c = 3; + + int d = 3; + /* A comment. */ + double e = 4; + +**AlignConsecutiveBitFields** (``AlignConsecutiveStyle``) + Style of aligning consecutive bit field. - This will align the bitfield separators of consecutive lines. This - will result in formattings like + ``Consecutive`` will align the bitfield separators of consecutive lines. + This will result in formattings like: .. code-block:: c++ @@ -219,23 +280,146 @@ the configuration (without a prefix: ``Auto``). int b : 12; int ccc : 8; -**AlignConsecutiveDeclarations** (``bool``) - If ``true``, aligns consecutive declarations. + Possible values: + + * ``ACS_None`` (in configuration: ``None``) + Do not align bit fields on consecutive lines. + + * ``ACS_Consecutive`` (in configuration: ``Consecutive``) + Align bit fields on consecutive lines. This will result in + formattings like: + + .. code-block:: c++ + + int aaaa : 1; + int b : 12; + int ccc : 8; + + int d : 2; + /* A comment. */ + int ee : 3; + + * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``) + Same as ACS_Consecutive, but also spans over empty lines, e.g. + + .. code-block:: c++ + + int aaaa : 1; + int b : 12; + int ccc : 8; + + int d : 2; + /* A comment. */ + int ee : 3; + + * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``) + Same as ACS_Consecutive, but also spans over lines only containing + comments, e.g. + + .. code-block:: c++ + + int aaaa : 1; + int b : 12; + int ccc : 8; + + int d : 2; + /* A comment. */ + int ee : 3; + + * ``ACS_AcrossEmptyLinesAndComments`` + (in configuration: ``AcrossEmptyLinesAndComments``) + + Same as ACS_Consecutive, but also spans over lines only containing + comments and empty lines, e.g. + + .. code-block:: c++ + + int aaaa : 1; + int b : 12; + int ccc : 8; + + int d : 2; + /* A comment. */ + int ee : 3; + +**AlignConsecutiveDeclarations** (``AlignConsecutiveStyle``) + Style of aligning consecutive declarations. - This will align the declaration names of consecutive lines. This - will result in formattings like + ``Consecutive`` will align the declaration names of consecutive lines. + This will result in formattings like: .. code-block:: c++ int aaaa = 12; float b = 23; - std::string ccc = 23; + std::string ccc; -**AlignConsecutiveMacros** (``bool``) - If ``true``, aligns consecutive C/C++ preprocessor macros. + Possible values: + + * ``ACS_None`` (in configuration: ``None``) + Do not align bit declarations on consecutive lines. + + * ``ACS_Consecutive`` (in configuration: ``Consecutive``) + Align declarations on consecutive lines. This will result in + formattings like: + + .. code-block:: c++ + + int aaaa = 12; + float b = 23; + std::string ccc; + + int a = 42; + /* A comment. */ + bool c = false; + + * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``) + Same as ACS_Consecutive, but also spans over empty lines, e.g. + + .. code-block:: c++ + + int aaaa = 12; + float b = 23; + std::string ccc; + + int a = 42; + /* A comment. */ + bool c = false; + + * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``) + Same as ACS_Consecutive, but also spans over lines only containing + comments, e.g. + + .. code-block:: c++ + + int aaaa = 12; + float b = 23; + std::string ccc; + + int a = 42; + /* A comment. */ + bool c = false; + + * ``ACS_AcrossEmptyLinesAndComments`` + (in configuration: ``AcrossEmptyLinesAndComments``) + + Same as ACS_Consecutive, but also spans over lines only containing + comments and empty lines, e.g. + + .. code-block:: c++ + + int aaaa = 12; + float b = 23; + std::string ccc; + + int a = 42; + /* A comment. */ + bool c = false; + +**AlignConsecutiveMacros** (``AlignConsecutiveStyle``) + Style of aligning consecutive macro definitions. - This will align C/C++ preprocessor macros of consecutive lines. - Will result in formattings like + ``Consecutive`` will result in formattings like: .. code-block:: c++ @@ -245,6 +429,68 @@ the configuration (without a prefix: ``Auto``). #define foo(x) (x * x) #define bar(y, z) (y + z) + Possible values: + + * ``ACS_None`` (in configuration: ``None``) + Do not align macro definitions on consecutive lines. + + * ``ACS_Consecutive`` (in configuration: ``Consecutive``) + Align macro definitions on consecutive lines. This will result in + formattings like: + + .. code-block:: c++ + + #define SHORT_NAME 42 + #define LONGER_NAME 0x007f + #define EVEN_LONGER_NAME (2) + + #define foo(x) (x * x) + /* some comment */ + #define bar(y, z) (y + z) + + * ``ACS_AcrossEmptyLines`` (in configuration: ``AcrossEmptyLines``) + Same as ACS_Consecutive, but also spans over empty lines, e.g. + + .. code-block:: c++ + + #define SHORT_NAME 42 + #define LONGER_NAME 0x007f + #define EVEN_LONGER_NAME (2) + + #define foo(x) (x * x) + /* some comment */ + #define bar(y, z) (y + z) + + * ``ACS_AcrossComments`` (in configuration: ``AcrossComments``) + Same as ACS_Consecutive, but also spans over lines only containing + comments, e.g. + + .. code-block:: c++ + + #define SHORT_NAME 42 + #define LONGER_NAME 0x007f + #define EVEN_LONGER_NAME (2) + + #define foo(x) (x * x) + /* some comment */ + #define bar(y, z) (y + z) + + * ``ACS_AcrossEmptyLinesAndComments`` + (in configuration: ``AcrossEmptyLinesAndComments``) + + Same as ACS_Consecutive, but also spans over lines only containing + comments and empty lines, e.g. + + .. code-block:: c++ + + #define SHORT_NAME 42 + #define LONGER_NAME 0x007f + #define EVEN_LONGER_NAME (2) + + #define foo(x) (x * x) + /* some comment */ + #define bar(y, z) (y + z) + **AlignEscapedNewlines** (``EscapedNewlineAlignmentStyle``) Options for aligning backslashes in escaped newlines. diff --git a/clang/docs/OpenCLSupport.rst b/clang/docs/OpenCLSupport.rst index 5be7e91adcaf..0eaf0f300ee4 100644 --- a/clang/docs/OpenCLSupport.rst +++ b/clang/docs/OpenCLSupport.rst @@ -112,6 +112,28 @@ Feel free to contact us on `cfe-dev `_ or via `Bugzilla `__. +Fast builtin function declarations +---------------------------------- + +In addition to regular header includes with builtin types and functions using +``-finclude-default-header`` explained in :doc:`UsersManual`, clang +supports a fast mechanism to declare builtin functions with +``-fdeclare-opencl-builtins``. This does not declare the builtin types and +therefore it has to be used in combination with ``-finclude-default-header`` +if full functionality is required. + +**Example of Use**: + + .. code-block:: console + + $ clang -Xclang -finclude-default-header test.cl + +Note that this is a frontend-only flag and therefore it requires the use of +flags that forward options to the frontend, e.g. ``-cc1`` or ``-Xclang``. + +As this feature is still in experimental phase some changes might still occur +on the command line interface side. + C++ libraries for OpenCL ------------------------ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 7fcae5bce164..a595ee2719bd 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -289,9 +289,11 @@ clang-format - Option ``IndentRequires`` has been added to indent the ``requires`` keyword in templates. + - Option ``BreakBeforeConceptDeclarations`` has been added to aid the formatting of concepts. -- Option ``IndentPragmas`` has been added to allow #pragma to indented with the current scope level. This is especially useful when using #pragma to mark OpenMP sections of code. +- Option ``IndentPragmas`` has been added to allow #pragma to indented with the current scope + level. This is especially useful when using #pragma to mark OpenMP sections of code. - Option ``SpaceBeforeCaseColon`` has been added to add a space before the colon in a case or default statement. @@ -300,6 +302,9 @@ clang-format macros which are not parsed as a type in front of a statement. See the documentation for an example. +- Options ``AlignConsecutiveAssignments``, ``AlignConsecutiveBitFields``, + ``AlignConsecutiveDeclarations`` and ``AlignConsecutiveMacros`` have been modified to allow + alignment across empty lines and/or comments. libclang -------- diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index a7b698d77c47..fe944a0166b8 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -3021,6 +3021,11 @@ To enable modules for OpenCL: $ clang -target spir-unknown-unknown -c -emit-llvm -Xclang -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path= test.cl +Another way to circumvent long parsing latency for the OpenCL builtin +declarations is to use mechanism enabled by ``-fdeclare-opencl-builtins`` flag +that is available as an experimental feature (see more information in +:doc:`OpenCLSupport`). + OpenCL Extensions ----------------- diff --git a/clang/docs/tools/dump_format_style.py b/clang/docs/tools/dump_format_style.py index d01c823a9a20..fd5837055789 100755 --- a/clang/docs/tools/dump_format_style.py +++ b/clang/docs/tools/dump_format_style.py @@ -42,7 +42,7 @@ def __init__(self, name, type, comment): def __str__(self): s = '**%s** (``%s``)\n%s' % (self.name, self.type, doxygen2rst(indent(self.comment, 2))) - if self.enum: + if self.enum and self.enum.values: s += indent('\n\nPossible values:\n\n%s\n' % self.enum, 2) if self.nested_struct: s += indent('\n\nNested configuration flags:\n\n%s\n' %self.nested_struct, @@ -104,13 +104,18 @@ def __str__(self): doxygen2rst(indent(self.comment, 2))) def clean_comment_line(line): - match = re.match(r'^/// \\code(\{.(\w+)\})?$', line) + match = re.match(r'^/// (?P +)?\\code(\{.(?P\w+)\})?$', line) if match: - lang = match.groups()[1] + indent = match.group('indent') + if not indent: + indent = '' + lang = match.group('lang') if not lang: lang = 'c++' - return '\n.. code-block:: %s\n\n' % lang - if line == '/// \\endcode': + return '\n%s.. code-block:: %s\n\n' % (indent, lang) + + endcode_match = re.match(r'^/// +\\endcode$', line) + if endcode_match: return '' return line[4:] + '\n' @@ -184,7 +189,9 @@ class State(object): state = State.InStruct enums[enum.name] = enum else: - raise Exception('Invalid format, expected enum field comment or };') + # Enum member without documentation. Must be documented where the enum + # is used. + pass elif state == State.InEnumMemberComment: if line.startswith('///'): comment += clean_comment_line(line) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 9ae17692a9fa..b13d2b8c3d7c 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -2406,12 +2406,10 @@ class ASTContext : public RefCountedBase { return (*SuperTnullability == NullabilityKind::NonNull && *SubTnullability == NullabilityKind::Nullable); } - else { - // For the return type, it's okay for the superclass method to specify - // "nullable" and the subclass method specify "nonnull" - return (*SuperTnullability == NullabilityKind::Nullable && - *SubTnullability == NullabilityKind::NonNull); - } + // For the return type, it's okay for the superclass method to specify + // "nullable" and the subclass method specify "nonnull" + return (*SuperTnullability == NullabilityKind::Nullable && + *SubTnullability == NullabilityKind::NonNull); } return true; } diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def index 9353be1753b0..801916c3ab94 100644 --- a/clang/include/clang/Basic/OpenCLExtensions.def +++ b/clang/include/clang/Basic/OpenCLExtensions.def @@ -10,19 +10,25 @@ // //===----------------------------------------------------------------------===// -// Macro OPENCLEXT or OPENCLEXT_INTERNAL can be defined to enumerate the +// Macro OPENCLEXTNAME or OPENCL_GENERIC_EXTENSION can be defined to enumerate all // OpenCL extensions listed in this file. // -// If the extensions are to be enumerated without the supported OpenCL version, -// define OPENCLEXT(ext) where ext is the name of the extension. -// -// If the extensions are to be enumerated with supported OpenCL version, -// define OPENCLEXT_INTERNAL(ext, avail, core) where +// If extensions are to be enumerated with information about whether +// an extension is core or optional core and minimum OpenCL version +// when an extension becomes available, +// define OPENCL_GENERIC_EXTENSION(ext, avail, core, opt) where // ext - name of the extension or optional core feature. // avail - minimum OpenCL version supporting it. -// core - minimum OpenCL version when the extension becomes optional core -// feature or core feature. ~0U indicates not a core feature or an -// optional core feature. +// core - OpenCL versions mask when the extension becomes core feature. +// 0U indicates not a core feature. +// opt - OpenCL versions mask when the extension becomes optional core +// feature. 0U indicates not a optional core feature. +// +// If extensions are to be enumerated without any information, +// define OPENCLEXTNAME(ext) where ext is the name of the extension. +// +// Difference between optional core feature and core feature is that the +// later is unconditionally supported in specific OpenCL version. // // As per The OpenCL Extension Specification, Section 1.2, in this file, an // extension is defined if and only it either: @@ -32,63 +38,72 @@ // For such an extension, a preprocessor #define that matches the extension // name must be created and a #pragma is required if and only if the // compilation flow is impacted, e.g. due to a difference of syntax or -// semantics in the language compared to the core standard. +// semantics in the language compared to the core standard. #pragma directive +// has no effect for optional core and core features. -#ifndef OPENCLEXT_INTERNAL -#ifndef OPENCLEXT -#pragma error "macro OPENCLEXT or OPENCLEXT_INTERNAL is required" +#ifndef OPENCL_GENERIC_EXTENSION +#ifndef OPENCLEXTNAME +#pragma error "macro OPENCLEXTNAME or OPENCL_GENERIC_EXTENSION is required" #else -#define OPENCLEXT_INTERNAL(ext, ...) OPENCLEXT(ext) -#endif // OPENCLEXT -#endif // OPENCLEXT_INTERNAL +#define OPENCL_GENERIC_EXTENSION(ext, ...) OPENCLEXTNAME(ext) +#endif // OPENCLEXTNAME +#endif // OPENCL_GENERIC_EXTENSION + +// Declaration helpers +#define OPENCL_EXTENSION(ext, avail) OPENCL_GENERIC_EXTENSION(ext, avail, 0U, 0U) +#define OPENCL_COREFEATURE(ext, avail, core) OPENCL_GENERIC_EXTENSION(ext, avail, core, 0U) +#define OPENCL_OPTIONALCOREFEATURE(ext, avail, opt) OPENCL_GENERIC_EXTENSION(ext, avail, 0U, opt) // OpenCL 1.0. -OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 200) -OPENCLEXT_INTERNAL(cl_khr_byte_addressable_store, 100, 110) -OPENCLEXT_INTERNAL(cl_khr_fp16, 100, ~0U) -OPENCLEXT_INTERNAL(cl_khr_fp64, 100, 120) -OPENCLEXT_INTERNAL(cl_khr_global_int32_base_atomics, 100, 110) -OPENCLEXT_INTERNAL(cl_khr_global_int32_extended_atomics, 100, 110) -OPENCLEXT_INTERNAL(cl_khr_local_int32_base_atomics, 100, 110) -OPENCLEXT_INTERNAL(cl_khr_local_int32_extended_atomics, 100, 110) -OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 100, ~0U) -OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 100, ~0U) +OPENCL_COREFEATURE(cl_khr_byte_addressable_store, 100, OCL_C_11P) +OPENCL_COREFEATURE(cl_khr_global_int32_base_atomics, 100, OCL_C_11P) +OPENCL_COREFEATURE(cl_khr_global_int32_extended_atomics, 100, OCL_C_11P) +OPENCL_COREFEATURE(cl_khr_local_int32_base_atomics, 100, OCL_C_11P) +OPENCL_COREFEATURE(cl_khr_local_int32_extended_atomics, 100, OCL_C_11P) +OPENCL_OPTIONALCOREFEATURE(cl_khr_fp64, 100, OCL_C_12P) +OPENCL_EXTENSION(cl_khr_fp16, 100) +OPENCL_EXTENSION(cl_khr_int64_base_atomics, 100) +OPENCL_EXTENSION(cl_khr_int64_extended_atomics, 100) +OPENCL_GENERIC_EXTENSION(cl_khr_3d_image_writes, 100, OCL_C_20, OCL_C_30) // EMBEDDED_PROFILE -OPENCLEXT_INTERNAL(cles_khr_int64, 110, ~0U) +OPENCL_EXTENSION(cles_khr_int64, 110) // OpenCL 1.2. -OPENCLEXT_INTERNAL(cl_khr_depth_images, 120, ~0U) -OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 120, ~0U) +OPENCL_EXTENSION(cl_khr_depth_images, 120) +OPENCL_EXTENSION(cl_khr_gl_msaa_sharing, 120) // OpenCL 2.0. -OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U) -OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U) -OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U) -OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U) +OPENCL_EXTENSION(cl_khr_mipmap_image, 200) +OPENCL_EXTENSION(cl_khr_mipmap_image_writes, 200) +OPENCL_EXTENSION(cl_khr_srgb_image_writes, 200) +OPENCL_EXTENSION(cl_khr_subgroups, 200) // Clang Extensions. -OPENCLEXT_INTERNAL(cl_clang_storage_class_specifiers, 100, ~0U) -OPENCLEXT_INTERNAL(__cl_clang_function_pointers, 100, ~0U) -OPENCLEXT_INTERNAL(__cl_clang_variadic_functions, 100, ~0U) +OPENCL_EXTENSION(cl_clang_storage_class_specifiers, 100) +OPENCL_EXTENSION(__cl_clang_function_pointers, 100) +OPENCL_EXTENSION(__cl_clang_variadic_functions, 100) // AMD OpenCL extensions -OPENCLEXT_INTERNAL(cl_amd_media_ops, 100, ~0U) -OPENCLEXT_INTERNAL(cl_amd_media_ops2, 100, ~0U) +OPENCL_EXTENSION(cl_amd_media_ops, 100) +OPENCL_EXTENSION(cl_amd_media_ops2, 100) // ARM OpenCL extensions -OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_int8, 120, ~0U) -OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_accumulate_int8, 120, ~0U) -OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_accumulate_int16, 120, ~0U) -OPENCLEXT_INTERNAL(cl_arm_integer_dot_product_accumulate_saturate_int8, 120, ~0U) +OPENCL_EXTENSION(cl_arm_integer_dot_product_int8, 120) +OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_int8, 120) +OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_int16, 120) +OPENCL_EXTENSION(cl_arm_integer_dot_product_accumulate_saturate_int8, 120) // Intel OpenCL extensions -OPENCLEXT_INTERNAL(cl_intel_subgroups, 120, ~0U) -OPENCLEXT_INTERNAL(cl_intel_subgroups_short, 120, ~0U) -OPENCLEXT_INTERNAL(cl_intel_device_side_avc_motion_estimation, 120, ~0U) +OPENCL_EXTENSION(cl_intel_subgroups, 120) +OPENCL_EXTENSION(cl_intel_subgroups_short, 120) +OPENCL_EXTENSION(cl_intel_device_side_avc_motion_estimation, 120) + -#undef OPENCLEXT_INTERNAL +#undef OPENCL_OPTIONALCOREFEATURE +#undef OPENCL_COREFEATURE +#undef OPENCL_GENERIC_EXTENSION -#ifdef OPENCLEXT -#undef OPENCLEXT +#ifdef OPENCLEXTNAME +#undef OPENCLEXTNAME #endif diff --git a/clang/include/clang/Basic/OpenCLOptions.h b/clang/include/clang/Basic/OpenCLOptions.h index 66dd06db5b83..fe27ef19d4d5 100644 --- a/clang/include/clang/Basic/OpenCLOptions.h +++ b/clang/include/clang/Basic/OpenCLOptions.h @@ -19,155 +19,145 @@ namespace clang { +namespace { +// This enum maps OpenCL version(s) into value. These values are used as +// a mask to indicate in which OpenCL version(s) extension is a core or +// optional core feature. +enum OpenCLVersionID : unsigned int { + OCL_C_10 = 0x1, + OCL_C_11 = 0x2, + OCL_C_12 = 0x4, + OCL_C_20 = 0x8, + OCL_C_30 = 0x10, + OCL_C_ALL = 0x1f, + OCL_C_11P = OCL_C_ALL ^ OCL_C_10, // OpenCL C 1.1+ + OCL_C_12P = OCL_C_ALL ^ (OCL_C_10 | OCL_C_11), // OpenCL C 1.2+ +}; + +static inline OpenCLVersionID encodeOpenCLVersion(unsigned OpenCLVersion) { + switch (OpenCLVersion) { + default: + llvm_unreachable("Unknown OpenCL version code"); + case 100: + return OCL_C_10; + case 110: + return OCL_C_11; + case 120: + return OCL_C_12; + case 200: + return OCL_C_20; + case 300: + return OCL_C_30; + } +} + +// Simple helper to check if OpenCL C version is contained in a given encoded +// OpenCL C version mask +static inline bool isOpenCLVersionIsContainedInMask(const LangOptions &LO, + unsigned Mask) { + auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion; + OpenCLVersionID Code = encodeOpenCLVersion(CLVer); + return Mask & Code; +} +} // end anonymous namespace + /// OpenCL supported extensions and optional core features class OpenCLOptions { - struct Info { - bool Supported; // Is this option supported - bool Enabled; // Is this option enabled - unsigned Avail; // Option starts to be available in this OpenCL version - unsigned Core; // Option becomes (optional) core feature in this OpenCL - // version - Info(bool S = false, bool E = false, unsigned A = 100, unsigned C = ~0U) - :Supported(S), Enabled(E), Avail(A), Core(C){} - }; - llvm::StringMap OptMap; public: - /// Check if \c Ext is a recognized OpenCL extension. - /// - /// \param Ext - Extension to look up. - /// \returns \c true if \c Ext is known, \c false otherwise. - bool isKnown(llvm::StringRef Ext) const { - return OptMap.find(Ext) != OptMap.end(); - } + struct OpenCLOptionInfo { + // Option starts to be available in this OpenCL version + unsigned Avail; - /// Check if \c Ext is an enabled OpenCL extension. - /// - /// \param Ext - Extension to look up. - /// \returns \c true if \c Ext is known and enabled, \c false otherwise. - bool isEnabled(llvm::StringRef Ext) const { - auto E = OptMap.find(Ext); - return E != OptMap.end() && E->second.Enabled; - } + // Option becomes core feature in this OpenCL versions + unsigned Core; + + // Option becomes optional core feature in this OpenCL versions + unsigned Opt; + + // Is this option supported + bool Supported = false; - /// Check if \c Ext is supported as either an extension or an (optional) core - /// feature for the given OpenCL version. - /// - /// \param Ext - Extension to look up. - /// \param LO - \c LangOptions specifying the OpenCL version. - /// \returns \c true if \c Ext is known and supported, \c false otherwise. - bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const { - auto E = OptMap.find(Ext); - if (E == OptMap.end()) { - return false; + // Is this option enabled + bool Enabled = false; + + OpenCLOptionInfo(unsigned A = 100, unsigned C = 0U, unsigned O = 0U) + : Avail(A), Core(C), Opt(O) {} + + bool isCore() const { return Core != 0U; } + + bool isOptionalCore() const { return Opt != 0U; } + + // Is option available in OpenCL version \p LO. + bool isAvailableIn(const LangOptions &LO) const { + // In C++ mode all extensions should work at least as in v2.0. + auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion; + return CLVer >= Avail; } - // In C++ mode all extensions should work at least as in v2.0. - auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion; - auto I = E->getValue(); - return I.Supported && I.Avail <= CLVer; - } - /// Check if \c Ext is supported as an (optional) OpenCL core features for - /// the given OpenCL version. - /// - /// \param Ext - Extension to look up. - /// \param LO - \c LangOptions specifying the OpenCL version. - /// \returns \c true if \c Ext is known and supported, \c false otherwise. - bool isSupportedCore(llvm::StringRef Ext, const LangOptions &LO) const { - auto E = OptMap.find(Ext); - if (E == OptMap.end()) { - return false; + // Is core option in OpenCL version \p LO. + bool isCoreIn(const LangOptions &LO) const { + return isAvailableIn(LO) && isOpenCLVersionIsContainedInMask(LO, Core); } - // In C++ mode all extensions should work at least as in v2.0. - auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion; - auto I = E->getValue(); - return I.Supported && I.Avail <= CLVer && I.Core != ~0U && CLVer >= I.Core; - } - /// Check if \c Ext is a supported OpenCL extension for the given OpenCL - /// version. - /// - /// \param Ext - Extension to look up. - /// \param LO - \c LangOptions specifying the OpenCL version. - /// \returns \c true if \c Ext is known and supported, \c false otherwise. - bool isSupportedExtension(llvm::StringRef Ext, const LangOptions &LO) const { - auto E = OptMap.find(Ext); - if (E == OptMap.end()) { - return false; + // Is optional core option in OpenCL version \p LO. + bool isOptionalCoreIn(const LangOptions &LO) const { + return isAvailableIn(LO) && isOpenCLVersionIsContainedInMask(LO, Opt); } - // In C++ mode all extensions should work at least as in v2.0. - auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion; - auto I = E->getValue(); - return I.Supported && I.Avail <= CLVer && (I.Core == ~0U || CLVer < I.Core); - } + }; - void enable(llvm::StringRef Ext, bool V = true) { - OptMap[Ext].Enabled = V; - } + bool isKnown(llvm::StringRef Ext) const; - /// Enable or disable support for OpenCL extensions - /// \param Ext name of the extension optionally prefixed with - /// '+' or '-' - /// \param V used when \p Ext is not prefixed by '+' or '-' - void support(llvm::StringRef Ext, bool V = true) { - assert(!Ext.empty() && "Extension is empty."); - - switch (Ext[0]) { - case '+': - V = true; - Ext = Ext.drop_front(); - break; - case '-': - V = false; - Ext = Ext.drop_front(); - break; - } + bool isEnabled(llvm::StringRef Ext) const; - if (Ext.equals("all")) { - supportAll(V); - return; - } - OptMap[Ext].Supported = V; - } + // Is supported as either an extension or an (optional) core feature for + // OpenCL version \p LO. + bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const; - OpenCLOptions(){ -#define OPENCLEXT_INTERNAL(Ext, AvailVer, CoreVer) \ - OptMap[#Ext].Avail = AvailVer; \ - OptMap[#Ext].Core = CoreVer; -#include "clang/Basic/OpenCLExtensions.def" - } + // Is supported OpenCL core feature for OpenCL version \p LO. + // For supported extension, return false. + bool isSupportedCore(llvm::StringRef Ext, const LangOptions &LO) const; - void addSupport(const OpenCLOptions &Opts) { - for (auto &I:Opts.OptMap) - if (I.second.Supported) - OptMap[I.getKey()].Supported = true; - } + // Is supported optional core OpenCL feature for OpenCL version \p LO. + // For supported extension, return false. + bool isSupportedOptionalCore(llvm::StringRef Ext, + const LangOptions &LO) const; - void copy(const OpenCLOptions &Opts) { - OptMap = Opts.OptMap; - } + // Is supported optional core or core OpenCL feature for OpenCL version \p + // LO. For supported extension, return false. + bool isSupportedCoreOrOptionalCore(llvm::StringRef Ext, + const LangOptions &LO) const; - // Turn on or off support of all options. - void supportAll(bool On = true) { - for (llvm::StringMap::iterator I = OptMap.begin(), - E = OptMap.end(); I != E; ++I) - I->second.Supported = On; - } + // Is supported OpenCL extension for OpenCL version \p LO. + // For supported core or optional core feature, return false. + bool isSupportedExtension(llvm::StringRef Ext, const LangOptions &LO) const; - void disableAll() { - for (llvm::StringMap::iterator I = OptMap.begin(), - E = OptMap.end(); I != E; ++I) - I->second.Enabled = false; - } + void enable(llvm::StringRef Ext, bool V = true); - void enableSupportedCore(LangOptions LO) { - for (llvm::StringMap::iterator I = OptMap.begin(), E = OptMap.end(); - I != E; ++I) - if (isSupportedCore(I->getKey(), LO)) - I->second.Enabled = true; - } + /// Enable or disable support for OpenCL extensions + /// \param Ext name of the extension (not prefixed with '+' or '-') + /// \param V value to set for a extension + void support(llvm::StringRef Ext, bool V = true); + + OpenCLOptions(); + OpenCLOptions(const OpenCLOptions &) = default; + + // Set supported options based on target settings and language version + void addSupport(const llvm::StringMap &FeaturesMap, + const LangOptions &Opts); + + // Disable all extensions + void disableAll(); + + // Enable supported core and optional core features + void enableSupportedCore(const LangOptions &LO); friend class ASTWriter; friend class ASTReader; + + using OpenCLOptionInfoMap = llvm::StringMap; + +private: + OpenCLOptionInfoMap OptMap; }; } // end namespace clang diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index de91ca2ee82e..b782172d93a3 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1438,21 +1438,39 @@ class TargetInfo : public virtual TransferrableTargetInfo, /// Set supported OpenCL extensions and optional core features. virtual void setSupportedOpenCLOpts() {} + virtual void supportAllOpenCLOpts(bool V = true) { +#define OPENCLEXTNAME(Ext) getTargetOpts().OpenCLFeaturesMap[#Ext] = V; +#include "clang/Basic/OpenCLExtensions.def" + } + /// Set supported OpenCL extensions as written on command line - virtual void setOpenCLExtensionOpts() { + virtual void setCommandLineOpenCLOpts() { for (const auto &Ext : getTargetOpts().OpenCLExtensionsAsWritten) { - getTargetOpts().SupportedOpenCLOptions.support(Ext); + bool IsPrefixed = (Ext[0] == '+' || Ext[0] == '-'); + std::string Name = IsPrefixed ? Ext.substr(1) : Ext; + bool V = IsPrefixed ? Ext[0] == '+' : true; + + if (Name == "all") { + supportAllOpenCLOpts(V); + continue; + } + + getTargetOpts().OpenCLFeaturesMap[Name] = V; } } + /// Define OpenCL macros based on target settings and language version + void getOpenCLFeatureDefines(const LangOptions &Opts, + MacroBuilder &Builder) const; + /// Get supported OpenCL extensions and optional core features. - OpenCLOptions &getSupportedOpenCLOpts() { - return getTargetOpts().SupportedOpenCLOptions; + llvm::StringMap &getSupportedOpenCLOpts() { + return getTargetOpts().OpenCLFeaturesMap; } /// Get const supported OpenCL extensions and optional core features. - const OpenCLOptions &getSupportedOpenCLOpts() const { - return getTargetOpts().SupportedOpenCLOptions; + const llvm::StringMap &getSupportedOpenCLOpts() const { + return getTargetOpts().OpenCLFeaturesMap; } /// Get address space for OpenCL type. diff --git a/clang/include/clang/Basic/TargetOptions.h b/clang/include/clang/Basic/TargetOptions.h index f81c150b7d0a..81c15adb8248 100644 --- a/clang/include/clang/Basic/TargetOptions.h +++ b/clang/include/clang/Basic/TargetOptions.h @@ -62,7 +62,7 @@ class TargetOptions { llvm::StringMap FeatureMap; /// Supported OpenCL extensions and optional core features. - OpenCLOptions SupportedOpenCLOptions; + llvm::StringMap OpenCLFeaturesMap; /// The list of OpenCL extensions to enable or disable, as written on /// the command line. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 355e433a42e4..d987b69a76da 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -475,38 +475,23 @@ multiclass BoolOption; } -/// Creates a BoolOption with the changing available on the CC1 command line. -multiclass BoolCC1Option> { - defvar changed_by_cc1 - = ChangedBy; - - defm NAME : BoolOption; -} - -/// Creates a BoolOption where both of the flags are prefixed with "f", are in -/// the Group, and the changing flag is also available on the CC1 -/// command line. +/// Creates a BoolOption where both of the flags are prefixed with "f" and have +/// the Group. multiclass BoolFOption> { - defm NAME : BoolCC1Option<"f", flag_base, kpm, defaults_to, changed_by, - reset_by, both>, + defm NAME : BoolOption<"f", flag_base, kpm, defaults_to, changed_by, reset_by, + both>, Group; } -// Creates a BoolOption where both of the flags are prefixed with "g", are in -// the Group, and the changing flag is also available on the CC1 -// command line. +// Creates a BoolOption where both of the flags are prefixed with "g" and have +// the Group. multiclass BoolGOption> { - defm NAME : BoolCC1Option<"g", flag_base, kpm, defaults_to, changed_by, - reset_by, both>, + defm NAME : BoolOption<"g", flag_base, kpm, defaults_to, changed_by, reset_by, + both>, Group; } @@ -971,7 +956,7 @@ defm cuda_approx_transcendentals : OptInFFlag<"cuda-approx-transcendentals", "Us " approximate transcendental functions">; defm gpu_rdc : BoolFOption<"gpu-rdc", LangOpts<"GPURelocatableDeviceCode">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; def : Flag<["-"], "fcuda-rdc">, Alias; def : Flag<["-"], "fno-cuda-rdc">, Alias; @@ -991,17 +976,17 @@ def fhip_dump_offload_linker_script : Flag<["-"], "fhip-dump-offload-linker-scri Group, Flags<[NoArgumentUnused, HelpHidden]>; defm hip_new_launch_api : BoolFOption<"hip-new-launch-api", LangOpts<"HIPUseNewLaunchAPI">, DefaultsToFalse, - ChangedBy, ResetBy, + ChangedBy, ResetBy, BothFlags<[], " new kernel launching API for HIP">>; defm gpu_allow_device_init : OptInFFlag<"gpu-allow-device-init", "Allow", "Don't allow", " device side init function in HIP">; defm gpu_defer_diag : BoolFOption<"gpu-defer-diag", LangOpts<"GPUDeferDiag">, DefaultsToFalse, - ChangedBy, ResetBy, + ChangedBy, ResetBy, BothFlags<[], " host/device related diagnostic messages for CUDA/HIP">>; defm gpu_exclude_wrong_side_overloads : BoolFOption<"gpu-exclude-wrong-side-overloads", LangOpts<"GPUExcludeWrongSideOverloads">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy, BothFlags<[HelpHidden], " in overloading resolution for CUDA/HIP">>; def gpu_max_threads_per_block_EQ : Joined<["--"], "gpu-max-threads-per-block=">, @@ -1063,14 +1048,14 @@ def fPIE : Flag<["-"], "fPIE">, Group; def fno_PIE : Flag<["-"], "fno-PIE">, Group; defm access_control : BoolFOption<"access-control", LangOpts<"AccessControl">, DefaultsToTrue, - ChangedBy, + ChangedBy, ResetBy>; def falign_functions : Flag<["-"], "falign-functions">, Group; def falign_functions_EQ : Joined<["-"], "falign-functions=">, Group; def fno_align_functions: Flag<["-"], "fno-align-functions">, Group; defm allow_editor_placeholders : BoolFOption<"allow-editor-placeholders", LangOpts<"AllowEditorPlaceholders">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; def fallow_unsupported : Flag<["-"], "fallow-unsupported">, Group; def fapple_kext : Flag<["-"], "fapple-kext">, Group, Flags<[CC1Option]>, @@ -1078,7 +1063,7 @@ def fapple_kext : Flag<["-"], "fapple-kext">, Group, Flags<[CC1Option]> MarshallingInfoFlag>; defm apple_pragma_pack : BoolFOption<"apple-pragma-pack", LangOpts<"ApplePragmaPack">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; def fxl_pragma_pack : Flag<["-"], "fxl-pragma-pack">, Group, Flags<[CC1Option]>, HelpText<"Enable IBM XL #pragma pack handling">; @@ -1126,7 +1111,7 @@ def fembed_bitcode_marker : Flag<["-"], "fembed-bitcode-marker">, HelpText<"Embed placeholder LLVM IR data as a marker">; defm gnu_inline_asm : BoolFOption<"gnu-inline-asm", LangOpts<"GNUAsm">, DefaultsToTrue, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; def fprofile_sample_use : Flag<["-"], "fprofile-sample-use">, Group, Flags<[CoreOption]>; @@ -1165,7 +1150,7 @@ def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">, Alias; defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling", CodeGenOpts<"DebugInfoForProfiling">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">, Group, Flags<[CoreOption]>, @@ -1186,7 +1171,7 @@ def fprofile_remapping_file : Separate<["-"], "fprofile-remapping-file">, Group, Flags<[CoreOption]>, Alias; defm coverage_mapping : BoolFOption<"coverage-mapping", CodeGenOpts<"CoverageMapping">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy, BothFlags<[CoreOption]>>; def fprofile_generate : Flag<["-"], "fprofile-generate">, Group, Flags<[CoreOption]>, @@ -1218,10 +1203,10 @@ def fno_profile_use : Flag<["-"], "fno-profile-use">, Alias; defm profile_arcs : BoolFOption<"profile-arcs", CodeGenOpts<"EmitGcovArcs">, DefaultsToFalse, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; defm test_coverage : BoolFOption<"test-coverage", CodeGenOpts<"EmitGcovNotes">, DefaultsToFalse, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; def fprofile_filter_files_EQ : Joined<["-"], "fprofile-filter-files=">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Instrument only functions from files where names match any regex separated by a semi-colon">, @@ -1246,20 +1231,20 @@ def forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">, defm addrsig : BoolFOption<"addrsig", CodeGenOpts<"Addrsig">, DefaultsToFalse, - ChangedBy, ResetBy, + ChangedBy, ResetBy, BothFlags<[CoreOption], " an address-significance table">>; defm blocks : OptInFFlag<"blocks", "Enable the 'blocks' language feature", "", "", [CoreOption]>; def fbootclasspath_EQ : Joined<["-"], "fbootclasspath=">, Group; defm borland_extensions : BoolFOption<"borland-extensions", LangOpts<"Borland">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; def fbuiltin : Flag<["-"], "fbuiltin">, Group, Flags<[CoreOption]>; def fbuiltin_module_map : Flag <["-"], "fbuiltin-module-map">, Group, Flags<[NoXarchOption]>, HelpText<"Load the clang builtins module map file.">; defm caret_diagnostics : BoolFOption<"caret-diagnostics", DiagnosticOpts<"ShowCarets">, DefaultsToTrue, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; def fclang_abi_compat_EQ : Joined<["-"], "fclang-abi-compat=">, Group, Flags<[CC1Option]>, MetaVarName<"">, Values<".,latest">, HelpText<"Attempt to match the ABI of Clang ">; @@ -1300,7 +1285,7 @@ def fcf_runtime_abi_EQ : Joined<["-"], "fcf-runtime-abi=">, Group, MarshallingInfoString, "ObjectiveC">, AutoNormalizeEnum; defm constant_cfstrings : BoolFOption<"constant-cfstrings", LangOpts<"NoConstantCFStrings">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; def fconstant_string_class_EQ : Joined<["-"], "fconstant-string-class=">, Group; def fconstexpr_depth_EQ : Joined<["-"], "fconstexpr-depth=">, Group; @@ -1316,7 +1301,7 @@ def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, Group, Group; defm cxx_exceptions: BoolFOption<"cxx-exceptions", LangOpts<"CXXExceptions">, DefaultsToFalse, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; def fcxx_modules : Flag <["-"], "fcxx-modules">, Group, Flags<[NoXarchOption]>; def fdebug_pass_arguments : Flag<["-"], "fdebug-pass-arguments">, Group; @@ -1336,7 +1321,7 @@ def fdiagnostics_print_source_range_info : Flag<["-"], "fdiagnostics-print-sourc MarshallingInfoFlag>; defm diagnostics_show_hotness : BoolFOption<"diagnostics-show-hotness", CodeGenOpts<"DiagnosticsWithHotness">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; def fdiagnostics_hotness_threshold_EQ : Joined<["-"], "fdiagnostics-hotness-threshold=">, Group, Flags<[CC1Option]>, MetaVarName<"">, @@ -1344,7 +1329,7 @@ def fdiagnostics_hotness_threshold_EQ : Joined<["-"], "fdiagnostics-hotness-thre "Use 'auto' to apply the threshold from profile summary">; defm diagnostics_show_option : BoolFOption<"diagnostics-show-option", DiagnosticOpts<"ShowOptionNames">, DefaultsToTrue, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; defm diagnostics_show_note_include_stack : BoolFOption<"diagnostics-show-note-include-stack", DiagnosticOpts<"ShowNoteIncludeStack">, DefaultsToFalse, ChangedBy, @@ -1367,10 +1352,10 @@ def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">, Group, Group; defm dwarf_directory_asm : BoolFOption<"dwarf-directory-asm", CodeGenOpts<"NoDwarfDirectoryAsm">, DefaultsToFalse, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; defm elide_constructors : BoolFOption<"elide-constructors", LangOpts<"ElideConstructors">, DefaultsToTrue, - ChangedBy, + ChangedBy, ResetBy>; def fno_elide_type : Flag<["-"], "fno-elide-type">, Group, Flags<[CC1Option]>, @@ -1384,13 +1369,13 @@ def femit_all_decls : Flag<["-"], "femit-all-decls">, Group, Flags<[CC1 MarshallingInfoFlag>; defm emulated_tls : BoolFOption<"emulated-tls", CodeGenOpts<"EmulatedTLS">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy, BothFlags<[CC1Option]>>; def fencoding_EQ : Joined<["-"], "fencoding=">, Group; def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group, Flags<[CoreOption]>; defm exceptions : BoolFOption<"exceptions", LangOpts<"Exceptions">, DefaultsToFalse, - ChangedBy, ResetBy, + ChangedBy, ResetBy, BothFlags<[], " support for exception handling">>; def fdwarf_exceptions : Flag<["-"], "fdwarf-exceptions">, Group, HelpText<"Use DWARF style exceptions">; @@ -1439,17 +1424,17 @@ def fsignaling_math : Flag<["-"], "fsignaling-math">, Group; def fno_signaling_math : Flag<["-"], "fno-signaling-math">, Group; defm jump_tables : BoolFOption<"jump-tables", CodeGenOpts<"NoUseJumpTables">, DefaultsToFalse, - ChangedBy, ResetBy, + ChangedBy, ResetBy, BothFlags<[], " jump tables for lowering switches">>; defm force_enable_int128 : OptInFFlag<"force-enable-int128", "Enable", "Disable", " support for int128_t type", [], TargetOpts<"ForceEnableInt128">>; defm keep_static_consts : BoolFOption<"keep-static-consts", CodeGenOpts<"KeepStaticConsts">, DefaultsToFalse, - ChangedBy, ResetBy, + ChangedBy, ResetBy, BothFlags<[NoXarchOption], " static const variables if unused">>; defm fixed_point : OptInFFlag<"fixed-point", "Enable", "Disable", " fixed point types">; defm cxx_static_destructors : BoolFOption<"c++-static-destructors", LangOpts<"RegisterStaticDestructors">, DefaultsToTrue, - ChangedBy, + ChangedBy, ResetBy>; def fsymbol_partition_EQ : Joined<["-"], "fsymbol-partition=">, Group, Flags<[CC1Option]>, MarshallingInfoString>; @@ -1654,7 +1639,7 @@ defm finite_math_only : OptInFFlag<"finite-math-only", "", "", "", [], LangOpts<"FiniteMathOnly">, [cl_finite_math_only, ffast_math]>; defm signed_zeros : BoolFOption<"signed-zeros", LangOpts<"NoSignedZero">, DefaultsToFalse, - ChangedBy, ResetBy>; def fhonor_nans : Flag<["-"], "fhonor-nans">, Group; @@ -1681,7 +1666,7 @@ def ffp_contract : Joined<["-"], "ffp-contract=">, Group, defm strict_float_cast_overflow : BoolFOption<"strict-float-cast-overflow", CodeGenOpts<"StrictFloatCastOverflow">, DefaultsToTrue, - ChangedBy, ResetBy>; @@ -1690,14 +1675,14 @@ def fno_for_scope : Flag<["-"], "fno-for-scope">, Group; defm rewrite_imports : BoolFOption<"rewrite-imports", PreprocessorOutputOpts<"RewriteImports">, DefaultsToFalse, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; defm rewrite_includes : BoolFOption<"rewrite-includes", PreprocessorOutputOpts<"RewriteIncludes">, DefaultsToFalse, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; defm delete_null_pointer_checks : BoolFOption<"delete-null-pointer-checks", CodeGenOpts<"NullPointerIsValid">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy, BothFlags<[CoreOption]>>; @@ -1711,7 +1696,7 @@ def frewrite_map_file_EQ : Joined<["-"], "frewrite-map-file=">, defm use_line_directives : BoolFOption<"use-line-directives", PreprocessorOutputOpts<"UseLineDirectives">, DefaultsToFalse, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; def ffreestanding : Flag<["-"], "ffreestanding">, Group, Flags<[CC1Option]>, HelpText<"Assert that the compilation takes place in a freestanding environment">, @@ -1883,7 +1868,7 @@ def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">, Group, Flags<[NoXarchOption, CoreOption]>; defm merge_all_constants : BoolFOption<"merge-all-constants", CodeGenOpts<"MergeAllConstants">, DefaultsToFalse, - ChangedBy, ResetBy, + ChangedBy, ResetBy, BothFlags<[], " merging of constants">>; def fmessage_length_EQ : Joined<["-"], "fmessage-length=">, Group, Flags<[CC1Option]>, HelpText<"Format message diagnostics so that they fit within N columns">, @@ -1906,7 +1891,7 @@ def fms_compatibility_version "(default))">; defm delayed_template_parsing : BoolFOption<"delayed-template-parsing", LangOpts<"DelayedTemplateParsing">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy, BothFlags<[CoreOption]>>; def fms_memptr_rep_EQ : Joined<["-"], "fms-memptr-rep=">, Group, Flags<[CC1Option]>, @@ -2031,7 +2016,7 @@ def fno_modules_search_all : Flag <["-"], "fno-modules-search-all">, Group; defm implicit_modules : BoolFOption<"implicit-modules", LangOpts<"ImplicitModules">, DefaultsToTrue, - ChangedBy, ResetBy, BothFlags<[NoXarchOption]>>; + ChangedBy, ResetBy, BothFlags<[NoXarchOption]>>; def fretain_comments_from_system_headers : Flag<["-"], "fretain-comments-from-system-headers">, Group, Flags<[CC1Option]>, MarshallingInfoFlag>; @@ -2119,7 +2104,7 @@ def fno_temp_file : Flag<["-"], "fno-temp-file">, Group, MarshallingInfoNegativeFlag>; defm use_cxa_atexit : BoolFOption<"use-cxa-atexit", CodeGenOpts<"CXAAtExit">, DefaultsToTrue, - ChangedBy, + ChangedBy, ResetBy>; def fno_unit_at_a_time : Flag<["-"], "fno-unit-at-a-time">, Group; def fno_unwind_tables : Flag<["-"], "fno-unwind-tables">, Group; @@ -2132,7 +2117,7 @@ def fobjc_arc : Flag<["-"], "fobjc-arc">, Group, Flags<[CC1Option]>, def fno_objc_arc : Flag<["-"], "fno-objc-arc">, Group; defm objc_convert_messages_to_runtime_calls : BoolFOption<"objc-convert-messages-to-runtime-calls", CodeGenOpts<"ObjCConvertMessagesToRuntimeCalls">, DefaultsToTrue, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; defm objc_arc_exceptions : OptInFFlag<"objc-arc-exceptions", "Use EH-safe code when synthesizing retains and releases in -fobjc-arc", "", "", [], CodeGenOpts<"ObjCAutoRefCountExceptions">>; @@ -2140,18 +2125,18 @@ def fobjc_atdefs : Flag<["-"], "fobjc-atdefs">, Group; def fobjc_call_cxx_cdtors : Flag<["-"], "fobjc-call-cxx-cdtors">, Group; defm objc_exceptions : BoolFOption<"objc-exceptions", LangOpts<"ObjCExceptions">, DefaultsToFalse, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; defm application_extension : BoolFOption<"application-extension", LangOpts<"AppExt">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; defm relaxed_template_template_args : BoolFOption<"relaxed-template-template-args", LangOpts<"RelaxedTemplateTemplateArgs">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; defm sized_deallocation : BoolFOption<"sized-deallocation", LangOpts<"SizedDeallocation">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; def faligned_allocation : Flag<["-"], "faligned-allocation">, Flags<[CC1Option]>, HelpText<"Enable C++17 aligned allocation functions">, Group; @@ -2170,7 +2155,7 @@ def fobjc_legacy_dispatch : Flag<["-"], "fobjc-legacy-dispatch">, Group def fobjc_new_property : Flag<["-"], "fobjc-new-property">, Group; defm objc_infer_related_result_type : BoolFOption<"objc-infer-related-result-type", LangOpts<"ObjCInferRelatedResultType">, DefaultsToTrue, - ChangedBy, + ChangedBy, ResetBy>; def fobjc_link_runtime: Flag<["-"], "fobjc-link-runtime">, Group; def fobjc_weak : Flag<["-"], "fobjc-weak">, Group, Flags<[CC1Option]>, @@ -2225,7 +2210,7 @@ def fopenmp_cuda_teams_reduction_recs_num_EQ : Joined<["-"], "fopenmp-cuda-teams Flags<[CC1Option, NoArgumentUnused, HelpHidden]>; defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse", LangOpts<"OpenMPOptimisticCollapse">, DefaultsToFalse, - ChangedBy, ResetBy, BothFlags<[NoArgumentUnused, HelpHidden]>>; + ChangedBy, ResetBy, BothFlags<[NoArgumentUnused, HelpHidden]>>; def fopenmp_cuda_parallel_target_regions : Flag<["-"], "fopenmp-cuda-parallel-target-regions">, Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>, HelpText<"Support parallel execution of target regions on Cuda-based devices.">; @@ -2238,7 +2223,7 @@ def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, Grou def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, Group; defm escaping_block_tail_calls : BoolFOption<"escaping-block-tail-calls", CodeGenOpts<"NoEscapingBlockTailCalls">, DefaultsToFalse, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">; def force__flat__namespace : Flag<["-"], "force_flat_namespace">; def force__load : Separate<["-"], "force_load">; @@ -2255,7 +2240,7 @@ def fmax_type_align_EQ : Joined<["-"], "fmax-type-align=">, Group, Flag def fno_max_type_align : Flag<["-"], "fno-max-type-align">, Group; defm pascal_strings : BoolFOption<"pascal-strings", LangOpts<"PascalStrings">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; // Note: This flag has different semantics in the driver and in -cc1. The driver accepts -fpatchable-function-entry=M,N // and forwards it to -cc1 as -fpatchable-function-entry=M and -fpatchable-function-entry-offset=N. In -cc1, both flags @@ -2276,15 +2261,15 @@ def fno_direct_access_external_data : Flag<["-"], "fno-direct-access-external-da HelpText<"Use GOT indirection to reference external data symbols">; defm plt : BoolFOption<"plt", CodeGenOpts<"NoPLT">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; defm ropi : BoolFOption<"ropi", LangOpts<"ROPI">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; defm rwpi : BoolFOption<"rwpi", LangOpts<"RWPI">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; def fplugin_EQ : Joined<["-"], "fplugin=">, Group, Flags<[NoXarchOption]>, MetaVarName<"">, HelpText<"Load the named plugin (dynamic shared object)">; @@ -2294,7 +2279,7 @@ def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">, MarshallingInfoStringVector>; defm preserve_as_comments : BoolFOption<"preserve-as-comments", CodeGenOpts<"PreserveAsmComments">, DefaultsToTrue, - ChangedBy, + ChangedBy, ResetBy>; def framework : Separate<["-"], "framework">, Flags<[LinkerInput]>; def frandom_seed_EQ : Joined<["-"], "frandom-seed=">, Group; @@ -2305,7 +2290,7 @@ defm rtti_data : OptOutFFlag<"rtti-data", "", "Disable generation of RTTI data"> def : Flag<["-"], "fsched-interblock">, Group; defm short_enums : BoolFOption<"short-enums", LangOpts<"ShortEnums">, DefaultsToFalse, - ChangedBy, ResetBy>; def fchar8__t : Flag<["-"], "fchar8_t">, Group, Flags<[CC1Option]>, @@ -2323,15 +2308,15 @@ def fshow_overloads_EQ : Joined<["-"], "fshow-overloads=">, Group, Flag MarshallingInfoString, "Ovl_All">, AutoNormalizeEnum; defm show_column : BoolFOption<"show-column", DiagnosticOpts<"ShowColumn">, DefaultsToTrue, - ChangedBy, + ChangedBy, ResetBy>; defm show_source_location : BoolFOption<"show-source-location", DiagnosticOpts<"ShowLocation">, DefaultsToTrue, - ChangedBy, + ChangedBy, ResetBy>; defm spell_checking : BoolFOption<"spell-checking", LangOpts<"SpellChecking">, DefaultsToTrue, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; def fspell_checking_limit_EQ : Joined<["-"], "fspell-checking-limit=">, Group; def fsigned_bitfields : Flag<["-"], "fsigned-bitfields">, Group; defm signed_char : OptOutFFlag<"signed-char", "char is signed", "char is unsigned">; @@ -2340,7 +2325,7 @@ def fstack_protector_all : Flag<["-"], "fstack-protector-all">, Group, HelpText<"Enable stack protectors for all functions">; defm stack_clash_protection : BoolFOption<"stack-clash-protection", CodeGenOpts<"StackClashProtector">, DefaultsToFalse, - ChangedBy, ResetBy, + ChangedBy, ResetBy, BothFlags<[], " stack clash protection">>; def fstack_protector_strong : Flag<["-"], "fstack-protector-strong">, Group, HelpText<"Enable stack protectors for some functions vulnerable to stack smashing. " @@ -2388,7 +2373,7 @@ def fstrict_enums : Flag<["-"], "fstrict-enums">, Group, Flags<[CC1Opti MarshallingInfoFlag>; defm strict_vtable_pointers : BoolFOption<"strict-vtable-pointers", CodeGenOpts<"StrictVTablePointers">, DefaultsToFalse, - ChangedBy, ResetBy>; def fstrict_overflow : Flag<["-"], "fstrict-overflow">, Group; @@ -2487,7 +2472,7 @@ def Wframe_larger_than_EQ : Joined<["-"], "Wframe-larger-than=">, Group def : Flag<["-"], "fterminated-vtables">, Alias; defm threadsafe_statics : BoolFOption<"threadsafe-statics", LangOpts<"ThreadsafeStatics">, DefaultsToTrue, - ChangedBy, + ChangedBy, ResetBy>; def ftime_report : Flag<["-"], "ftime-report">, Group, Flags<[CC1Option]>, MarshallingInfoFlag>; @@ -2533,7 +2518,7 @@ def fno_unroll_loops : Flag<["-"], "fno-unroll-loops">, Group, HelpText<"Turn off loop unroller">, Flags<[CC1Option]>; defm reroll_loops : BoolFOption<"reroll-loops", CodeGenOpts<"RerollLoops">, DefaultsToFalse, - ChangedBy, ResetBy>; + ChangedBy, ResetBy>; def ftrigraphs : Flag<["-"], "ftrigraphs">, Group, HelpText<"Process trigraph sequences">, Flags<[CC1Option]>; def fno_trigraphs : Flag<["-"], "fno-trigraphs">, Group, @@ -2544,11 +2529,11 @@ def fno_unsigned_char : Flag<["-"], "fno-unsigned-char">; def funwind_tables : Flag<["-"], "funwind-tables">, Group; defm register_global_dtors_with_atexit : BoolFOption<"register-global-dtors-with-atexit", CodeGenOpts<"RegisterGlobalDtorsWithAtExit">, DefaultsToFalse, - ChangedBy, ResetBy, + ChangedBy, ResetBy, BothFlags<[], " atexit or __cxa_atexit to register global destructors">>; defm use_init_array : BoolFOption<"use-init-array", CodeGenOpts<"UseInitArray">, DefaultsToTrue, - ChangedBy, + ChangedBy, ResetBy>; def fno_var_tracking : Flag<["-"], "fno-var-tracking">, Group; def fverbose_asm : Flag<["-"], "fverbose-asm">, Group, @@ -2556,7 +2541,7 @@ def fverbose_asm : Flag<["-"], "fverbose-asm">, Group, def dA : Flag<["-"], "dA">, Alias; defm visibility_from_dllstorageclass : BoolFOption<"visibility-from-dllstorageclass", LangOpts<"VisibilityFromDLLStorageClass">, DefaultsToFalse, - ChangedBy, + ChangedBy, ResetBy>; def fvisibility_dllexport_EQ : Joined<["-"], "fvisibility-dllexport=">, Group, Flags<[CC1Option]>, HelpText<"The visibility for dllexport defintions [-fvisibility-from-dllstorageclass]">, @@ -2581,7 +2566,7 @@ def fvisibility_inlines_hidden : Flag<["-"], "fvisibility-inlines-hidden">, Grou Flags<[CC1Option]>, MarshallingInfoFlag>; defm visibility_inlines_hidden_static_local_var : BoolFOption<"visibility-inlines-hidden-static-local-var", LangOpts<"VisibilityInlinesHiddenStaticLocalVar">, DefaultsToFalse, - ChangedBy