[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / clang / unittests / Basic / SanitizersTest.cpp
blobc6537cbf71a94ce02c60551421880e06d46f0e9a
1 //===- unittests/Basic/SanitizersTest.cpp - Test Sanitizers ---------------===//
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/Sanitizers.h"
11 #include "gmock/gmock-matchers.h"
12 #include "gtest/gtest.h"
14 using namespace clang;
16 using testing::Contains;
17 using testing::Not;
19 TEST(SanitizersTest, serializeSanitizers) {
20 SanitizerSet Set;
21 Set.set(parseSanitizerValue("memory", false), true);
22 Set.set(parseSanitizerValue("nullability-arg", false), true);
24 SmallVector<StringRef, 4> Serialized;
25 serializeSanitizerSet(Set, Serialized);
27 ASSERT_EQ(Serialized.size(), 2u);
28 ASSERT_THAT(Serialized, Contains("memory"));
29 ASSERT_THAT(Serialized, Contains("nullability-arg"));
32 TEST(SanitizersTest, serializeSanitizersIndividual) {
33 SanitizerSet Set;
34 Set.set(parseSanitizerValue("memory", false), true);
35 Set.set(parseSanitizerValue("nullability-arg", false), true);
36 Set.set(parseSanitizerValue("nullability-assign", false), true);
37 Set.set(parseSanitizerValue("nullability-return", false), true);
39 SmallVector<StringRef, 4> Serialized;
40 serializeSanitizerSet(Set, Serialized);
42 ASSERT_EQ(Serialized.size(), 4u);
43 ASSERT_THAT(Serialized, Contains("memory"));
44 ASSERT_THAT(Serialized, Contains("nullability-arg"));
45 ASSERT_THAT(Serialized, Contains("nullability-assign"));
46 ASSERT_THAT(Serialized, Contains("nullability-return"));
47 // Individual sanitizers don't get squashed into a single group.
48 ASSERT_THAT(Serialized, Not(Contains("nullability")));