diff options
author | Brad King <brad.king@kitware.com> | 2021-05-11 12:47:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-13 12:33:04 (GMT) |
commit | db8e0beeaca0f0330431d5874bfb22e0a3f1fb70 (patch) | |
tree | ebdb9c5c49b16d98d012c2d357373170e4c59485 /Source/cmGlobalNinjaGenerator.cxx | |
parent | bd12b97d05314500892426e827dc0ad57c4f4fdc (diff) | |
download | CMake-db8e0beeaca0f0330431d5874bfb22e0a3f1fb70.zip CMake-db8e0beeaca0f0330431d5874bfb22e0a3f1fb70.tar.gz CMake-db8e0beeaca0f0330431d5874bfb22e0a3f1fb70.tar.bz2 |
cmGlobalNinjaGenerator: Clarify semantics of Fortran scanning info
Use `optional<>` instead of `unique_ptr<>` to hold optional value.
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0a5b169..d667575 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -9,6 +9,7 @@ #include <cm/iterator> #include <cm/memory> +#include <cm/optional> #include <cm/string_view> #include <cmext/algorithm> #include <cmext/memory> @@ -2255,7 +2256,7 @@ struct cmSourceInfo std::vector<std::string> Includes; }; -std::unique_ptr<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran( +cm::optional<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran( std::string const& arg_tdi, std::string const& arg_pp); } @@ -2312,7 +2313,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg, return 1; } - std::unique_ptr<cmSourceInfo> info; + cm::optional<cmSourceInfo> info; if (arg_lang == "Fortran") { info = cmcmd_cmake_ninja_depends_fortran(arg_tdi, arg_pp); } else { @@ -2348,9 +2349,10 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg, namespace { -std::unique_ptr<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran( +cm::optional<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran( std::string const& arg_tdi, std::string const& arg_pp) { + cm::optional<cmSourceInfo> info; cmFortranCompiler fc; std::vector<std::string> includes; { @@ -2363,7 +2365,7 @@ std::unique_ptr<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran( cmSystemTools::Error( cmStrCat("-E cmake_ninja_depends failed to parse ", arg_tdi, reader.getFormattedErrorMessages())); - return nullptr; + return info; } } @@ -2390,14 +2392,14 @@ std::unique_ptr<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran( if (!cmFortranParser_FilePush(&parser, arg_pp.c_str())) { cmSystemTools::Error( cmStrCat("-E cmake_ninja_depends failed to open ", arg_pp)); - return nullptr; + return info; } if (cmFortran_yyparse(parser.Scanner) != 0) { // Failed to parse the file. - return nullptr; + return info; } - auto info = cm::make_unique<cmSourceInfo>(); + info = cmSourceInfo(); for (std::string const& provide : finfo.Provides) { cmSourceReqInfo src_info; src_info.LogicalName = provide; |