[PATCH] D37262: The issues with X86 prefixes: step 2
Andrew V. Tischenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 12 01:02:29 PDT 2017
avt77 added inline comments.
================
Comment at: lib/Target/X86/AsmParser/X86AsmParser.cpp:2866
+ if (static_cast<X86Operand &>(*Operands.back()).Kind == X86Operand::Prefix) {
+ X86Operand &Prefix = static_cast<X86Operand &>(*Operands.pop_back_val());
+ Prefixes = Prefix.getPrefix();
----------------
craig.topper wrote:
> I'm not sure this isn't a use after free. pop_back_val is going to return a std::unique_ptr which you dereferenced, but I'm not convinced anything is keeping the std::unique_ptr alive.
It seems that everything is OK here because
C++ Utilities library Dynamic memory management std::unique_ptr
typename std::add_lvalue_reference<T>::type operator*() const; (1) (since C++11)
pointer operator->() const noexcept; (2) (since C++11)
operator* and operator-> provide access to the object owned by *this.
The behavior is undefined if get() == nullptr
Parameters
(none)
Return value
1) Returns the object owned by *this, equivalent to *get().
2) Returns a pointer to the object owned by *this, i.e. get().
Am I right?
https://reviews.llvm.org/D37262
More information about the llvm-commits
mailing list