Commit 2796d500 by Abseil Team Committed by Derek Mauro

Export of internal Abseil changes

--
b770d03c2f1042d399c3f9576e881691cbe962c4 by Abseil Team <absl-team@google.com>:

Avoid applying the workaround for MSVC's static initialization problems when using clang-cl.

PiperOrigin-RevId: 275870089

--
2b8fc02ec49aeb5ad56cef20259cdd7f6ee0c917 by Abseil Team <absl-team@google.com>:

Document return values.

PiperOrigin-RevId: 275839042

--
baa99064f9a28b188661df7fba989fcd558818af by Abseil Team <absl-team@google.com>:

Support "auto" and other uncommon builtin types in absl::debugging_internal::Demangle.

PiperOrigin-RevId: 275556195

--
f9d5c6a3a0d374dbf105d6e2e9e0c8fa949ed187 by Gennadiy Rozental <rogeeff@google.com>:

Internal rework.

PiperOrigin-RevId: 275550005

--
2679a77db5b26349e8c8b2059621af55d2fca139 by Mark Barolak <mbar@google.com>:

Remove a comment reference to the no longer extant ::string implementation.

PiperOrigin-RevId: 275531987

--
7b427a7613c44a98c6f13da43b2bff2837ca6b19 by Derek Mauro <dmauro@google.com>:

Upgrade to Bazel 1.0.0 and CMake 3.15.4

PiperOrigin-RevId: 275500823

--
81f7d20905debf9d1e300bd2e9899f88d27f632a by Derek Mauro <dmauro@google.com>:

Fix -Wimplicit-int-float-conversion warning in latest clang

PiperOrigin-RevId: 275492439
GitOrigin-RevId: b770d03c2f1042d399c3f9576e881691cbe962c4
Change-Id: I9b39dad524489f0d62c912d02e8ac43761c81e55
parent e4c8d0eb
......@@ -93,6 +93,8 @@ static const AbbrevPair kOperatorList[] = {
};
// List of builtin types from Itanium C++ ABI.
//
// Invariant: only one- or two-character type abbreviations here.
static const AbbrevPair kBuiltinTypeList[] = {
{"v", "void", 0},
{"w", "wchar_t", 0},
......@@ -115,6 +117,16 @@ static const AbbrevPair kBuiltinTypeList[] = {
{"e", "long double", 0},
{"g", "__float128", 0},
{"z", "ellipsis", 0},
{"De", "decimal128", 0}, // IEEE 754r decimal floating point (128 bits)
{"Dd", "decimal64", 0}, // IEEE 754r decimal floating point (64 bits)
{"Dc", "decltype(auto)", 0},
{"Da", "auto", 0},
{"Dn", "std::nullptr_t", 0}, // i.e., decltype(nullptr)
{"Df", "decimal32", 0}, // IEEE 754r decimal floating point (32 bits)
{"Di", "char32_t", 0},
{"Ds", "char16_t", 0},
{"Dh", "float16", 0}, // IEEE 754r half-precision float (16 bits)
{nullptr, nullptr, 0},
};
......@@ -1168,12 +1180,6 @@ static bool ParseType(State *state) {
}
state->parse_state = copy;
// nullptr_t, i.e. decltype(nullptr).
if (ParseTwoCharToken(state, "Dn")) {
return true;
}
state->parse_state = copy;
if (ParseOneCharToken(state, 'U') && ParseSourceName(state) &&
ParseType(state)) {
return true;
......@@ -1214,16 +1220,26 @@ static bool ParseCVQualifiers(State *state) {
return num_cv_qualifiers > 0;
}
// <builtin-type> ::= v, etc.
// <builtin-type> ::= v, etc. # single-character builtin types
// ::= u <source-name>
// ::= Dd, etc. # two-character builtin types
//
// Not supported:
// ::= DF <number> _ # _FloatN (N bits)
//
static bool ParseBuiltinType(State *state) {
ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false;
const AbbrevPair *p;
for (p = kBuiltinTypeList; p->abbrev != nullptr; ++p) {
if (RemainingInput(state)[0] == p->abbrev[0]) {
// Guaranteed only 1- or 2-character strings in kBuiltinTypeList.
if (p->abbrev[1] == '\0') {
if (ParseOneCharToken(state, p->abbrev[0])) {
MaybeAppend(state, p->real_name);
return true;
}
} else if (p->abbrev[2] == '\0' && ParseTwoCharToken(state, p->abbrev)) {
MaybeAppend(state, p->real_name);
++state->parse_state.mangled_idx;
return true;
}
}
......
......@@ -36,10 +36,10 @@ namespace absl {
// GetStackFrames()
//
// Records program counter values for up to `max_depth` frames, skipping the
// most recent `skip_count` stack frames, and stores their corresponding values
// and sizes in `results` and `sizes` buffers. (Note that the frame generated
// for the `absl::GetStackFrames()` routine itself is also skipped.)
// routine itself.
// most recent `skip_count` stack frames, stores their corresponding values
// and sizes in `results` and `sizes` buffers, and returns the number of frames
// stored. (Note that the frame generated for the `absl::GetStackFrames()`
// routine itself is also skipped.)
//
// Example:
//
......@@ -54,8 +54,8 @@ namespace absl {
// The current stack frame would consist of three function calls: `bar()`,
// `foo()`, and then `main()`; however, since the `GetStackFrames()` call sets
// `skip_count` to `1`, it will skip the frame for `bar()`, the most recently
// invoked function call. It will therefore return two program counters and will
// produce values that map to the following function calls:
// invoked function call. It will therefore return 2 and fill `result` with
// program counters within the following functions:
//
// result[0] foo()
// result[1] main()
......@@ -82,9 +82,10 @@ extern int GetStackFrames(void** result, int* sizes, int max_depth,
//
// Records program counter values obtained from a signal handler. Records
// program counter values for up to `max_depth` frames, skipping the most recent
// `skip_count` stack frames, and stores their corresponding values and sizes in
// `results` and `sizes` buffers. (Note that the frame generated for the
// `absl::GetStackFramesWithContext()` routine itself is also skipped.)
// `skip_count` stack frames, stores their corresponding values and sizes in
// `results` and `sizes` buffers, and returns the number of frames stored. (Note
// that the frame generated for the `absl::GetStackFramesWithContext()` routine
// itself is also skipped.)
//
// The `uc` parameter, if non-null, should be a pointer to a `ucontext_t` value
// passed to a signal handler registered via the `sa_sigaction` field of a
......@@ -105,8 +106,9 @@ extern int GetStackFramesWithContext(void** result, int* sizes, int max_depth,
// GetStackTrace()
//
// Records program counter values for up to `max_depth` frames, skipping the
// most recent `skip_count` stack frames, and stores their corresponding values
// in `results`. Note that this function is similar to `absl::GetStackFrames()`
// most recent `skip_count` stack frames, stores their corresponding values
// in `results`, and returns the number of frames
// stored. Note that this function is similar to `absl::GetStackFrames()`
// except that it returns the stack trace only, and not stack frame sizes.
//
// Example:
......@@ -131,9 +133,9 @@ extern int GetStackTrace(void** result, int max_depth, int skip_count);
//
// Records program counter values obtained from a signal handler. Records
// program counter values for up to `max_depth` frames, skipping the most recent
// `skip_count` stack frames, and stores their corresponding values in
// `results`. (Note that the frame generated for the
// `absl::GetStackFramesWithContext()` routine itself is also skipped.)
// `skip_count` stack frames, stores their corresponding values in `results`,
// and returns the number of frames stored. (Note that the frame generated for
// the `absl::GetStackFramesWithContext()` routine itself is also skipped.)
//
// The `uc` parameter, if non-null, should be a pointer to a `ucontext_t` value
// passed to a signal handler registered via the `sa_sigaction` field of a
......
......@@ -40,6 +40,7 @@ cc_library(
deps = [
":handle",
":registry",
"//absl/base:core_headers",
"//absl/memory",
"//absl/strings",
"//absl/synchronization",
......@@ -135,9 +136,6 @@ cc_library(
":config",
":marshalling",
"//absl/base:core_headers",
"//absl/base:raw_logging_internal",
"//absl/strings",
"//absl/synchronization",
"//absl/types:optional",
],
)
......
......@@ -39,7 +39,7 @@ class Flag;
// Flag
//
// Forward declaration of the `absl::Flag` type for use in defining the macro.
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
template <typename T>
class Flag;
#else
......
......@@ -43,7 +43,7 @@ ABSL_FLAGS_INTERNAL_FOR_EACH_LOCK_FREE(ABSL_FLAGS_ATOMIC_GET)
// This global nutex protects on-demand construction of flag objects in MSVC
// builds.
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
namespace flags_internal {
......
......@@ -63,7 +63,7 @@ namespace absl {
// ABSL_FLAG(int, count, 0, "Count of items to process");
//
// No public methods of `absl::Flag<T>` are part of the Abseil Flags API.
#if !defined(_MSC_VER)
#if !defined(_MSC_VER) || defined(__clang__)
template <typename T>
using Flag = flags_internal::Flag<T>;
#else
......@@ -119,7 +119,6 @@ class Flag {
absl::string_view Name() const { return GetImpl()->Name(); }
std::string Help() const { return GetImpl()->Help(); }
bool IsModified() const { return GetImpl()->IsModified(); }
void SetModified(bool is_modified) { GetImpl()->SetModified(is_modified); }
bool IsSpecifiedOnCommandLine() const {
return GetImpl()->IsSpecifiedOnCommandLine();
}
......@@ -127,9 +126,6 @@ class Flag {
std::string Filename() const { return GetImpl()->Filename(); }
std::string DefaultValue() const { return GetImpl()->DefaultValue(); }
std::string CurrentValue() const { return GetImpl()->CurrentValue(); }
bool InvokeValidator(const void* value) const {
return GetImpl()->InvokeValidator(value);
}
template <typename T1>
inline bool IsOfType() const {
return GetImpl()->template IsOfType<T1>();
......@@ -272,7 +268,7 @@ void SetFlag(absl::Flag<T>* flag, const V& v) {
#if ABSL_FLAGS_STRIP_NAMES
#define ABSL_FLAG_IMPL_FLAGNAME(txt) ""
#define ABSL_FLAG_IMPL_FILENAME() ""
#if !defined(_MSC_VER)
#if !defined(_MSC_VER) || defined(__clang__)
#define ABSL_FLAG_IMPL_REGISTRAR(T, flag) \
absl::flags_internal::FlagRegistrar<T, false>(&flag)
#else
......@@ -282,7 +278,7 @@ void SetFlag(absl::Flag<T>* flag, const V& v) {
#else
#define ABSL_FLAG_IMPL_FLAGNAME(txt) txt
#define ABSL_FLAG_IMPL_FILENAME() __FILE__
#if !defined(_MSC_VER)
#if !defined(_MSC_VER) || defined(__clang__)
#define ABSL_FLAG_IMPL_REGISTRAR(T, flag) \
absl::flags_internal::FlagRegistrar<T, true>(&flag)
#else
......
......@@ -42,15 +42,14 @@ void TestCallback() {}
template <typename T>
bool TestConstructionFor() {
constexpr flags::Flag<T> f1("f1", &TestHelpMsg, "file",
&absl::flags_internal::FlagMarshallingOps<T>,
&TestMakeDflt<T>);
&flags::FlagMarshallingOps<T>, &TestMakeDflt<T>);
EXPECT_EQ(f1.Name(), "f1");
EXPECT_EQ(f1.Help(), "help");
EXPECT_EQ(f1.Filename(), "file");
ABSL_CONST_INIT static flags::Flag<T> f2(
"f2", &TestHelpMsg, "file", &absl::flags_internal::FlagMarshallingOps<T>,
&TestMakeDflt<T>);
ABSL_CONST_INIT static flags::Flag<T> f2("f2", &TestHelpMsg, "file",
&flags::FlagMarshallingOps<T>,
&TestMakeDflt<T>);
flags::FlagRegistrar<T, false>(&f2).OnUpdate(TestCallback);
EXPECT_EQ(f2.Name(), "f2");
......
......@@ -118,7 +118,7 @@ void FlagRegistry::RegisterFlag(CommandLineFlag* flag) {
(flag->IsRetired() ? old_flag->Filename() : flag->Filename()),
"'."),
true);
} else if (flag->op_ != old_flag->op_) {
} else if (flag->TypeId() != old_flag->TypeId()) {
flags_internal::ReportUsageError(
absl::StrCat("Flag '", flag->Name(),
"' was defined more than once but with "
......@@ -275,38 +275,49 @@ namespace {
class RetiredFlagObj final : public flags_internal::CommandLineFlag {
public:
constexpr RetiredFlagObj(const char* name, FlagOpFn ops,
FlagMarshallingOpFn marshalling_ops)
constexpr RetiredFlagObj(const char* name, FlagOpFn ops)
: flags_internal::CommandLineFlag(
name, flags_internal::HelpText::FromStaticCString(nullptr),
/*filename=*/"RETIRED", ops, marshalling_ops,
/*initial_value_gen=*/nullptr,
/*def=*/nullptr,
/*cur=*/nullptr) {}
/*filename=*/"RETIRED"),
op_(ops) {}
private:
bool IsRetired() const override { return true; }
void Destroy() const override {
// Values are heap allocated for Retired Flags.
if (cur_) Delete(op_, cur_);
if (def_) Delete(op_, def_);
if (locks_) delete locks_;
delete this;
}
flags_internal::FlagOpFn TypeId() const override { return op_; }
bool IsRetired() const override { return true; }
bool IsModified() const override { return false; }
bool IsSpecifiedOnCommandLine() const override { return false; }
std::string DefaultValue() const override { return ""; }
std::string CurrentValue() const override { return ""; }
// Any input is valid
bool ValidateInputValue(absl::string_view) const override { return true; }
std::unique_ptr<flags_internal::FlagStateInterface> SaveState() override {
return nullptr;
}
bool SetFromString(absl::string_view, flags_internal::FlagSettingMode,
flags_internal::ValueSource, std::string*) override {
return false;
}
void CheckDefaultValueParsingRoundtrip() const override {}
void Read(void*) const override {}
// Data members
const FlagOpFn op_;
};
} // namespace
bool Retire(const char* name, FlagOpFn ops,
FlagMarshallingOpFn marshalling_ops) {
auto* flag = new flags_internal::RetiredFlagObj(name, ops, marshalling_ops);
bool Retire(const char* name, FlagOpFn ops) {
auto* flag = new flags_internal::RetiredFlagObj(name, ops);
FlagRegistry::GlobalRegistry()->RegisterFlag(flag);
return true;
}
......
......@@ -76,14 +76,12 @@ bool RegisterCommandLineFlag(CommandLineFlag*);
//
// Retire flag with name "name" and type indicated by ops.
bool Retire(const char* name, FlagOpFn ops,
FlagMarshallingOpFn marshalling_ops);
bool Retire(const char* name, FlagOpFn ops);
// Registered a retired flag with name 'flag_name' and type 'T'.
template <typename T>
inline bool RetiredFlag(const char* flag_name) {
return flags_internal::Retire(flag_name, flags_internal::FlagOps<T>,
flags_internal::FlagMarshallingOps<T>);
return flags_internal::Retire(flag_name, flags_internal::FlagOps<T>);
}
// If the flag is retired, returns true and indicates in |*type_is_bool|
......
......@@ -196,8 +196,8 @@ TEST(IOStreamStateSaver, RoundTripFloats) {
EXPECT_EQ(-d, StreamRoundTrip<double>(-d));
// Avoid undefined behavior (overflow/underflow).
if (d <= std::numeric_limits<int64_t>::max() &&
d >= std::numeric_limits<int64_t>::lowest()) {
if (f <= static_cast<float>(std::numeric_limits<int64_t>::max()) &&
f >= static_cast<float>(std::numeric_limits<int64_t>::lowest())) {
int64_t x = static_cast<int64_t>(f);
EXPECT_EQ(x, StreamRoundTrip<int64_t>(x));
}
......@@ -264,8 +264,8 @@ TEST(IOStreamStateSaver, RoundTripDoubles) {
}
// Avoid undefined behavior (overflow/underflow).
if (d <= std::numeric_limits<int64_t>::max() &&
d >= std::numeric_limits<int64_t>::lowest()) {
if (d <= static_cast<double>(std::numeric_limits<int64_t>::max()) &&
d >= static_cast<double>(std::numeric_limits<int64_t>::lowest())) {
int64_t x = static_cast<int64_t>(d);
EXPECT_EQ(x, StreamRoundTrip<int64_t>(x));
}
......
......@@ -35,8 +35,7 @@ struct ResizeUninitializedTraits {
static void Resize(string_type* s, size_t new_size) { s->resize(new_size); }
};
// __resize_default_init is provided by libc++ >= 8.0 and by Google's internal
// ::string implementation.
// __resize_default_init is provided by libc++ >= 8.0
template <typename string_type>
struct ResizeUninitializedTraits<
string_type, absl::void_t<decltype(std::declval<string_type&>()
......
......@@ -28,6 +28,5 @@ time docker run \
--rm \
-e CFLAGS="-Werror" \
-e CXXFLAGS="-Werror" \
gcr.io/google.com/absl-177019/linux_gcc-latest:20190703 \
gcr.io/google.com/absl-177019/linux_gcc-latest:20191018 \
/bin/bash CMake/install_test_project/test.sh $@
......@@ -36,7 +36,7 @@ if [ -z ${EXCEPTIONS_MODE:-} ]; then
EXCEPTIONS_MODE="-fno-exceptions -fexceptions"
fi
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20190813"
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20191018"
# USE_BAZEL_CACHE=1 only works on Kokoro.
# Without access to the credentials this won't work.
......
......@@ -36,7 +36,7 @@ if [ -z ${EXCEPTIONS_MODE:-} ]; then
EXCEPTIONS_MODE="-fno-exceptions -fexceptions"
fi
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20190813"
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20191018"
# USE_BAZEL_CACHE=1 only works on Kokoro.
# Without access to the credentials this won't work.
......
......@@ -36,7 +36,7 @@ if [ -z ${EXCEPTIONS_MODE:-} ]; then
EXCEPTIONS_MODE="-fno-exceptions -fexceptions"
fi
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20190813"
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20191018"
# USE_BAZEL_CACHE=1 only works on Kokoro.
# Without access to the credentials this won't work.
......
......@@ -36,7 +36,7 @@ if [ -z ${EXCEPTIONS_MODE:-} ]; then
EXCEPTIONS_MODE="-fno-exceptions -fexceptions"
fi
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20190813"
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20191018"
# USE_BAZEL_CACHE=1 only works on Kokoro.
# Without access to the credentials this won't work.
......
......@@ -36,7 +36,7 @@ if [ -z ${EXCEPTIONS_MODE:-} ]; then
EXCEPTIONS_MODE="-fno-exceptions -fexceptions"
fi
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-4.9:20190702"
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-4.9:20191018"
# USE_BAZEL_CACHE=1 only works on Kokoro.
# Without access to the credentials this won't work.
......
......@@ -36,7 +36,7 @@ if [ -z ${EXCEPTIONS_MODE:-} ]; then
EXCEPTIONS_MODE="-fno-exceptions -fexceptions"
fi
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-latest:20190703"
readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-latest:20191018"
# USE_BAZEL_CACHE=1 only works on Kokoro.
# Without access to the credentials this won't work.
......
......@@ -47,7 +47,7 @@ for std in ${ABSL_CMAKE_CXX_STANDARDS}; do
--rm \
-e CFLAGS="-Werror" \
-e CXXFLAGS="-Werror" \
gcr.io/google.com/absl-177019/linux_gcc-latest:20190703 \
gcr.io/google.com/absl-177019/linux_gcc-latest:20191018 \
/bin/bash -c "
cd /buildfs && \
cmake /abseil-cpp \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment