[SCCP] Avoid modifying AdditionalUsers while iterating over it
[llvm-project.git] / clang / unittests / CodeGen / CheckTargetFeaturesTest.cpp
blob160b387338d5d2de7bb8da4f7208c6397996362b
1 #include "../lib/CodeGen/CodeGenFunction.h"
2 #include "gtest/gtest.h"
4 using namespace llvm;
6 // These tests are to Check whether CodeGen::TargetFeatures works correctly.
7 TEST(CheckTargetFeaturesTest, checkBuiltinFeatures) {
8 auto doCheck = [](StringRef BuiltinFeatures, StringRef FuncFeatures) {
9 SmallVector<StringRef, 1> Features;
10 FuncFeatures.split(Features, ',');
11 StringMap<bool> SM;
12 for (StringRef F : Features)
13 SM.insert(std::make_pair(F, true));
14 clang::CodeGen::TargetFeatures TF(SM);
15 return TF.hasRequiredFeatures(BuiltinFeatures);
17 // Make sure the basic function ',' and '|' works correctly
18 ASSERT_FALSE(doCheck("A,B,C,D", "A"));
19 ASSERT_TRUE(doCheck("A,B,C,D", "A,B,C,D"));
20 ASSERT_TRUE(doCheck("A|B", "A"));
21 ASSERT_FALSE(doCheck("A|B", "C"));
23 // Make sure the ',' has higher priority.
24 ASSERT_TRUE(doCheck("A|B,C|D", "A"));
26 // Make sure the parentheses do change the priority of '|'.
27 ASSERT_FALSE(doCheck("(A|B),(C|D)", "A"));
28 ASSERT_TRUE(doCheck("(A|B),(C|D)", "A,C"));
30 // Make sure the combination in parentheses works correctly.
31 ASSERT_FALSE(doCheck("(A,B|C),D", "A,C"));
32 ASSERT_FALSE(doCheck("(A,B|C),D", "A,D"));
33 ASSERT_TRUE(doCheck("(A,B|C),D", "C,D"));
34 ASSERT_TRUE(doCheck("(A,B|C),D", "A,B,D"));
36 // Make sure nested parentheses works correctly.
37 ASSERT_FALSE(doCheck("(A,(B|C)),D", "C,D"));
38 ASSERT_TRUE(doCheck("(A,(B|C)),D", "A,C,D"));