aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-11-30 01:15:32 +0000
committerJordan Rose <jordan_rose@apple.com>2012-11-30 01:15:32 +0000
commitdcd42fbb418cf662c136cb035e235a44b58ad91e (patch)
treed97ab6a7cf9ccb8b31465e08a7bd301eb8d68dc0 /lib/Frontend/CompilerInstance.cpp
parent7dff05bf3019995798def5d1066e4282b8578df6 (diff)
Use the new LLVM_LVALUE_FUNCTION to ban two getAs() calls on rvalues.
If 'x' is a temporary, x.getAs<Foo>() may not be safe if the result is supposed to persist (if its address is stored somewhere). Since getAs() can return a null value, the result is almost always stored into a variable, which of course is not safe when the original value dies. This has caused several bugs with GCC's "Temporaries May Vanish Sooner Than You Expect" optimization; in C++11 builds, at least, we'll be able to catch these problems now. I would suggest applying these to other getAs() and get*As() methods (castAs is "better" because sometimes the result is used directly, which means the temporary will still be live), but these two have both caused trouble in the analyzer in the past. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168967 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/CompilerInstance.cpp')
0 files changed, 0 insertions, 0 deletions