diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h index a876e653925a..e84af077f9ff 100644 --- a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h +++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h @@ -607,9 +607,9 @@ public: static bool classof(const SExpr *E) { return E->opcode() == COP_Literal; } Literal(const clang::Expr *C) - : SExpr(COP_Literal), ValType(ValueType::getValueType()) + : SExpr(COP_Literal), ValType(ValueType::getValueType()), Cexpr(C) { } - Literal(ValueType VT) : SExpr(COP_Literal), ValType(VT) {} + Literal(ValueType VT) : SExpr(COP_Literal), ValType(VT), Cexpr(nullptr) {} Literal(const Literal &L) : SExpr(L), ValType(L.ValType), Cexpr(L.Cexpr) {} // The clang expression for this literal. diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h b/clang/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h index 344f9d68147a..322a3b589ee1 100644 --- a/clang/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h +++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyTraverse.h @@ -600,8 +600,10 @@ protected: } void printLiteral(Literal *E, StreamType &SS) { - if (E->clangExpr()) + if (E->clangExpr()) { SS << getSourceLiteralString(E->clangExpr()); + return; + } else { ValueType VT = E->valueType(); switch (VT.Base) { @@ -610,7 +612,7 @@ protected: return; } case ValueType::BT_Bool: { - if (reinterpret_cast*>(E)->value()) + if (E->as().value()) SS << "true"; else SS << "false"; @@ -620,27 +622,27 @@ protected: switch (VT.Size) { case ValueType::ST_8: if (VT.Signed) - printLiteralT(reinterpret_cast*>(E), SS); + printLiteralT(&E->as(), SS); else - printLiteralT(reinterpret_cast*>(E), SS); + printLiteralT(&E->as(), SS); return; case ValueType::ST_16: if (VT.Signed) - printLiteralT(reinterpret_cast*>(E), SS); + printLiteralT(&E->as(), SS); else - printLiteralT(reinterpret_cast*>(E), SS); + printLiteralT(&E->as(), SS); return; case ValueType::ST_32: if (VT.Signed) - printLiteralT(reinterpret_cast*>(E), SS); + printLiteralT(&E->as(), SS); else - printLiteralT(reinterpret_cast*>(E), SS); + printLiteralT(&E->as(), SS); return; case ValueType::ST_64: if (VT.Signed) - printLiteralT(reinterpret_cast*>(E), SS); + printLiteralT(&E->as(), SS); else - printLiteralT(reinterpret_cast*>(E), SS); + printLiteralT(&E->as(), SS); return; default: break; @@ -650,10 +652,10 @@ protected: case ValueType::BT_Float: { switch (VT.Size) { case ValueType::ST_32: - printLiteralT(reinterpret_cast*>(E), SS); + printLiteralT(&E->as(), SS); return; case ValueType::ST_64: - printLiteralT(reinterpret_cast*>(E), SS); + printLiteralT(&E->as(), SS); return; default: break; @@ -662,7 +664,7 @@ protected: } case ValueType::BT_String: { SS << "\""; - printLiteralT(reinterpret_cast*>(E), SS); + printLiteralT(&E->as(), SS); SS << "\""; return; }