aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2014-11-11 01:26:14 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2014-11-11 01:26:14 +0000
commita041610f11e9be018e125a5789e3ea258659dab4 (patch)
tree5f29be853db4279ef35e5a90bd451de7a2a36665 /clang/lib/Basic
parent7f654a8e8f68b91efea0c71bcf327478cc2c168f (diff)
downloadllvm-a041610f11e9be018e125a5789e3ea258659dab4.zip
llvm-a041610f11e9be018e125a5789e3ea258659dab4.tar.gz
llvm-a041610f11e9be018e125a5789e3ea258659dab4.tar.bz2
[Sanitizer] Refactor sanitizer options in LangOptions.
Get rid of ugly SanitizerOptions class thrust into LangOptions: * Make SanitizeAddressFieldPadding a regular language option, and rely on default behavior to initialize/reset it. * Make SanitizerBlacklistFile a regular member LangOptions. * Introduce the helper class "SanitizerSet" to represent the set of enabled sanitizers and make it a member of LangOptions. It is exactly the entity we want to cache and modify in CodeGenFunction, for instance. We'd also be able to reuse SanitizerSet in CodeGenOptions for storing the set of recoverable sanitizers, and in the Driver to represent the set of sanitizers turned on/off by the commandline flags. No functionality change. llvm-svn: 221653
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r--clang/lib/Basic/CMakeLists.txt1
-rw-r--r--clang/lib/Basic/LangOptions.cpp19
-rw-r--r--clang/lib/Basic/Sanitizers.cpp31
3 files changed, 33 insertions, 18 deletions
diff --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index 2ecbf0a..3bcbc89 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -19,6 +19,7 @@ add_clang_library(clangBasic
OpenMPKinds.cpp
OperatorPrecedence.cpp
SanitizerBlacklist.cpp
+ Sanitizers.cpp
SourceLocation.cpp
SourceManager.cpp
TargetInfo.cpp
diff --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index 8992bfa..dcbd228 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -14,24 +14,6 @@
using namespace clang;
-SanitizerOptions::SanitizerOptions()
- : Kind(0), SanitizeAddressFieldPadding(0) {}
-
-bool SanitizerOptions::has(SanitizerKind K) const {
- unsigned Bit = static_cast<unsigned>(K);
- return Kind & (1 << Bit);
-}
-
-void SanitizerOptions::set(SanitizerKind K, bool Value) {
- unsigned Bit = static_cast<unsigned>(K);
- Kind = Value ? (Kind | (1 << Bit)) : (Kind & ~(1 << Bit));
-}
-
-void SanitizerOptions::clear() {
- SanitizerOptions Default;
- *this = std::move(Default);
-}
-
LangOptions::LangOptions() {
#define LANGOPT(Name, Bits, Default, Description) Name = Default;
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) set##Name(Default);
@@ -48,6 +30,7 @@ void LangOptions::resetNonModularOptions() {
// FIXME: This should not be reset; modules can be different with different
// sanitizer options (this affects __has_feature(address_sanitizer) etc).
Sanitize.clear();
+ SanitizerBlacklistFile.clear();
CurrentModule.clear();
ImplementationOfModule.clear();
diff --git a/clang/lib/Basic/Sanitizers.cpp b/clang/lib/Basic/Sanitizers.cpp
new file mode 100644
index 0000000..7bc884d
--- /dev/null
+++ b/clang/lib/Basic/Sanitizers.cpp
@@ -0,0 +1,31 @@
+//===--- Sanitizers.cpp - C Language Family Language Options ----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the classes from Sanitizers.h
+//
+//===----------------------------------------------------------------------===//
+#include "clang/Basic/Sanitizers.h"
+
+using namespace clang;
+
+SanitizerSet::SanitizerSet() : Kinds(0) {}
+
+bool SanitizerSet::has(SanitizerKind K) const {
+ unsigned Bit = static_cast<unsigned>(K);
+ return Kinds & (1 << Bit);
+}
+
+void SanitizerSet::set(SanitizerKind K, bool Value) {
+ unsigned Bit = static_cast<unsigned>(K);
+ Kinds = Value ? (Kinds | (1 << Bit)) : (Kinds & ~(1 << Bit));
+}
+
+void SanitizerSet::clear() {
+ Kinds = 0;
+}