summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-02-20 08:24:07 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-02-20 08:24:07 +0000
commitb23371579291488bb1d17d8431ae0db127be003c (patch)
treea034535e02e35a84ef6ed8acc39035d224f22d2f
parent841eb5078c04936dcdcfd049445283b44598eecf (diff)
parentf156c93331c21edc571a1390a3fcd0ffe03ba5d5 (diff)
downloadlibchrome-b23371579291488bb1d17d8431ae0db127be003c.tar.gz
Snap for 4612226 from f156c93331c21edc571a1390a3fcd0ffe03ba5d5 to pi-release
Change-Id: If9c36f1086464636d327e97d2506e002a35c57d5
-rw-r--r--Android.bp22
-rw-r--r--base/allocator/allocator_shim.cc1
-rw-r--r--base/allocator/allocator_shim_default_dispatch_to_glibc.cc8
-rw-r--r--base/allocator/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc8
-rw-r--r--base/command_line.cc1
-rw-r--r--base/compiler_specific.h3
-rw-r--r--base/debug/stack_trace.cc4
-rw-r--r--base/debug/stack_trace_posix.cc3
-rw-r--r--base/memory/shared_memory_tracker.cc1
-rw-r--r--base/metrics/histogram.cc2
-rw-r--r--base/process/memory_stubs.cc5
-rw-r--r--base/threading/sequenced_worker_pool.cc5
-rw-r--r--base/threading/thread_restrictions.h4
-rw-r--r--base/trace_event/trace_event_filter.cc6
-rw-r--r--base/trace_event/trace_log.cc2
-rw-r--r--base/tracked_objects.cc1
-rwxr-xr-xlibchrome_tools/include_generator.py93
17 files changed, 116 insertions, 53 deletions
diff --git a/Android.bp b/Android.bp
index bf4809e30e..eaa5cc5849 100644
--- a/Android.bp
+++ b/Android.bp
@@ -15,6 +15,18 @@
// Common defaults
// ========================================================
+// Using Chrome header files directly could cause -Wunused-parameter errors,
+// and this is workaround. Please find the document in include_generator.py
+// for details.
+gensrcs {
+ name: "libchrome-include",
+ cmd: "$(location libchrome_tools/include_generator.py) $(in) $(out)",
+ tool_files: ["libchrome_tools/include_generator.py"],
+ export_include_dirs: ["."],
+ srcs: ["**/*.h"],
+ output_extension: "h",
+}
+
cc_defaults {
name: "libchrome-defaults",
// Set clang to "true" to force clang or "false" to force gcc.
@@ -24,12 +36,18 @@ cc_defaults {
"-Wall",
"-Werror",
"-Wno-deprecated-declarations",
+ "-Wno-unused-parameter",
],
include_dirs: [
"external/valgrind/include",
"external/valgrind",
],
- export_include_dirs: ["."],
+
+ // Note: Although the generated header files are exported here, in building
+ // libchrome, "." has priority (unlike building projects using libchrome),
+ // so the raw header files are used for them.
+ generated_headers: ["libchrome-include"],
+ export_generated_headers: ["libchrome-include"],
target: {
host: {
cflags: [
@@ -47,7 +65,6 @@ cc_defaults {
name: "libchrome-test-defaults",
defaults: ["libchrome-defaults"],
cflags: [
- "-Wno-unused-parameter",
"-Wno-unused-function",
"-Wno-unused-variable",
"-Wno-missing-field-initializers",
@@ -335,7 +352,6 @@ cc_library_shared {
"crypto/sha2.cc",
],
- cflags: ["-Wno-unused-parameter"],
shared_libs: [
"libchrome",
"libcrypto",
diff --git a/base/allocator/allocator_shim.cc b/base/allocator/allocator_shim.cc
index 4887142d25..f511b53088 100644
--- a/base/allocator/allocator_shim.cc
+++ b/base/allocator/allocator_shim.cc
@@ -58,7 +58,6 @@ bool CallNewHandler(size_t size) {
#if defined(OS_WIN)
return base::allocator::WinCallNewHandler(size);
#else
- ALLOW_UNUSED_PARAM(size);
// TODO(primiano): C++11 has introduced ::get_new_handler() which is supposed
// to be thread safe and would avoid the spinlock boilerplate here. However
// it doesn't seem to be available yet in the Linux chroot headers yet.
diff --git a/base/allocator/allocator_shim_default_dispatch_to_glibc.cc b/base/allocator/allocator_shim_default_dispatch_to_glibc.cc
index 6f386d4cc0..8574da3eb3 100644
--- a/base/allocator/allocator_shim_default_dispatch_to_glibc.cc
+++ b/base/allocator/allocator_shim_default_dispatch_to_glibc.cc
@@ -6,8 +6,6 @@
#include <malloc.h>
-#include "base/compiler_specific.h"
-
// This translation unit defines a default dispatch for the allocator shim which
// routes allocations to libc functions.
// The code here is strongly inspired from tcmalloc's libc_override_glibc.h.
@@ -25,7 +23,6 @@ namespace {
using base::allocator::AllocatorDispatch;
void* GlibcMalloc(const AllocatorDispatch*, size_t size, void* context) {
- ALLOW_UNUSED_PARAM(context);
return __libc_malloc(size);
}
@@ -33,7 +30,6 @@ void* GlibcCalloc(const AllocatorDispatch*,
size_t n,
size_t size,
void* context) {
- ALLOW_UNUSED_PARAM(context);
return __libc_calloc(n, size);
}
@@ -41,7 +37,6 @@ void* GlibcRealloc(const AllocatorDispatch*,
void* address,
size_t size,
void* context) {
- ALLOW_UNUSED_PARAM(context);
return __libc_realloc(address, size);
}
@@ -49,12 +44,10 @@ void* GlibcMemalign(const AllocatorDispatch*,
size_t alignment,
size_t size,
void* context) {
- ALLOW_UNUSED_PARAM(context);
return __libc_memalign(alignment, size);
}
void GlibcFree(const AllocatorDispatch*, void* address, void* context) {
- ALLOW_UNUSED_PARAM(context);
__libc_free(address);
}
@@ -63,7 +56,6 @@ size_t GlibcGetSizeEstimate(const AllocatorDispatch*,
void* context) {
// TODO(siggi, primiano): malloc_usable_size may need redirection in the
// presence of interposing shims that divert allocations.
- ALLOW_UNUSED_PARAM(context);
return malloc_usable_size(address);
}
diff --git a/base/allocator/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc b/base/allocator/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc
index 3ad13ef98f..e33754a443 100644
--- a/base/allocator/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc
+++ b/base/allocator/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc
@@ -5,7 +5,6 @@
#include <malloc.h>
#include "base/allocator/allocator_shim.h"
-#include "base/compiler_specific.h"
#include "build/build_config.h"
#if defined(OS_ANDROID) && __ANDROID_API__ < 17
@@ -34,7 +33,6 @@ namespace {
using base::allocator::AllocatorDispatch;
void* RealMalloc(const AllocatorDispatch*, size_t size, void* context) {
- ALLOW_UNUSED_PARAM(context);
return __real_malloc(size);
}
@@ -42,7 +40,6 @@ void* RealCalloc(const AllocatorDispatch*,
size_t n,
size_t size,
void* context) {
- ALLOW_UNUSED_PARAM(context);
return __real_calloc(n, size);
}
@@ -50,7 +47,6 @@ void* RealRealloc(const AllocatorDispatch*,
void* address,
size_t size,
void* context) {
- ALLOW_UNUSED_PARAM(context);
return __real_realloc(address, size);
}
@@ -58,12 +54,10 @@ void* RealMemalign(const AllocatorDispatch*,
size_t alignment,
size_t size,
void* context) {
- ALLOW_UNUSED_PARAM(context);
return __real_memalign(alignment, size);
}
void RealFree(const AllocatorDispatch*, void* address, void* context) {
- ALLOW_UNUSED_PARAM(context);
__real_free(address);
}
@@ -74,8 +68,6 @@ size_t DummyMallocUsableSize(const void*) { return 0; }
size_t RealSizeEstimate(const AllocatorDispatch*,
void* address,
void* context) {
- ALLOW_UNUSED_PARAM(address);
- ALLOW_UNUSED_PARAM(context);
#if defined(OS_ANDROID)
#if __ANDROID_API__ < 17
// malloc_usable_size() is available only starting from API 17.
diff --git a/base/command_line.cc b/base/command_line.cc
index 3033fcfc6e..b939201e5c 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -455,7 +455,6 @@ CommandLine::StringType CommandLine::GetCommandLineStringInternal(
CommandLine::StringType CommandLine::GetArgumentsStringInternal(
bool quote_placeholders) const {
- ALLOW_UNUSED_PARAM(quote_placeholders);
StringType params;
// Append switches and arguments.
bool parse_switches = true;
diff --git a/base/compiler_specific.h b/base/compiler_specific.h
index 358a5c9ca3..327e3fabc0 100644
--- a/base/compiler_specific.h
+++ b/base/compiler_specific.h
@@ -85,9 +85,6 @@
// ALLOW_UNUSED_LOCAL(x);
#define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0
-// Used for Arc++ where -Wno-unused-parameter is used.
-#define ALLOW_UNUSED_PARAM(x) false ? (void)x : (void)0
-
// Annotate a typedef or function indicating it's ok if it's not used.
// Use like:
// typedef Foo Bar ALLOW_UNUSED_TYPE;
diff --git a/base/debug/stack_trace.cc b/base/debug/stack_trace.cc
index 08dcacfa30..43a23d95ac 100644
--- a/base/debug/stack_trace.cc
+++ b/base/debug/stack_trace.cc
@@ -126,10 +126,8 @@ uintptr_t ScanStackForNextFrame(uintptr_t fp, uintptr_t stack_end) {
}
}
}
-#else
- ALLOW_UNUSED_PARAM(fp);
- ALLOW_UNUSED_PARAM(stack_end);
#endif // defined(OS_LINUX)
+
return 0;
}
diff --git a/base/debug/stack_trace_posix.cc b/base/debug/stack_trace_posix.cc
index 78bc650c79..c134f494eb 100644
--- a/base/debug/stack_trace_posix.cc
+++ b/base/debug/stack_trace_posix.cc
@@ -79,7 +79,6 @@ const char kSymbolCharacters[] =
void DemangleSymbols(std::string* text) {
// Note: code in this function is NOT async-signal safe (std::string uses
// malloc internally).
- ALLOW_UNUSED_PARAM(text);
#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
std::string::size_type search_from = 0;
@@ -214,7 +213,6 @@ void PrintToStderr(const char* output) {
}
void StackDumpSignalHandler(int signal, siginfo_t* info, void* void_context) {
- ALLOW_UNUSED_PARAM(void_context); // unused depending on build context
// NOTE: This code MUST be async-signal safe.
// NO malloc or stdio is allowed here.
@@ -730,7 +728,6 @@ StackTrace::StackTrace(size_t count) {
// return values, we take no chance.
count_ = base::saturated_cast<size_t>(backtrace(trace_, count));
#else
- ALLOW_UNUSED_PARAM(count);
count_ = 0;
#endif
}
diff --git a/base/memory/shared_memory_tracker.cc b/base/memory/shared_memory_tracker.cc
index cfd4c85c53..8613f59533 100644
--- a/base/memory/shared_memory_tracker.cc
+++ b/base/memory/shared_memory_tracker.cc
@@ -48,7 +48,6 @@ void SharedMemoryTracker::DecrementMemoryUsage(
bool SharedMemoryTracker::OnMemoryDump(const trace_event::MemoryDumpArgs& args,
trace_event::ProcessMemoryDump* pmd) {
- ALLOW_UNUSED_PARAM(args);
std::unordered_map<SharedMemory::UniqueId, size_t, SharedMemory::UniqueIdHash>
sizes;
{
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc
index de2ac336d3..d455c87b0f 100644
--- a/base/metrics/histogram.cc
+++ b/base/metrics/histogram.cc
@@ -534,7 +534,6 @@ Histogram::~Histogram() {
}
bool Histogram::PrintEmptyBucket(uint32_t index) const {
- ALLOW_UNUSED_PARAM(index);
return true;
}
@@ -1139,7 +1138,6 @@ bool CustomHistogram::SerializeInfoImpl(Pickle* pickle) const {
}
double CustomHistogram::GetBucketSize(Count current, uint32_t i) const {
- ALLOW_UNUSED_PARAM(i);
// If this is a histogram of enum values, normalizing the bucket count
// by the bucket range is not helpful, so just return the bucket count.
return current;
diff --git a/base/process/memory_stubs.cc b/base/process/memory_stubs.cc
index 67deb4f58b..787d9aef21 100644
--- a/base/process/memory_stubs.cc
+++ b/base/process/memory_stubs.cc
@@ -7,8 +7,6 @@
#include <stddef.h>
#include <stdlib.h>
-#include "base/compiler_specific.h"
-
namespace base {
void EnableTerminationOnOutOfMemory() {
@@ -18,13 +16,10 @@ void EnableTerminationOnHeapCorruption() {
}
bool AdjustOOMScore(ProcessId process, int score) {
- ALLOW_UNUSED_PARAM(process);
- ALLOW_UNUSED_PARAM(score);
return false;
}
void TerminateBecauseOutOfMemory(size_t size) {
- ALLOW_UNUSED_PARAM(size);
abort();
}
diff --git a/base/threading/sequenced_worker_pool.cc b/base/threading/sequenced_worker_pool.cc
index 866a8b3b3b..ecf6e2c8e0 100644
--- a/base/threading/sequenced_worker_pool.cc
+++ b/base/threading/sequenced_worker_pool.cc
@@ -807,8 +807,6 @@ bool SequencedWorkerPool::Inner::PostTaskToTaskScheduler(
const TimeDelta& delay) {
#if 1
NOTREACHED();
- ALLOW_UNUSED_PARAM(sequenced);
- ALLOW_UNUSED_PARAM(delay);
return false;
#else
DCHECK_EQ(AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER, g_all_pools_state);
@@ -849,8 +847,6 @@ SequencedWorkerPool::Inner::GetTaskSchedulerTaskRunner(
const TaskTraits& traits) {
#if 1
NOTREACHED();
- ALLOW_UNUSED_PARAM(sequence_token_id);
- ALLOW_UNUSED_PARAM(traits);
return scoped_refptr<TaskRunner>();
#else
DCHECK_EQ(AllPoolsState::REDIRECTED_TO_TASK_SCHEDULER, g_all_pools_state);
@@ -1479,7 +1475,6 @@ void SequencedWorkerPool::EnableWithRedirectionToTaskSchedulerForProcess(
TaskPriority max_task_priority) {
#if 1
NOTREACHED();
- ALLOW_UNUSED_PARAM(max_task_priority);
#else
// TODO(fdoray): Uncomment this line. It is initially commented to avoid a
// revert of the CL that adds debug::DumpWithoutCrashing() in case of
diff --git a/base/threading/thread_restrictions.h b/base/threading/thread_restrictions.h
index a86dd452b8..ad8b4ba629 100644
--- a/base/threading/thread_restrictions.h
+++ b/base/threading/thread_restrictions.h
@@ -163,9 +163,9 @@ class BASE_EXPORT ThreadRestrictions {
#else
// Inline the empty definitions of these functions so that they can be
// compiled out.
- static bool SetIOAllowed(bool) { return true; }
+ static bool SetIOAllowed(bool allowed) { return true; }
static void AssertIOAllowed() {}
- static bool SetSingletonAllowed(bool) { return true; }
+ static bool SetSingletonAllowed(bool allowed) { return true; }
static void AssertSingletonAllowed() {}
static void DisallowWaiting() {}
static void AssertWaitAllowed() {}
diff --git a/base/trace_event/trace_event_filter.cc b/base/trace_event/trace_event_filter.cc
index d50c5fe251..6265295864 100644
--- a/base/trace_event/trace_event_filter.cc
+++ b/base/trace_event/trace_event_filter.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/compiler_specific.h"
#include "base/trace_event/trace_event_filter.h"
namespace base {
@@ -12,10 +11,7 @@ TraceEventFilter::TraceEventFilter() {}
TraceEventFilter::~TraceEventFilter() {}
void TraceEventFilter::EndEvent(const char* category_name,
- const char* event_name) const {
- ALLOW_UNUSED_PARAM(category_name);
- ALLOW_UNUSED_PARAM(event_name);
-}
+ const char* event_name) const {}
} // namespace trace_event
} // namespace base
diff --git a/base/trace_event/trace_log.cc b/base/trace_event/trace_log.cc
index d798a9539b..dbdd4db06a 100644
--- a/base/trace_event/trace_log.cc
+++ b/base/trace_event/trace_log.cc
@@ -398,7 +398,6 @@ void TraceLog::InitializeThreadLocalEventBufferIfSupported() {
bool TraceLog::OnMemoryDump(const MemoryDumpArgs& args,
ProcessMemoryDump* pmd) {
- ALLOW_UNUSED_PARAM(args);
// TODO(ssid): Use MemoryDumpArgs to create light dumps when requested
// (crbug.com/499731).
TraceEventMemoryOverhead overhead;
@@ -1406,7 +1405,6 @@ std::string TraceLog::EventToConsoleMessage(unsigned char phase,
void TraceLog::EndFilteredEvent(const unsigned char* category_group_enabled,
const char* name,
TraceEventHandle handle) {
- ALLOW_UNUSED_PARAM(handle);
const char* category_name = GetCategoryGroupName(category_group_enabled);
ForEachCategoryFilter(
category_group_enabled,
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc
index 131af14a3a..1507c0986c 100644
--- a/base/tracked_objects.cc
+++ b/base/tracked_objects.cc
@@ -824,7 +824,6 @@ TrackedTime ThreadData::Now() {
// static
void ThreadData::EnsureCleanupWasCalled(int major_threads_shutdown_count) {
- ALLOW_UNUSED_PARAM(major_threads_shutdown_count);
base::AutoLock lock(*list_lock_.Pointer());
// TODO(jar): until this is working on XP, don't run the real test.
diff --git a/libchrome_tools/include_generator.py b/libchrome_tools/include_generator.py
new file mode 100755
index 0000000000..efffd3952c
--- /dev/null
+++ b/libchrome_tools/include_generator.py
@@ -0,0 +1,93 @@
+#!/usr/bin/python
+
+# Copyright (C) 2018 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Generates wrapped include files to workaround -Wunused-parameter errors.
+
+In Chrome repository, "-Wunused-parameter" is disabled, and several header
+files in Chrome repository have actually unused-parameter.
+One of the typical scenarios is; in Chrome, Observer class is often defined
+as follows:
+
+class Foo {
+ public:
+ class Observer {
+ public:
+ virtual void OnSomeEvent(EventArg arg) {}
+ virtual void OnAnotherEvent(EventArg arg) {}
+ ...
+ };
+ ...
+};
+
+Here, On...Event() methods do nothing by default, and subclasses will override
+only necessary ones.
+In this use case, argument names can also work as documentation, and overrides
+can use these good interface-defined default names as a starting point for
+their implementation.
+
+On the other hand, in Android, -Wunused-parameter is enabled by default.
+Thus, if such a project includes header files from libchrome, it could cause
+a compile error (by the warning and "-Werror").
+
+To avoid such a situation, libchrome exports include files wrapped by the
+pragmas as follows.
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+${actual_include_file_content}
+#pragma GCC diagnostic pop
+
+so, the unused-parameter warning generated by the libchrome include headers
+will be ignored.
+Note that these GCC pragmas are also supported by clang for compatibility. cf)
+https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-via-pragmas
+
+Usage: include_generator.py $(in) $(out)
+"""
+
+import sys
+
+
+def _generate(input_path, output_path):
+ """Generates a include file wrapped by pragmas.
+
+ Reads the file at |input_path| and output the content with wrapping by
+ #pragma to ignore unused-parameter warning into the file at |output_path|.
+ If the parent directories of |output_path| do not exist, creates them.
+
+ Args:
+ input_path: Path to the source file. Expected this is a chrome's header
+ file.
+ output_path: Path to the output file.
+ """
+ with open(input_path, 'r') as f:
+ content = f.read()
+
+ with open(output_path, 'w') as f:
+ f.writelines([
+ '// Generated by %s\n' % sys.argv[0],
+ '#pragma GCC diagnostic push\n'
+ '#pragma GCC diagnostic ignored "-Wunused-parameter"\n',
+ content,
+ '#pragma GCC diagnostic pop\n'])
+
+
+def main():
+ _generate(*sys.argv[1:])
+
+
+if __name__ == '__main__':
+ main()