Skip to content

Commit

Permalink
IMPALA-3675: part 1: -Werror for ASAN
Browse files Browse the repository at this point in the history
This fixes some clang warnings and enables -Werror going forward for
ASAN.

It adds -Wno-return-type-c-linkage to suppress a warning that otherwise
would fail the build.

It also enables the mismatched tags check and fixes the various
instances of it (this warning is irritating for YouCompleteMe users).

Change-Id: If83ca41cde49fd6cfde479e45f9cfdd9e3a45bec
Reviewed-on: http://gerrit.cloudera.org:8080/11002
Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
  • Loading branch information
Tim Armstrong authored and cloudera-hudson committed Jul 23, 2018
1 parent aeddbd2 commit a139de2
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 13 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Expand Up @@ -46,7 +46,6 @@ Checks: "-*,clang*,\
-clang-diagnostic-gnu-anonymous-struct,\
-clang-diagnostic-header-hygiene,\
-clang-diagnostic-implicit-fallthrough,\
-clang-diagnostic-mismatched-tags,\
-clang-diagnostic-missing-prototypes,\
-clang-diagnostic-missing-variable-declarations,\
-clang-diagnostic-nested-anon-types,\
Expand Down
12 changes: 5 additions & 7 deletions be/CMakeLists.txt
Expand Up @@ -63,8 +63,6 @@ SET(CXX_COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage")
# makes extra calls to clang which may have extra includes (-I) that are unused.
# -fcolor-diagnostics: ensure clang generates colorized output, which is necessary
# when using ccache as clang thinks it is not called from a terminal.
# -Wno-mismatched-tags: ignore harmless class/struct mismatch for forward declarations.
# Disabling to be consistent with gcc, which doesn't have this warning.
# -Wno-zero-as-null-pointer-constant: We are slowly moving towards the use of nullptr,
# but till we switch to it completely, we will ignore the warnings due to use of
# NULL as a null pointer constant.
Expand All @@ -75,10 +73,10 @@ SET(CXX_COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage")
# destructors with 'override' which is enforced by clang by not recommended by c++
# core guidelines (read C.128).
SET(CXX_CLANG_FLAGS "-Qunused-arguments -fcolor-diagnostics -Wno-unused-local-typedef")
SET(CXX_CLANG_FLAGS "${CXX_CLANG_FLAGS} -Wno-mismatched-tags")
SET(CXX_CLANG_FLAGS "${CXX_CLANG_FLAGS} -Wno-zero-as-null-pointer-constant")
SET(CXX_CLANG_FLAGS "${CXX_CLANG_FLAGS} -Wno-c++17-extensions")
SET(CXX_CLANG_FLAGS "${CXX_CLANG_FLAGS} -Wno-inconsistent-missing-destructor-override")
SET(CXX_CLANG_FLAGS "${CXX_CLANG_FLAGS} -Wno-return-type-c-linkage")
# For any gcc builds:
# -g: Enable symbols for profiler tools
# -Wno-unused-local-typedefs: Do not warn for local typedefs that are unused.
Expand All @@ -104,15 +102,15 @@ endif()
# Debug information is stored as dwarf2 to be as compatible as possible
SET(CXX_FLAGS_DEBUG "${CXX_GCC_FLAGS} -ggdb -gdwarf-2")
# -Werror: compile warnings should be errors when using the toolchain compiler.
# Only enable for debug builds because this is what we test in pre-commit tests.
# Enabled for DEBUG, ASAN, TSAN and UBSAN builds which are built pre-commit.
SET(CXX_FLAGS_DEBUG "${CXX_FLAGS_DEBUG} -Werror")
SET(CXX_FLAGS_RELEASE "${CXX_GCC_FLAGS} -O3 -DNDEBUG -gdwarf-2")
SET(CXX_FLAGS_ADDRESS_SANITIZER
"${CXX_CLANG_FLAGS} -O1 -g -fsanitize=address -fno-omit-frame-pointer -DADDRESS_SANITIZER")
"${CXX_CLANG_FLAGS} -Werror -O1 -g -fsanitize=address -fno-omit-frame-pointer -DADDRESS_SANITIZER")

# Set the flags to the undefined behavior sanitizer, also known as "ubsan"
# Turn on sanitizer and debug symbols to get stack traces:
SET(CXX_FLAGS_UBSAN "${CXX_CLANG_FLAGS} -ggdb3 -fno-omit-frame-pointer -fsanitize=undefined")
SET(CXX_FLAGS_UBSAN "${CXX_CLANG_FLAGS} -Werror -ggdb3 -fno-omit-frame-pointer -fsanitize=undefined")
# Set preprocessor macros to facilitate initialization the relevant configuration.
SET(CXX_FLAGS_UBSAN "${CXX_FLAGS_UBSAN} -DUNDEFINED_SANITIZER")
# Calling getenv() in __ubsan_default_options doesn't work, likely because of
Expand All @@ -131,7 +129,7 @@ SET(CXX_FLAGS_UBSAN "${CXX_FLAGS_UBSAN} -O0")

# Set the flags to the thread sanitizer, also known as "tsan"
# Turn on sanitizer and debug symbols to get stack traces:
SET(CXX_FLAGS_TSAN "${CXX_CLANG_FLAGS} -O1 -ggdb3 -fno-omit-frame-pointer")
SET(CXX_FLAGS_TSAN "${CXX_CLANG_FLAGS} -Werror -O1 -ggdb3 -fno-omit-frame-pointer")
SET(CXX_FLAGS_TSAN "${CXX_FLAGS_TSAN} -fsanitize=thread -DTHREAD_SANITIZER")

SET(CXX_FLAGS_TIDY "${CXX_CLANG_FLAGS}")
Expand Down
2 changes: 1 addition & 1 deletion be/src/exec/hdfs-table-writer.h
Expand Up @@ -30,7 +30,7 @@ namespace impala {
class HdfsPartitionDescriptor;
class HdfsTableDescriptor;
class HdfsTableSink;
class OutputPartition;
struct OutputPartition;
class RowBatch;
class RuntimeState;
class ScalarExprEvaluator;
Expand Down
2 changes: 1 addition & 1 deletion be/src/exprs/expr.h
Expand Up @@ -32,7 +32,7 @@
namespace impala {

class IsNullExpr;
class LibCacheEntry;
struct LibCacheEntry;
class LlvmCodeGen;
class MemTracker;
class ObjectPool;
Expand Down
2 changes: 1 addition & 1 deletion be/src/exprs/scalar-expr.h
Expand Up @@ -55,7 +55,7 @@ using impala_udf::StringVal;
using impala_udf::DecimalVal;
using impala_udf::CollectionVal;

class LibCacheEntry;
struct LibCacheEntry;
class LlvmCodeGen;
class MemTracker;
class ObjectPool;
Expand Down
2 changes: 1 addition & 1 deletion be/src/runtime/krpc-data-stream-recvr.h
Expand Up @@ -43,7 +43,7 @@ class MemTracker;
class RowBatch;
class RuntimeProfile;
class SortedRunMerger;
class TransmitDataCtx;
struct TransmitDataCtx;
class TransmitDataRequestPB;
class TransmitDataResponsePB;

Expand Down
2 changes: 1 addition & 1 deletion be/src/runtime/mem-tracker.h
Expand Up @@ -41,7 +41,7 @@ namespace impala {

class ObjectPool;
class MemTracker;
class ReservationTrackerCounters;
struct ReservationTrackerCounters;
class TQueryOptions;

/// A MemTracker tracks memory consumption; it contains an optional limit
Expand Down

0 comments on commit a139de2

Please sign in to comment.