diff --git a/aminclude_static.am b/aminclude_static.am index 12c8609bc2..fb61ba30dc 100644 --- a/aminclude_static.am +++ b/aminclude_static.am @@ -1,6 +1,6 @@ # aminclude_static.am generated automatically by Autoconf -# from AX_AM_MACROS_STATIC on Sun May 23 13:53:53 PDT 2021 +# from AX_AM_MACROS_STATIC on Sun May 30 13:10:25 PDT 2021 # Code coverage diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 index 2c18e49c56..9413da624d 100644 --- a/m4/ax_cxx_compile_stdcxx.m4 +++ b/m4/ax_cxx_compile_stdcxx.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html +# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html # =========================================================================== # # SYNOPSIS @@ -16,7 +16,7 @@ # The second argument, if specified, indicates whether you insist on an # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. # -std=c++11). If neither is specified, you get whatever works, with -# preference for an extended mode. +# preference for no added switch, and then for an extended mode. # # The third argument, if specified 'mandatory' or if left unspecified, # indicates that baseline support for the specified C++ standard is @@ -33,21 +33,24 @@ # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov # Copyright (c) 2015 Paul Norman # Copyright (c) 2015 Moritz Klammler +# Copyright (c) 2016, 2018 Krzesimir Nowak +# Copyright (c) 2019 Enji Cooper +# Copyright (c) 2020 Jason Merrill # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 4 +#serial 12 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl - m4_if([$1], [11], [], - [$1], [14], [], - [$1], [17], [m4_fatal([support for C++17 not yet implemented in AX_CXX_COMPILE_STDCXX])], + m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], + [$1], [14], [ax_cxx_compile_alternatives="14 1y"], + [$1], [17], [ax_cxx_compile_alternatives="17 1z"], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], @@ -59,18 +62,21 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) AC_LANG_PUSH([C++])dnl ac_success=no - AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, - ax_cv_cxx_compile_cxx$1, - [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [ax_cv_cxx_compile_cxx$1=yes], - [ax_cv_cxx_compile_cxx$1=no])]) - if test x$ax_cv_cxx_compile_cxx$1 = xyes; then - ac_success=yes - fi + + m4_if([$2], [], [dnl + AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, + ax_cv_cxx_compile_cxx$1, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [ax_cv_cxx_compile_cxx$1=yes], + [ax_cv_cxx_compile_cxx$1=no])]) + if test x$ax_cv_cxx_compile_cxx$1 = xyes; then + ac_success=yes + fi]) m4_if([$2], [noext], [], [dnl if test x$ac_success = xno; then - for switch in -std=gnu++$1 -std=gnu++0x; do + for alternative in ${ax_cxx_compile_alternatives}; do + switch="-std=gnu++${alternative}" cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, @@ -96,22 +102,27 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl dnl HP's aCC needs +std=c++11 according to: dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf dnl Cray's crayCC needs "-h std=c++11" - for switch in -std=c++$1 -std=c++0x +std=c++$1 "-h std=c++$1"; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, - $cachevar, - [ac_save_CXX="$CXX" - CXX="$CXX $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXX="$ac_save_CXX"]) - if eval test x\$$cachevar = xyes; then - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" + for alternative in ${ax_cxx_compile_alternatives}; do + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break fi - ac_success=yes + done + if test x$ac_success = xyes; then break fi done @@ -148,6 +159,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ) +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 +) dnl Tests for new features in C++11 @@ -185,11 +201,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -518,7 +536,7 @@ namespace cxx14 } - namespace test_digit_seperators + namespace test_digit_separators { constexpr auto ten_million = 100'000'000; @@ -560,3 +578,385 @@ namespace cxx14 #endif // __cplusplus >= 201402L ]]) + + +dnl Tests for new features in C++17 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ + +// If the compiler admits that it is not ready for C++17, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201703L + +#error "This is not a C++17 compiler" + +#else + +#include +#include +#include + +namespace cxx17 +{ + + namespace test_constexpr_lambdas + { + + constexpr int foo = [](){return 42;}(); + + } + + namespace test::nested_namespace::definitions + { + + } + + namespace test_fold_expression + { + + template + int multiply(Args... args) + { + return (args * ... * 1); + } + + template + bool all(Args... args) + { + return (args && ...); + } + + } + + namespace test_extended_static_assert + { + + static_assert (true); + + } + + namespace test_auto_brace_init_list + { + + auto foo = {5}; + auto bar {5}; + + static_assert(std::is_same, decltype(foo)>::value); + static_assert(std::is_same::value); + } + + namespace test_typename_in_template_template_parameter + { + + template typename X> struct D; + + } + + namespace test_fallthrough_nodiscard_maybe_unused_attributes + { + + int f1() + { + return 42; + } + + [[nodiscard]] int f2() + { + [[maybe_unused]] auto unused = f1(); + + switch (f1()) + { + case 17: + f1(); + [[fallthrough]]; + case 42: + f1(); + } + return f1(); + } + + } + + namespace test_extended_aggregate_initialization + { + + struct base1 + { + int b1, b2 = 42; + }; + + struct base2 + { + base2() { + b3 = 42; + } + int b3; + }; + + struct derived : base1, base2 + { + int d; + }; + + derived d1 {{1, 2}, {}, 4}; // full initialization + derived d2 {{}, {}, 4}; // value-initialized bases + + } + + namespace test_general_range_based_for_loop + { + + struct iter + { + int i; + + int& operator* () + { + return i; + } + + const int& operator* () const + { + return i; + } + + iter& operator++() + { + ++i; + return *this; + } + }; + + struct sentinel + { + int i; + }; + + bool operator== (const iter& i, const sentinel& s) + { + return i.i == s.i; + } + + bool operator!= (const iter& i, const sentinel& s) + { + return !(i == s); + } + + struct range + { + iter begin() const + { + return {0}; + } + + sentinel end() const + { + return {5}; + } + }; + + void f() + { + range r {}; + + for (auto i : r) + { + [[maybe_unused]] auto v = i; + } + } + + } + + namespace test_lambda_capture_asterisk_this_by_value + { + + struct t + { + int i; + int foo() + { + return [*this]() + { + return i; + }(); + } + }; + + } + + namespace test_enum_class_construction + { + + enum class byte : unsigned char + {}; + + byte foo {42}; + + } + + namespace test_constexpr_if + { + + template + int f () + { + if constexpr(cond) + { + return 13; + } + else + { + return 42; + } + } + + } + + namespace test_selection_statement_with_initializer + { + + int f() + { + return 13; + } + + int f2() + { + if (auto i = f(); i > 0) + { + return 3; + } + + switch (auto i = f(); i + 4) + { + case 17: + return 2; + + default: + return 1; + } + } + + } + + namespace test_template_argument_deduction_for_class_templates + { + + template + struct pair + { + pair (T1 p1, T2 p2) + : m1 {p1}, + m2 {p2} + {} + + T1 m1; + T2 m2; + }; + + void f() + { + [[maybe_unused]] auto p = pair{13, 42u}; + } + + } + + namespace test_non_type_auto_template_parameters + { + + template + struct B + {}; + + B<5> b1; + B<'a'> b2; + + } + + namespace test_structured_bindings + { + + int arr[2] = { 1, 2 }; + std::pair pr = { 1, 2 }; + + auto f1() -> int(&)[2] + { + return arr; + } + + auto f2() -> std::pair& + { + return pr; + } + + struct S + { + int x1 : 2; + volatile double y1; + }; + + S f3() + { + return {}; + } + + auto [ x1, y1 ] = f1(); + auto& [ xr1, yr1 ] = f1(); + auto [ x2, y2 ] = f2(); + auto& [ xr2, yr2 ] = f2(); + const auto [ x3, y3 ] = f3(); + + } + + namespace test_exception_spec_type_system + { + + struct Good {}; + struct Bad {}; + + void g1() noexcept; + void g2(); + + template + Bad + f(T*, T*); + + template + Good + f(T1*, T2*); + + static_assert (std::is_same_v); + + } + + namespace test_inline_variables + { + + template void f(T) + {} + + template inline T g(T) + { + return T{}; + } + + template<> inline void f<>(int) + {} + + template<> int g<>(int) + { + return 5; + } + + } + +} // namespace cxx17 + +#endif // __cplusplus < 201703L + +]]) diff --git a/src/base/result.h b/src/base/result.h index 42225b7e0c..6162d01b4e 100644 --- a/src/base/result.h +++ b/src/base/result.h @@ -11,6 +11,7 @@ #pragma once #include +#include #include #include diff --git a/src/files_sub_source.cc b/src/files_sub_source.cc index 5ed40871b4..585c83f94e 100644 --- a/src/files_sub_source.cc +++ b/src/files_sub_source.cc @@ -202,19 +202,24 @@ void files_sub_source::text_value_for_line(textview_curses &tc, int line, const auto &lf = fc.fc_files[line]; auto fn = lf->get_unique_path(); char start_time[64] = "", end_time[64] = ""; + std::vector file_notes; if (lf->get_format() != nullptr) { sql_strftime(start_time, sizeof(start_time), lf->front().get_timeval()); sql_strftime(end_time, sizeof(end_time), lf->back().get_timeval()); } truncate_to(fn, filename_width); + for (const auto& pair : lf->get_notes()) { + file_notes.push_back(pair.second); + } value_out = fmt::format( - FMT_STRING(" {:<{}} {:>8} {} \u2014 {}"), + FMT_STRING(" {:<{}} {:>8} {} \u2014 {} {}"), fn, filename_width, humanize::file_size(lf->get_index_size()), start_time, - end_time); + end_time, + fmt::join(file_notes, "; ")); } void files_sub_source::text_attrs_for_line(textview_curses &tc, int line, diff --git a/src/lnav.cc b/src/lnav.cc index 39bdf0679f..c4358f0874 100644 --- a/src/lnav.cc +++ b/src/lnav.cc @@ -690,13 +690,14 @@ void rebuild_indexes(nonstd::optional deadline) left->get_stat().st_size; }); + auto dupe_name = pair.second.front()->get_unique_path(); pair.second.pop_front(); for_each(pair.second.begin(), pair.second.end(), - [](auto& lf) { + [&dupe_name](auto& lf) { log_info("Hiding duplicate file: %s", lf->get_filename().c_str()); - lf->mark_as_duplicate(); + lf->mark_as_duplicate(dupe_name); lnav_data.ld_log_source.find_data(lf) | [](auto ld) { ld->set_visibility(false); }; diff --git a/src/logfile.cc b/src/logfile.cc index 8b8d68c836..39983df082 100644 --- a/src/logfile.cc +++ b/src/logfile.cc @@ -740,3 +740,12 @@ logfile::find_from_time(const timeval &tv) const return retval; } + +void logfile::mark_as_duplicate(const string &name) +{ + this->lf_indexing = false; + this->lf_options.loo_is_visible = false; + this->lf_notes.writeAccess()->emplace( + note_type::duplicate, + fmt::format("hiding duplicate of {}", name)); +} diff --git a/src/logfile.hh b/src/logfile.hh index a19da16c97..e611d9054d 100644 --- a/src/logfile.hh +++ b/src/logfile.hh @@ -52,6 +52,7 @@ #include "ghc/filesystem.hpp" #include "logfile_fwd.hh" #include "log_format_fwd.hh" +#include "safe/safe.h" /** * Observer interface for logfile indexing progress. @@ -209,10 +210,7 @@ public: this->adjust_content_time(-1, tv); }; - void mark_as_duplicate() { - this->lf_indexing = false; - this->lf_options.loo_is_visible = false; - } + void mark_as_duplicate(const std::string& name); const logfile_open_options& get_open_options() const { return this->lf_options; @@ -368,6 +366,18 @@ public: ghc::filesystem::path get_path() const override; + enum class note_type { + indexing_disabled, + duplicate, + }; + + using note_map = std::map; + using safe_notes = safe::Safe; + + note_map get_notes() const { + return *this->lf_notes.readAccess(); + } + protected: /** * Process a line from the file. @@ -408,6 +418,7 @@ private: size_t lf_longest_line{0}; text_format_t lf_text_format{text_format_t::TF_UNKNOWN}; uint32_t lf_out_of_time_order_count{0}; + safe_notes lf_notes; nonstd::optional> lf_next_line_cache; }; diff --git a/src/optional.hpp b/src/optional.hpp index 33a1241e72..aa54e93687 100644 --- a/src/optional.hpp +++ b/src/optional.hpp @@ -12,7 +12,7 @@ #define NONSTD_OPTIONAL_LITE_HPP #define optional_lite_MAJOR 3 -#define optional_lite_MINOR 2 +#define optional_lite_MINOR 4 #define optional_lite_PATCH 0 #define optional_lite_VERSION optional_STRINGIFY(optional_lite_MAJOR) "." optional_STRINGIFY(optional_lite_MINOR) "." optional_STRINGIFY(optional_lite_PATCH) @@ -26,6 +26,20 @@ #define optional_OPTIONAL_NONSTD 1 #define optional_OPTIONAL_STD 2 +// tweak header support: + +#ifdef __has_include +# if __has_include() +# include +# endif +#define optional_HAVE_TWEAK_HEADER 1 +#else +#define optional_HAVE_TWEAK_HEADER 0 +//# pragma message("optional.hpp: Note: Tweak header not supported.") +#endif + +// optional selection and configuration: + #if !defined( optional_CONFIG_SELECT_OPTIONAL ) # define optional_CONFIG_SELECT_OPTIONAL ( optional_HAVE_STD_OPTIONAL ? optional_OPTIONAL_STD : optional_OPTIONAL_NONSTD ) #endif @@ -33,7 +47,10 @@ // Control presence of exception handling (try and auto discover): #ifndef optional_CONFIG_NO_EXCEPTIONS -# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND) +# if _MSC_VER +# include // for _HAS_EXCEPTIONS +# endif +# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (_HAS_EXCEPTIONS) # define optional_CONFIG_NO_EXCEPTIONS 0 # else # define optional_CONFIG_NO_EXCEPTIONS 1 @@ -296,11 +313,11 @@ namespace nonstd { #define optional_CPP14_000 (optional_CPP14_OR_GREATER) #define optional_CPP17_000 (optional_CPP17_OR_GREATER) -// gcc >= 4.9, msvc >= vc14.1 (vs17): -#define optional_CPP11_140_G490 ((optional_CPP11_OR_GREATER_ && optional_COMPILER_GNUC_VERSION >= 490) || (optional_COMPILER_MSVC_VER >= 1910)) +// clang >= 2.9, gcc >= 4.9, msvc >= vc14.0/1900 (vs15): +#define optional_CPP11_140_C290_G490 ((optional_CPP11_OR_GREATER_ && (optional_COMPILER_CLANG_VERSION >= 290 || optional_COMPILER_GNUC_VERSION >= 490)) || (optional_COMPILER_MSVC_VER >= 1900)) // clang >= 3.5, msvc >= vc11 (vs12): -#define optional_CPP11_110_C350 ( optional_CPP11_110 && !optional_BETWEEN( optional_COMPILER_CLANG_VERSION, 1, 350 ) ) +#define optional_CPP11_110_C350 ( optional_CPP11_110 && !optional_BETWEEN( optional_COMPILER_CLANG_VERSION, 1, 350 ) ) // clang >= 3.5, gcc >= 5.0, msvc >= vc11 (vs12): #define optional_CPP11_110_C350_G500 \ @@ -314,7 +331,7 @@ namespace nonstd { #define optional_HAVE_IS_DEFAULT optional_CPP11_140 #define optional_HAVE_NOEXCEPT optional_CPP11_140 #define optional_HAVE_NULLPTR optional_CPP11_100 -#define optional_HAVE_REF_QUALIFIER optional_CPP11_140_G490 +#define optional_HAVE_REF_QUALIFIER optional_CPP11_140_C290_G490 #define optional_HAVE_INITIALIZER_LIST optional_CPP11_140 // Presence of C++14 language features: @@ -761,6 +778,12 @@ union storage_t ::new( value_ptr() ) value_type( std::move( v ) ); } + template< class... Args > + storage_t( nonstd_lite_in_place_t(T), Args&&... args ) + { + emplace( std::forward(args)... ); + } + template< class... Args > void emplace( Args&&... args ) { @@ -1092,7 +1115,7 @@ class optional > optional_constexpr explicit optional( U && value ) : has_value_( true ) - , contained( T{ std::forward( value ) } ) + , contained( nonstd_lite_in_place(T), std::forward( value ) ) {} // 8b (C++11) - non-explicit move construct from value @@ -1107,7 +1130,7 @@ class optional // NOLINTNEXTLINE( google-explicit-constructor, hicpp-explicit-conversions ) optional_constexpr /*non-explicit*/ optional( U && value ) : has_value_( true ) - , contained( std::forward( value ) ) + , contained( nonstd_lite_in_place(T), std::forward( value ) ) {} #else // optional_CPP11_OR_GREATER @@ -1420,7 +1443,7 @@ class optional #endif -#if optional_CPP11_OR_GREATER +#if optional_HAVE( REF_QUALIFIER ) template< typename U > optional_constexpr value_type value_or( U && v ) const optional_ref_qual @@ -1431,7 +1454,11 @@ class optional template< typename U > optional_constexpr14 value_type value_or( U && v ) optional_refref_qual { +#if optional_COMPILER_CLANG_VERSION + return has_value() ? /*std::move*/( contained.value() ) : static_cast(std::forward( v ) ); +#else return has_value() ? std::move( contained.value() ) : static_cast(std::forward( v ) ); +#endif } #else diff --git a/src/pcrepp/pcrepp.hh b/src/pcrepp/pcrepp.hh index ebfd4d8e8f..bb9d84f3e8 100644 --- a/src/pcrepp/pcrepp.hh +++ b/src/pcrepp/pcrepp.hh @@ -49,6 +49,7 @@ #include +#include #include #include #include