| 51 | ASTValue::ASTValue(const ASTValue &Rhs) : IsArray(false) { *this = Rhs; } |
| 52 | |
| 53 | std::pair<bool, std::vector<ASTValueData>> |
| 54 | ASTValue::getData(const Expr &E, const ASTContext &Ctx) const { |
| 55 | |
| 56 | std::pair<bool, std::vector<ASTValueData>> Result = |
| 57 | std::make_pair(false, std::vector<ASTValueData>()); |
| 58 | |
| 59 | auto QTy = E.getType(); |
| 60 | if (QTy.isNull()) { |
| 61 | return Result; |
| 62 | } |
| 63 | |
| 64 | if (QTy->isIntegerType() || QTy->isEnumeralType()) { |
| 65 | auto Value = getValueAsReal(E, Ctx); |
| 66 | if (!Value.empty()) { |
| 67 | Result.second.emplace_back(ASTValueData::VType_INT, Value); |
| 68 | } |
| 69 | return Result; |
| 70 | } |
| 71 | |
| 72 | if (QTy->isRealFloatingType()) { |
| 73 | auto Value = getValueAsReal(E, Ctx); |
| 74 | if (!Value.empty()) { |
| 75 | Result.second.emplace_back(ASTValueData::VType_FLOAT, Value); |
| 76 | } |
| 77 | return Result; |
| 78 | } |
| 79 | |
| 80 | if (QTy->isAnyPointerType()) { |
| 81 | auto PointeeQTy = QTy->getPointeeType(); |
| 82 | if (!PointeeQTy.getTypePtrOrNull() || !PointeeQTy->isAnyCharacterType()) { |
| 83 | return Result; |
| 84 | } |
| 85 | |
| 86 | auto Value = getValueAsString(E, Ctx); |
| 87 | if (!Value.empty()) { |
| 88 | Result.second.emplace_back(ASTValueData::VType_STRING, Value); |
| 89 | } |
| 90 | return Result; |
| 91 | } |
| 92 | |
| 93 | if (QTy->isArrayType()) { |
| 94 | Result.first = true; |
| 95 | Result.second = getDataForArray(E, Ctx); |
| 96 | } |
| 97 | |
| 98 | return Result; |
| 99 | } |
| 100 | |
| 101 | bool ASTValue::fromJson(Json::Value Json) { |
| 102 |
nothing calls this directly
no test coverage detected