<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I could see it as a clang-tidy pass. "This method modifies members of 'this' but does not return 'this' or use it in any way [after modification]; do you want to make it lvalue-only?" I wouldn't make it a full warning because lvalue qualifiers are still fairly esoteric and people may not want to add them to their codebase even if they'd catch bugs.<div class=""><br class=""></div><div class="">Jordan<br class=""><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 14, 2019, at 15:43, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Seems like a losing race to try to flag every API surface area that might have this problem.<br class=""><br class="">Is it worth considering a clang-tidy or full clang warning for cases like this? (& could diagnose the usage directly)</div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 8, 2019 at 11:59 AM Jordan Rose via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: jrose<br class="">
Date: Tue Oct  8 12:01:48 2019<br class="">
New Revision: 374102<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=374102&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=374102&view=rev</a><br class="">
Log:<br class="">
Mark several PointerIntPair methods as lvalue-only<br class="">
<br class="">
No point in mutating 'this' if it's just going to be thrown away.<br class="">
<br class="">
<a href="https://reviews.llvm.org/D63945" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/D63945</a><br class="">
<br class="">
Modified:<br class="">
    llvm/trunk/include/llvm/ADT/PointerIntPair.h<br class="">
<br class="">
Modified: llvm/trunk/include/llvm/ADT/PointerIntPair.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerIntPair.h?rev=374102&r1=374101&r2=374102&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerIntPair.h?rev=374102&r1=374101&r2=374102&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/include/llvm/ADT/PointerIntPair.h (original)<br class="">
+++ llvm/trunk/include/llvm/ADT/PointerIntPair.h Tue Oct  8 12:01:48 2019<br class="">
@@ -13,6 +13,7 @@<br class="">
 #ifndef LLVM_ADT_POINTERINTPAIR_H<br class="">
 #define LLVM_ADT_POINTERINTPAIR_H<br class="">
<br class="">
+#include "llvm/Support/Compiler.h"<br class="">
 #include "llvm/Support/PointerLikeTypeTraits.h"<br class="">
 #include "llvm/Support/type_traits.h"<br class="">
 #include <cassert><br class="">
@@ -59,19 +60,19 @@ public:<br class="">
<br class="">
   IntType getInt() const { return (IntType)Info::getInt(Value); }<br class="">
<br class="">
-  void setPointer(PointerTy PtrVal) {<br class="">
+  void setPointer(PointerTy PtrVal) LLVM_LVALUE_FUNCTION {<br class="">
     Value = Info::updatePointer(Value, PtrVal);<br class="">
   }<br class="">
<br class="">
-  void setInt(IntType IntVal) {<br class="">
+  void setInt(IntType IntVal) LLVM_LVALUE_FUNCTION {<br class="">
     Value = Info::updateInt(Value, static_cast<intptr_t>(IntVal));<br class="">
   }<br class="">
<br class="">
-  void initWithPointer(PointerTy PtrVal) {<br class="">
+  void initWithPointer(PointerTy PtrVal) LLVM_LVALUE_FUNCTION {<br class="">
     Value = Info::updatePointer(0, PtrVal);<br class="">
   }<br class="">
<br class="">
-  void setPointerAndInt(PointerTy PtrVal, IntType IntVal) {<br class="">
+  void setPointerAndInt(PointerTy PtrVal, IntType IntVal) LLVM_LVALUE_FUNCTION {<br class="">
     Value = Info::updateInt(Info::updatePointer(0, PtrVal),<br class="">
                             static_cast<intptr_t>(IntVal));<br class="">
   }<br class="">
@@ -89,7 +90,7 @@ public:<br class="">
<br class="">
   void *getOpaqueValue() const { return reinterpret_cast<void *>(Value); }<br class="">
<br class="">
-  void setFromOpaqueValue(void *Val) {<br class="">
+  void setFromOpaqueValue(void *Val) LLVM_LVALUE_FUNCTION {<br class="">
     Value = reinterpret_cast<intptr_t>(Val);<br class="">
   }<br class="">
<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></div></div></body></html>