Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / unittests / StaticAnalyzer / APSIntTypeTest.cpp
blob19adb1b77c67590aae4f9b22b5d5ede649587f94
1 //===- unittest/StaticAnalyzer/APSIntTest.cpp - getAPSIntType test --===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "clang/Basic/TargetInfo.h"
10 #include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
11 #include "clang/Tooling/Tooling.h"
12 #include "llvm/ADT/APSInt.h"
13 #include "llvm/Support/raw_ostream.h"
14 #include "gtest/gtest.h"
16 namespace {
18 TEST(getAPSIntTypeTest, APSIntTypeTests) {
19 std::unique_ptr<clang::ASTUnit> AST = clang::tooling::buildASTFromCode("");
20 clang::ASTContext &Context = AST->getASTContext();
21 llvm::BumpPtrAllocator Arena;
22 clang::ento::BasicValueFactory BVF{Context, Arena};
24 clang::ento::APSIntType Ty = BVF.getAPSIntType(Context.LongAccumTy);
25 EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongAccumWidth());
26 EXPECT_FALSE(Ty.isUnsigned());
28 Ty = BVF.getAPSIntType(Context.UnsignedLongAccumTy);
29 EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongAccumWidth());
30 EXPECT_TRUE(Ty.isUnsigned());
32 Ty = BVF.getAPSIntType(Context.LongFractTy);
33 EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongFractWidth());
34 EXPECT_FALSE(Ty.isUnsigned());
36 Ty = BVF.getAPSIntType(Context.UnsignedLongFractTy);
37 EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongFractWidth());
38 EXPECT_TRUE(Ty.isUnsigned());
40 Ty = BVF.getAPSIntType(Context.SignedCharTy);
41 EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getCharWidth());
42 EXPECT_FALSE(Ty.isUnsigned());
44 Ty = BVF.getAPSIntType(Context.UnsignedCharTy);
45 EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getCharWidth());
46 EXPECT_TRUE(Ty.isUnsigned());
48 Ty = BVF.getAPSIntType(Context.LongTy);
49 EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongWidth());
50 EXPECT_FALSE(Ty.isUnsigned());
52 Ty = BVF.getAPSIntType(Context.UnsignedLongTy);
53 EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongWidth());
54 EXPECT_TRUE(Ty.isUnsigned());
57 } // end namespace