|
17 | 17 | #include "clang/Analysis/FlowSensitive/StorageLocation.h"
|
18 | 18 | #include "clang/Analysis/FlowSensitive/Value.h"
|
19 | 19 | #include "clang/Basic/LangStandard.h"
|
| 20 | +#include "clang/Testing/TestAST.h" |
20 | 21 | #include "llvm/ADT/SmallVector.h"
|
21 | 22 | #include "llvm/ADT/StringRef.h"
|
22 | 23 | #include "llvm/Testing/Support/Error.h"
|
@@ -135,12 +136,32 @@ const Formula &getFormula(const ValueDecl &D, const Environment &Env) {
|
135 | 136 | }
|
136 | 137 |
|
137 | 138 | TEST(TransferTest, CNotSupported) {
|
138 |
| - std::string Code = R"( |
139 |
| - void target() {} |
140 |
| - )"; |
141 |
| - ASSERT_THAT_ERROR(checkDataflowWithNoopAnalysis( |
142 |
| - Code, [](const auto &, auto &) {}, {BuiltinOptions{}}, |
143 |
| - LangStandard::lang_c89), |
| 139 | + TestInputs Inputs("void target() {}"); |
| 140 | + Inputs.Language = TestLanguage::Lang_C89; |
| 141 | + clang::TestAST AST(Inputs); |
| 142 | + const auto *Target = |
| 143 | + cast<FunctionDecl>(test::findValueDecl(AST.context(), "target")); |
| 144 | + ASSERT_THAT_ERROR(AdornedCFG::build(*Target).takeError(), |
| 145 | + llvm::FailedWithMessage("Can only analyze C++")); |
| 146 | +} |
| 147 | + |
| 148 | +TEST(TransferTest, ObjectiveCNotSupported) { |
| 149 | + TestInputs Inputs("void target() {}"); |
| 150 | + Inputs.Language = TestLanguage::Lang_OBJC; |
| 151 | + clang::TestAST AST(Inputs); |
| 152 | + const auto *Target = |
| 153 | + cast<FunctionDecl>(test::findValueDecl(AST.context(), "target")); |
| 154 | + ASSERT_THAT_ERROR(AdornedCFG::build(*Target).takeError(), |
| 155 | + llvm::FailedWithMessage("Can only analyze C++")); |
| 156 | +} |
| 157 | + |
| 158 | +TEST(TransferTest, ObjectiveCXXNotSupported) { |
| 159 | + TestInputs Inputs("void target() {}"); |
| 160 | + Inputs.Language = TestLanguage::Lang_OBJCXX; |
| 161 | + clang::TestAST AST(Inputs); |
| 162 | + const auto *Target = |
| 163 | + cast<FunctionDecl>(test::findValueDecl(AST.context(), "target")); |
| 164 | + ASSERT_THAT_ERROR(AdornedCFG::build(*Target).takeError(), |
144 | 165 | llvm::FailedWithMessage("Can only analyze C++"));
|
145 | 166 | }
|
146 | 167 |
|
|
0 commit comments