[llvm-dev] Strange local variable cv::VideoCapture allocated
Adrian Tong via llvm-dev
llvm-dev at lists.llvm.org
Sat Jun 8 19:46:44 PDT 2019
Hi
I am using clang-6 to compile this C++ code and I see a strange temporary
variable allocated at expression address 0x7ff1131536e8.
If I change the ternary operator at line 483 to an if-else, the temporary
is not allocated.
Thanks
Variables:
=========
FFMPEGVideoCapture ffmpeg_video_capture_;
cv::VideoCapture opencv_video_capture_;
Function:
========
bool StreamData::readFileFrame(Mat& curr_frame, int& frame_id) {
// read frame from file
++frame_id;
483: enable_ffmpeg_decoder_ ? (ffmpeg_video_capture_.read(curr_frame))
: opencv_video_capture_ >> curr_frame;
return !curr_frame.empty();
}
Generated AST from ast-dump:
===========================
-CXXMethodDecl 0x7ff113148810 parent 0x7ff114400cb0 prev 0x7ff114401e30
<line:480:1, line:486:1> line:480:18 used readFileFrame 'bool (cv::Mat &,
int &)'
| |-ParmVarDecl 0x7ff113148708 <col:32, col:37> col:37 used curr_frame
'cv::Mat &'
| |-ParmVarDecl 0x7ff113148780 <col:49, col:54> col:54 used frame_id 'int &'
| `-CompoundStmt 0x7ff1131537d8 <col:64, line:486:1>
| |-UnaryOperator 0x7ff113148930 <line:482:5, col:7> 'int' lvalue prefix
'++'
| | `-DeclRefExpr 0x7ff113148908 <col:7> 'int' lvalue ParmVar
0x7ff113148780 'frame_id' 'int &'
| |-ExprWithCleanups 0x7ff1131536e8 <line:483:5, line:484:32>
'cv::VideoCapture'
| | `-ConditionalOperator 0x7ff1131536b8 <line:483:5, line:484:32>
'cv::VideoCapture'
| | |-ImplicitCastExpr 0x7ff113153178 <line:483:5> 'bool'
<LValueToRValue>
| | | `-MemberExpr 0x7ff113148968 <col:5> 'bool' lvalue
->enable_ffmpeg_decoder_ 0x7ff114221ef0
| | | `-CXXThisExpr 0x7ff113148950 <col:5> 'xyz::StreamData *' this
| | |-CXXBindTemporaryExpr 0x7ff113153620 <col:30, col:69>
'cv::VideoCapture' (CXXTemporary 0x7ff113153618)
| | | `-CXXConstructExpr 0x7ff1131535e0 <col:30, col:69>
'cv::VideoCapture' 'void (const cv::VideoCapture &) noexcept(false)'
elidable
| | | `-MaterializeTemporaryExpr 0x7ff1131535c8 <col:30, col:69>
'const cv::VideoCapture' lvalue
| | | `-ImplicitCastExpr 0x7ff1131535b0 <col:30, col:69> 'const
cv::VideoCapture' <NoOp>
| | | `-CXXBindTemporaryExpr 0x7ff113153590 <col:30, col:69>
'cv::VideoCapture' (CXXTemporary 0x7ff113153588)
| | | `-CXXConstructExpr 0x7ff113153550 <col:30, col:69>
'cv::VideoCapture' 'void (const cv::VideoCapture &) noexcept(false)'
elidable
| | | `-MaterializeTemporaryExpr 0x7ff113153238 <col:30,
col:69> 'const cv::VideoCapture' lvalue
| | | `-ImplicitCastExpr 0x7ff113153220 <col:30, col:69>
'const cv::VideoCapture' <NoOp>
| | | `-CXXBindTemporaryExpr 0x7ff113153200 <col:30,
col:69> 'cv::VideoCapture' (CXXTemporary 0x7ff1131531f8)
| | | `-ImplicitCastExpr 0x7ff1131531e0 <col:30,
col:69> 'cv::VideoCapture' <ConstructorConversion>
| | | `-CXXConstructExpr 0x7ff1131531a8 <col:30,
col:69> 'cv::VideoCapture' 'void (int)'
| | | `-ImplicitCastExpr 0x7ff113153190 <col:30,
col:69> 'int' <IntegralCast>
| | | `-ParenExpr 0x7ff113148a80 <col:30, col:69>
'bool'
| | | `-CXXMemberCallExpr 0x7ff113148a50
<col:31, col:68> 'bool'
| | | |-MemberExpr 0x7ff1131489f0 <col:31,
col:53> '<bound member function type>' .read 0x7ff1143a6f38
| | | | `-MemberExpr 0x7ff1131489b8 <col:31>
'FFMPEGVideoCapture' lvalue ->ffmpeg_video_capture_ 0x7ff114402a38
| | | | `-CXXThisExpr 0x7ff1131489a0
<col:31> 'xyz::StreamData *' this
| | | `-DeclRefExpr 0x7ff113148a28 <col:58>
'cv::Mat' lvalue ParmVar 0x7ff113148708 'curr_frame' 'cv::Mat &'
| | `-CXXBindTemporaryExpr 0x7ff113153698 <line:484:7, col:32>
'cv::VideoCapture' (CXXTemporary 0x7ff113153690)
| | `-CXXConstructExpr 0x7ff113153658 <col:7, col:32>
'cv::VideoCapture' 'void (const cv::VideoCapture &) noexcept(false)'
| | `-ImplicitCastExpr 0x7ff113153640 <col:7, col:32> 'const
cv::VideoCapture' lvalue <NoOp>
| | `-CXXOperatorCallExpr 0x7ff113153130 <col:7, col:32>
'cv::VideoCapture' lvalue
| | |-ImplicitCastExpr 0x7ff113153118 <col:29>
'cv::VideoCapture &(*)(cv::Mat &)' <FunctionToPointerDecay>
| | | `-DeclRefExpr 0x7ff1131530c0 <col:29> 'cv::VideoCapture
&(cv::Mat &)' lvalue CXXMethod 0x55be741b2b60 'operator>>'
'cv::VideoCapture &(cv::Mat &)'
| | |-MemberExpr 0x7ff113148ab8 <col:7>
'cv::VideoCapture':'cv::VideoCapture' lvalue ->opencv_video_capture_
0x7ff114402b00
| | | `-CXXThisExpr 0x7ff113148aa0 <col:7> 'xyz::StreamData *'
this
| | `-DeclRefExpr 0x7ff113148af0 <col:32> 'cv::Mat' lvalue
ParmVar 0x7ff113148708 'curr_frame' 'cv::Mat &'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190608/f6793ebb/attachment.html>
More information about the llvm-dev
mailing list