================
@@ -133,24 +191,47 @@ void FactsGenerator::VisitCXXNullPtrLiteralExpr(
const CXXNullPtrLiteralExpr *N) {
/// TODO: Handle nullptr expr as a special 'null' loan. Uninitialized
/// pointers can use the same type of loan.
- FactMgr.getOriginMgr().getOrCreate(*N);
+ getOriginsList(*N);
}
void FactsGenerator::VisitImplicitCastExpr(const ImplicitCastExpr *ICE) {
- if (!hasOrigin(ICE))
+ OriginList *Dest = getOriginsList(*ICE);
+ if (!Dest)
+ return;
+ OriginList *SrcList = getOriginsList(*ICE->getSubExpr());
+
+ if (ICE->getCastKind() == CK_LValueToRValue) {
+ // TODO: Decide what to do for x-values here.
+ if (!ICE->getSubExpr()->isLValue())
+ return;
+
+ assert(SrcList && "LValue being cast to RValue has no origin list");
+ // The result of an LValue-to-RValue cast on a reference-to-pointer like
+ // has the inner origin. Get rid of the outer origin.
+ flow(getOriginsList(*ICE), getRValueOrigins(ICE->getSubExpr(), SrcList),
+ /*Kill=*/true);
+ return;
+ }
+ if (ICE->getCastKind() == CK_NullToPointer) {
+ getOriginsList(*ICE);
+ // TODO: Flow into them a null origin.
+ return;
+ }
+ if (ICE->getCastKind() == CK_NoOp ||
+ ICE->getCastKind() == CK_ConstructorConversion ||
+ ICE->getCastKind() == CK_UserDefinedConversion)
+ flow(Dest, SrcList, /*Kill=*/true);
+ if (ICE->getCastKind() == CK_FunctionToPointerDecay ||
+ ICE->getCastKind() == CK_BuiltinFnToFnPtr ||
+ ICE->getCastKind() == CK_ArrayToPointerDecay) {
+ // Ignore function-to-pointer decays.
return;
- // An ImplicitCastExpr node itself gets an origin, which flows from the
- // origin of its sub-expression (after stripping its own parens/casts).
- killAndFlowOrigin(*ICE, *ICE->getSubExpr());
+ }
----------------
usx95 wrote:
Done
https://github.com/llvm/llvm-project/pull/168344
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits