[cfe-commits] r148874 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/Analysis/reference.cpp
Chandler Carruth
chandlerc at google.com
Sat Jan 28 16:50:07 PST 2012
qualifying the pointer with volatile works, and is only a touch awkward.
We've already done this for one copy, I'll update the main open source
version as soon as I'm able.
On Jan 28, 2012 4:21 PM, "Nico Weber" <thakis at chromium.org> wrote:
> Hi Eli,
>
> with this change, clang now warns about this function in gtest (which is
> fine):
>
> // Invalid<T>() returns an invalid value of type T. This is useful
> // when a value of type T is needed for compilation, but the statement
> // will not really be executed (or we don't care if the statement
> // crashes).
> template <typename T>
> inline T Invalid() {
> return *static_cast<typename remove_reference<T>::type*>(NULL);
> }
>
> The warning recommends to add a "volatile", but then code that calls
> this function with a type without copy constructor fails to compile.
> What's the recommended way to change code like this?
>
> Should the -Wnull-dereference diagnostic text be changed to something
> else in an expression context? It currently says "consider using
> __builtin_trap() or qualifying pointer with 'volatile'".
>
> Thanks,
> Nico
>
> On Tue, Jan 24, 2012 at 2:51 PM, Eli Friedman <eli.friedman at gmail.com>
> wrote:
> > Author: efriedma
> > Date: Tue Jan 24 16:51:26 2012
> > New Revision: 148874
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=148874&view=rev
> > Log:
> > Switch PerformImplicitConversion over to use DefaultLvalueConversion for
> lvalue-to-rvalue conversion.
> >
> >
> > Modified:
> > cfe/trunk/lib/Sema/SemaExprCXX.cpp
> > cfe/trunk/test/Analysis/reference.cpp
> >
> > Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=148874&r1=148873&r2=148874&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jan 24 16:51:26 2012
> > @@ -2324,12 +2324,14 @@
> > // Nothing to do.
> > break;
> >
> > - case ICK_Lvalue_To_Rvalue:
> > + case ICK_Lvalue_To_Rvalue: {
> > assert(From->getObjectKind() != OK_ObjCProperty);
> > FromType = FromType.getUnqualifiedType();
> > - From = ImplicitCastExpr::Create(Context, FromType,
> CK_LValueToRValue,
> > - From, 0, VK_RValue);
> > + ExprResult FromRes = DefaultLvalueConversion(From);
> > + assert(!FromRes.isInvalid() && "Can't perform deduced
> conversion?!");
> > + From = FromRes.take();
> > break;
> > + }
> >
> > case ICK_Array_To_Pointer:
> > FromType = Context.getArrayDecayedType(FromType);
> >
> > Modified: cfe/trunk/test/Analysis/reference.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/reference.cpp?rev=148874&r1=148873&r2=148874&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/test/Analysis/reference.cpp (original)
> > +++ cfe/trunk/test/Analysis/reference.cpp Tue Jan 24 16:51:26 2012
> > @@ -1,4 +1,4 @@
> > -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core
> -analyzer-store=region -analyzer-constraints=range -verify %s
> > +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core
> -analyzer-store=region -analyzer-constraints=range -verify
> -Wno-null-dereference %s
> > // XFAIL
> >
> > typedef typeof(sizeof(int)) size_t;
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120128/221fd6d8/attachment.html>
More information about the cfe-commits
mailing list