[cfe-commits] r148624 - in /cfe/trunk: include/clang/Sema/Sema.h lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaType.cpp

Eli Friedman eli.friedman at gmail.com
Fri Jan 20 20:44:06 PST 2012


Author: efriedma
Date: Fri Jan 20 22:44:06 2012
New Revision: 148624

URL: http://llvm.org/viewvc/llvm-project?rev=148624&view=rev
Log:
Fix some comments relating to ExpressionEvaluationContexts.  Get rid of a couple of uses of ConstantEvaluated which don't make sense.


Modified:
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=148624&r1=148623&r2=148624&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jan 20 22:44:06 2012
@@ -521,9 +521,9 @@
     /// run time.
     Unevaluated,
 
-    /// \brief The current expression and its subexpressions occur within a
-    /// constant expression. Such a context is not potentially-evaluated in
-    /// C++98, but is potentially-evaluated in C++11.
+    /// \brief The current context is "potentially evaluated" in C++11 terms,
+    /// but the expression is evaluated at compile-time (like the values of
+    /// cases in a switch statment).
     ConstantEvaluated,
 
     /// \brief The current expression is potentially evaluated at run time,

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=148624&r1=148623&r2=148624&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Jan 20 22:44:06 2012
@@ -10751,8 +10751,7 @@
   // not have a vtable.
   if (!Class->isDynamicClass() || Class->isDependentContext() ||
       CurContext->isDependentContext() ||
-      ExprEvalContexts.back().Context == Unevaluated ||
-      ExprEvalContexts.back().Context == ConstantEvaluated)
+      ExprEvalContexts.back().Context == Unevaluated)
     return;
 
   // Try to insert this class into the map.

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=148624&r1=148623&r2=148624&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jan 20 22:44:06 2012
@@ -9477,21 +9477,16 @@
   switch (ExprEvalContexts.back().Context) {
     case Unevaluated:
       // We are in an expression that is not potentially evaluated; do nothing.
+      // (Depending on how you read the standard, we actually do need to do
+      // something here for null pointer constants, but the standard's
+      // definition of a null pointer constant is completely crazy.)
       return;
 
     case ConstantEvaluated:
-      // We are in an expression that will be evaluated during translation; in
-      // C++11, we need to define any functions which are used in case they're
-      // constexpr, whereas in C++98, we only need to define static data members
-      // of class templates.
-      if (!getLangOptions().CPlusPlus ||
-          (!getLangOptions().CPlusPlus0x && !isa<VarDecl>(D)))
-        return;
-      break;
-
     case PotentiallyEvaluated:
-      // We are in a potentially-evaluated expression, so this declaration is
-      // "used"; handle this below.
+      // We are in a potentially evaluated expression (or a constant-expression
+      // in C++03); we need to do implicit template instantiation, implicitly
+      // define class members, and mark most declarations as used.
       break;
 
     case PotentiallyEvaluatedIfUsed:
@@ -9616,6 +9611,8 @@
     // Keep track of used but undefined variables.  We make a hole in
     // the warning for static const data members with in-line
     // initializers.
+    // FIXME: The hole we make for static const data members is too wide!
+    // We need to implement the C++11 rules for odr-used.
     if (Var->hasDefinition() == VarDecl::DeclarationOnly
         && Var->getLinkage() != ExternalLinkage
         && !(Var->isStaticDataMember() && Var->hasInit())) {

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=148624&r1=148623&r2=148624&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Jan 20 22:44:06 2012
@@ -1059,8 +1059,7 @@
 
   // If we are in an unevaluated context, like sizeof, skip adding a
   // qualification.
-  } else if (S.ExprEvalContexts.back().Context == Sema::Unevaluated ||
-             S.ExprEvalContexts.back().Context == Sema::ConstantEvaluated) {
+  } else if (S.ExprEvalContexts.back().Context == Sema::Unevaluated) {
     return type;
 
   // If that failed, give an error and recover using __autoreleasing.





More information about the cfe-commits mailing list