summaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-12-16 19:06:07 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-12-16 19:06:07 +0000
commit08d6e032a2a0a8656d12b3b7b93942987bb12eb7 (patch)
tree632b74cc7329419d23c53cb941e19ed16a587d5b /unittests
parentd3d8548e75f3fb6db53ed0927c1df30d78f4ce1d (diff)
C++11 constexpr: Add note stacks containing backtraces if constant evaluation
fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit argument to driver and frontend, to control the maximum number of notes so produced (default 10). Fix APValue printing to be able to pretty-print all APValue types, and move the testing for this functionality from a unittest to a -verify test now that it's visible in clang's output. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146749 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/AST/APValueTest.cpp83
-rw-r--r--unittests/AST/Makefile15
-rw-r--r--unittests/CMakeLists.txt5
-rw-r--r--unittests/Makefile2
4 files changed, 1 insertions, 104 deletions
diff --git a/unittests/AST/APValueTest.cpp b/unittests/AST/APValueTest.cpp
deleted file mode 100644
index 5ac454de5f..0000000000
--- a/unittests/AST/APValueTest.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-//===- unittests/AST/APValueTest.cpp - APValue tests ---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/AST/APValue.h"
-
-#include "clang/Basic/Diagnostic.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SmallString.h"
-
-#include "gtest/gtest.h"
-
-using namespace llvm;
-using namespace clang;
-
-namespace {
-
-class DiagnosticOutputGetter {
- class LastDiagnosticString : public DiagnosticConsumer {
- SmallString<64> LastDiagnostic;
- public:
- virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
- const Diagnostic &Info) {
- LastDiagnostic.clear();
- Info.FormatDiagnostic(LastDiagnostic);
- }
-
- StringRef get() const { return LastDiagnostic; }
-
- virtual DiagnosticConsumer *clone(DiagnosticsEngine &Diags) const {
- return new LastDiagnosticString();
- }
- };
-
- const IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs;
- const unsigned diag_just_format;
- LastDiagnosticString LastDiagnostic;
- DiagnosticsEngine Diag;
-
-public:
- DiagnosticOutputGetter()
- : DiagIDs(new DiagnosticIDs),
- diag_just_format(DiagIDs->getCustomDiagID(DiagnosticIDs::Error, "%0")),
- Diag(DiagIDs, &LastDiagnostic, false) {
- }
-
- template<typename T>
- std::string operator()(const T& value) {
- Diag.Report(diag_just_format) << value;
- return LastDiagnostic.get().str();
- }
-};
-
-TEST(APValue, Diagnostics) {
- DiagnosticOutputGetter GetDiagnosticOutput;
-
- EXPECT_EQ("Uninitialized", GetDiagnosticOutput(APValue()));
- EXPECT_EQ("5", GetDiagnosticOutput(APValue(APSInt(APInt(16, 5)))));
- EXPECT_EQ("3.141590e+00",
- GetDiagnosticOutput(APValue(APFloat(APFloat::IEEEdouble,
- "3.14159"))));
- EXPECT_EQ("3+4i",
- GetDiagnosticOutput(APValue(APSInt(APInt(16, 3)),
- APSInt(APInt(16, 4)))));
- EXPECT_EQ("3.200000e+00+5.700000e+00i",
- GetDiagnosticOutput(APValue(
- APFloat(APFloat::IEEEdouble, "3.2"),
- APFloat(APFloat::IEEEdouble, "5.7"))));
- APValue V[] = {
- APValue(APSInt(APInt(16, 3))),
- APValue(APSInt(APInt(16, 4))),
- APValue(APSInt(APInt(16, 5)))
- };
- EXPECT_EQ("[3, 4, 5]",
- GetDiagnosticOutput(APValue(V, array_lengthof(V))));
-}
-
-} // anonymous namespace
diff --git a/unittests/AST/Makefile b/unittests/AST/Makefile
deleted file mode 100644
index 74191d037f..0000000000
--- a/unittests/AST/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-##===- unittests/Frontend/Makefile -------------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-
-CLANG_LEVEL = ../..
-TESTNAME = AST
-LINK_COMPONENTS := support mc
-USEDLIBS = clangAST.a clangBasic.a
-
-include $(CLANG_LEVEL)/unittests/Makefile
diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt
index 901f167f35..cb44dc59dc 100644
--- a/unittests/CMakeLists.txt
+++ b/unittests/CMakeLists.txt
@@ -50,11 +50,6 @@ if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
add_definitions("-Wno-variadic-macros")
endif()
-add_clang_unittest(AST
- AST/APValueTest.cpp
- USED_LIBS gtest gtest_main clangAST
- )
-
add_clang_unittest(Basic
Basic/FileManagerTest.cpp
USED_LIBS gtest gtest_main clangBasic
diff --git a/unittests/Makefile b/unittests/Makefile
index f4ce6adaa7..951e17e217 100644
--- a/unittests/Makefile
+++ b/unittests/Makefile
@@ -14,7 +14,7 @@ ifndef CLANG_LEVEL
IS_UNITTEST_LEVEL := 1
CLANG_LEVEL := ..
-PARALLEL_DIRS = AST Basic Frontend
+PARALLEL_DIRS = Basic Frontend
endif # CLANG_LEVEL