
Summary: Change the way we use ASan and UBSan together. Instead of keeping two separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on a platform, all UBSan sources are just compiled into dummy empty object files. UBSan initialization code (e.g. flag parsing) is directly called from ASan initialization, so we are able to enforce correct initialization order. This mirrors the approach we already use for ASan+LSan. This change doesn't modify the way we use standalone UBSan. Test Plan: regression test suite Reviewers: kubabrecka, zaks.anna, rsmith, kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8646 llvm-svn: 233861
50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
//===-- ubsan_flags.h -------------------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Runtime flags for UndefinedBehaviorSanitizer.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
#ifndef UBSAN_FLAGS_H
|
|
#define UBSAN_FLAGS_H
|
|
|
|
#include "sanitizer_common/sanitizer_internal_defs.h"
|
|
|
|
namespace __sanitizer {
|
|
class FlagParser;
|
|
}
|
|
|
|
namespace __ubsan {
|
|
|
|
struct Flags {
|
|
#define UBSAN_FLAG(Type, Name, DefaultValue, Description) Type Name;
|
|
#include "ubsan_flags.inc"
|
|
#undef UBSAN_FLAG
|
|
|
|
void SetDefaults();
|
|
};
|
|
|
|
extern Flags ubsan_flags;
|
|
inline Flags *flags() { return &ubsan_flags; }
|
|
|
|
void InitializeFlags();
|
|
void RegisterUbsanFlags(FlagParser *parser, Flags *f);
|
|
|
|
const char *MaybeCallUbsanDefaultOptions();
|
|
|
|
} // namespace __ubsan
|
|
|
|
extern "C" {
|
|
// Users may provide their own implementation of __ubsan_default_options to
|
|
// override the default flag values.
|
|
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
|
|
const char *__ubsan_default_options();
|
|
} // extern "C"
|
|
|
|
#endif // UBSAN_FLAGS_H
|