Add -ftrapv support, patch from David Chisnall; well all except the
clang option code that is and two bug fixes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68240 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 6cfd168..b149a1d 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -675,6 +675,14 @@
Options.setGCMode(LangOptions::HybridGC);
}
+static llvm::cl::opt<bool>
+OverflowChecking("ftrapv",
+ llvm::cl::desc("Trap on integer overflow"),
+ llvm::cl::init(false));
+
+void InitializeOverflowChecking(LangOptions &Options) {
+ Options.OverflowChecking = OverflowChecking;
+}
//===----------------------------------------------------------------------===//
// Target Triple Processing.
//===----------------------------------------------------------------------===//
@@ -1626,6 +1634,7 @@
LangKind LK = GetLanguage(InFile);
InitializeLangOptions(LangInfo, LK);
InitializeGCMode(LangInfo);
+ InitializeOverflowChecking(LangInfo);
InitializeLanguageStandard(LangInfo, LK, Target.get());
// Process the -I options and set them in the HeaderInfo.