[llvm-commits] [llvm] r169728 - in /llvm/trunk: include/llvm/Analysis/PtrUseVisitor.h lib/Analysis/CMakeLists.txt lib/Analysis/PtrUseVisitor.cpp lib/Transforms/Scalar/SROA.cpp
Duncan Sands
baldrick at free.fr
Mon Dec 10 01:53:59 PST 2012
Hi Chandler,
On 10/12/12 10:49, Chandler Carruth wrote:
> On Mon, Dec 10, 2012 at 1:45 AM, Duncan Sands <baldrick at free.fr
> <mailto:baldrick at free.fr>> wrote:
>
> Hi Chandler,
>
>
> + /// \brief Mark the visit as aborted. Intended for use in
> a void
> return.
>
>
> Intended for use in a void return? What does this mean? What
> happens if I is
> used for an instruction that is not a void return?
>
>
> The 'set' methods are intended to work cleanly with code like:
>
> void visitMyInstruction(__MyInstruction &I) {
> // .. some code ..
>
> if (detectErrorCondition())
> return PI.setAborted(&I);
>
> // .. rest of my code ..
> }
>
> Thus, they are designed to be called within a void-type return statement
> by the
> implementor of the visitor. Does that clarify? It has nothing to do with the
> return of the LLVM IR under analysis.
>
>
> are you saying that the user should not continue to use the visitor after having
> called setAborted, and should bail out at once?
>
>
> Nothing breaks if the user continues to use it. Setting abort just halts the
> visit across the uses. Often this is done when the user is no longer interested
> in the results, including the visit currently taking place, so this is expected
> to be a common pattern but not necessarily a required pattern.
in that case, why not drop the "they are designed to be called within a
void-type return statement" comments altogether? At worst someone will write
if (detectErrorCondition()) {
PI.setAborted(&I);
return;
}
rather than your neater version, but this is harmless.
Ciao, Duncan.
More information about the llvm-commits
mailing list