diff --git a/minidump/minidump_context_writer.cc b/minidump/minidump_context_writer.cc index 70aa96b8..fef1af31 100644 --- a/minidump/minidump_context_writer.cc +++ b/minidump/minidump_context_writer.cc @@ -16,6 +16,7 @@ #include +#include "base/compiler_specific.h" #include "base/logging.h" #include "snapshot/cpu_context.h" #include "util/file/file_writer.h" @@ -39,16 +40,10 @@ scoped_ptr MinidumpContextWriter::CreateFromSnapshot( } case kCPUArchitectureX86_64: { -#if defined(COMPILER_MSVC) && defined(ARCH_CPU_X86) -#pragma warning(push) -#pragma warning(disable: 4316) // Object allocated on the heap may not be 16 - // byte aligned. -#endif + MSVC_PUSH_DISABLE_WARNING(4316); // Object on heap may not be aligned. MinidumpContextAMD64Writer* context_amd64 = new MinidumpContextAMD64Writer(); -#if defined(COMPILER_MSVC) && defined(ARCH_CPU_X86) -#pragma warning(pop) -#endif + MSVC_POP_WARNING(); // C4316 context.reset(context_amd64); context_amd64->InitializeFromSnapshot(context_snapshot->x86_64); break; diff --git a/minidump/minidump_extensions.h b/minidump/minidump_extensions.h index 8453f553..20fe2dda 100644 --- a/minidump/minidump_extensions.h +++ b/minidump/minidump_extensions.h @@ -24,15 +24,12 @@ #include "build/build_config.h" #include "util/misc/uuid.h" -#if defined(COMPILER_MSVC) // C4200 is "nonstandard extension used : zero-sized array in struct/union". // We would like to globally disable this warning, but unfortunately, the // compiler is buggy and only supports disabling it with a pragma, so we can't // disable it with other silly warnings in build/common.gypi. See: // https://connect.microsoft.com/VisualStudio/feedback/details/1114440 -#pragma warning(push) -#pragma warning(disable: 4200) -#endif // COMPILER_MSVC +MSVC_PUSH_DISABLE_WARNING(4200); #if defined(COMPILER_MSVC) #define PACKED @@ -470,9 +467,7 @@ struct ALIGNAS(4) PACKED MinidumpCrashpadInfo { #endif // COMPILER_MSVC #undef PACKED -#if defined(COMPILER_MSVC) -#pragma warning(pop) // C4200 -#endif // COMPILER_MSVC +MSVC_POP_WARNING(); // C4200 } // namespace crashpad diff --git a/minidump/minidump_file_writer_test.cc b/minidump/minidump_file_writer_test.cc index fd880f6e..7b08a090 100644 --- a/minidump/minidump_file_writer_test.cc +++ b/minidump/minidump_file_writer_test.cc @@ -20,6 +20,7 @@ #include #include "base/basictypes.h" +#include "base/compiler_specific.h" #include "gtest/gtest.h" #include "minidump/minidump_stream_writer.h" #include "minidump/minidump_writable.h" @@ -287,15 +288,9 @@ TEST(MinidumpFileWriter, InitializeFromSnapshot_Basic) { TEST(MinidumpFileWriter, InitializeFromSnapshot_Exception) { // In a 32-bit environment, this will give a “timestamp out of range” warning, // but the test should complete without failure. -#if defined(OS_WIN) && defined(ARCH_CPU_X86) -#pragma warning(push) -#pragma warning(disable: 4309) // Truncation of constant value. -#endif // OS_WIN && ARCH_CPU_X86 const uint32_t kSnapshotTime = 0xfd469ab8; + MSVC_SUPPRESS_WARNING(4309); // Truncation of constant value. const timeval kSnapshotTimeval = { static_cast(kSnapshotTime), 0 }; -#if defined(OS_WIN) && defined(ARCH_CPU_X86) -#pragma warning(pop) -#endif // OS_WIN && ARCH_CPU_X86 TestProcessSnapshot process_snapshot; process_snapshot.SetSnapshotTime(kSnapshotTimeval); diff --git a/minidump/minidump_thread_writer_test.cc b/minidump/minidump_thread_writer_test.cc index efe7dc6f..f8fd43b4 100644 --- a/minidump/minidump_thread_writer_test.cc +++ b/minidump/minidump_thread_writer_test.cc @@ -18,6 +18,7 @@ #include #include +#include "base/compiler_specific.h" #include "base/strings/stringprintf.h" #include "gtest/gtest.h" #include "minidump/minidump_context_writer.h" @@ -219,7 +220,7 @@ TEST(MinidumpThreadWriter, OneThread_AMD64_Stack) { new TestMinidumpMemoryWriter(kMemoryBase, kMemorySize, kMemoryValue)); thread_writer->SetStack(memory_writer.Pass()); - MSVC_SUPPRESS_WARNING(4316) // Object allocated on heap may not be aligned. + MSVC_SUPPRESS_WARNING(4316); // Object allocated on heap may not be aligned. auto context_amd64_writer = make_scoped_ptr(new MinidumpContextAMD64Writer()); InitializeMinidumpContextAMD64(context_amd64_writer->context(), kSeed); thread_writer->SetContext(context_amd64_writer.Pass());