[cfe-commits] r130667 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/Expr.cpp lib/Serialization/ASTReaderStmt.cpp

Chandler Carruth chandlerc at gmail.com
Sun May 1 14:55:21 PDT 2011


Author: chandlerc
Date: Sun May  1 16:55:21 2011
New Revision: 130667

URL: http://llvm.org/viewvc/llvm-project?rev=130667&view=rev
Log:
Several cosmetic changes, no functionality changed.

Mostly trailing whitespace so that me editor nuking it doesn't muddy the
waters of subsequent commits that do change functionality.

Also nukes a stray statement that was harmless but redundant that
I introduced in r130666.

Modified:
    cfe/trunk/include/clang/AST/Expr.h
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=130667&r1=130666&r2=130667&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun May  1 16:55:21 2011
@@ -697,20 +697,18 @@
   /// embedded in D.
   DeclarationNameLoc DNLoc;
 
-  /// \brief Retrieve the qualifier that preceded the declaration name, if any.
-  NameQualifier *getNameQualifier() {
-    if (!hasQualifier())
-      return 0;
-
-    return reinterpret_cast<NameQualifier *> (this + 1);
+  /// \brief Helper to retrieve the optional NameQualifier.
+  NameQualifier &getNameQualifier() {
+    assert(hasQualifier());
+    return *reinterpret_cast<NameQualifier *>(this + 1);
   }
 
-  /// \brief Retrieve the qualifier that preceded the declaration name, if any.
-  const NameQualifier *getNameQualifier() const {
+  /// \brief Helper to retrieve the optional NameQualifier.
+  const NameQualifier &getNameQualifier() const {
     return const_cast<DeclRefExpr *>(this)->getNameQualifier();
   }
 
-  DeclRefExpr(NestedNameSpecifierLoc QualifierLoc, 
+  DeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
               ValueDecl *D, SourceLocation NameLoc,
               const TemplateArgumentListInfo *TemplateArgs,
               QualType T, ExprValueKind VK);
@@ -723,7 +721,7 @@
   /// \brief Construct an empty declaration reference expression.
   explicit DeclRefExpr(EmptyShell Empty)
     : Expr(DeclRefExprClass, Empty) { }
-  
+
   /// \brief Computes the type- and value-dependence flags for this
   /// declaration reference expression.
   void computeDependence();
@@ -756,7 +754,7 @@
                                   bool HasQualifier, 
                                   bool HasExplicitTemplateArgs,
                                   unsigned NumTemplateArgs);
-  
+
   ValueDecl *getDecl() { return D; }
   const ValueDecl *getDecl() const { return D; }
   void setDecl(ValueDecl *NewD) { D = NewD; }
@@ -772,41 +770,42 @@
   /// \brief Determine whether this declaration reference was preceded by a
   /// C++ nested-name-specifier, e.g., \c N::foo.
   bool hasQualifier() const { return DeclRefExprBits.HasQualifier; }
-  
-  /// \brief If the name was qualified, retrieves the nested-name-specifier 
+
+  /// \brief If the name was qualified, retrieves the nested-name-specifier
   /// that precedes the name. Otherwise, returns NULL.
   NestedNameSpecifier *getQualifier() const {
     if (!hasQualifier())
       return 0;
-    
-    return getNameQualifier()->QualifierLoc.getNestedNameSpecifier();
+
+    return getNameQualifier().QualifierLoc.getNestedNameSpecifier();
   }
 
-  /// \brief If the name was qualified, retrieves the nested-name-specifier 
+  /// \brief If the name was qualified, retrieves the nested-name-specifier
   /// that precedes the name, with source-location information.
   NestedNameSpecifierLoc getQualifierLoc() const {
     if (!hasQualifier())
       return NestedNameSpecifierLoc();
-    
-    return getNameQualifier()->QualifierLoc;
+
+    return getNameQualifier().QualifierLoc;
   }
 
+  /// \brief Determines whether this declaration reference was followed by an
+  /// explict template argument list.
   bool hasExplicitTemplateArgs() const {
     return DeclRefExprBits.HasExplicitTemplateArgs;
   }
-  
+
   /// \brief Retrieve the explicit template argument list that followed the
   /// member template name.
   ExplicitTemplateArgumentList &getExplicitTemplateArgs() {
     assert(hasExplicitTemplateArgs());
-
     if (!hasQualifier())
       return *reinterpret_cast<ExplicitTemplateArgumentList *>(this + 1);
-    
+
     return *reinterpret_cast<ExplicitTemplateArgumentList *>(
-                                                      getNameQualifier() + 1);
+      &getNameQualifier() + 1);
   }
-  
+
   /// \brief Retrieve the explicit template argument list that followed the
   /// member template name.
   const ExplicitTemplateArgumentList &getExplicitTemplateArgs() const {
@@ -820,50 +819,50 @@
     if (!hasExplicitTemplateArgs()) return 0;
     return &getExplicitTemplateArgs();
   }
-  
+
   /// \brief Copies the template arguments (if present) into the given
   /// structure.
   void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const {
     if (hasExplicitTemplateArgs())
       getExplicitTemplateArgs().copyInto(List);
   }
-  
+
   /// \brief Retrieve the location of the left angle bracket following the
   /// member name ('<'), if any.
   SourceLocation getLAngleLoc() const {
     if (!hasExplicitTemplateArgs())
       return SourceLocation();
-    
+
     return getExplicitTemplateArgs().LAngleLoc;
   }
-  
+
   /// \brief Retrieve the template arguments provided as part of this
   /// template-id.
   const TemplateArgumentLoc *getTemplateArgs() const {
     if (!hasExplicitTemplateArgs())
       return 0;
-    
+
     return getExplicitTemplateArgs().getTemplateArgs();
   }
-  
+
   /// \brief Retrieve the number of template arguments provided as part of this
   /// template-id.
   unsigned getNumTemplateArgs() const {
     if (!hasExplicitTemplateArgs())
       return 0;
-    
+
     return getExplicitTemplateArgs().NumTemplateArgs;
   }
-  
+
   /// \brief Retrieve the location of the right angle bracket following the
   /// template arguments ('>').
   SourceLocation getRAngleLoc() const {
     if (!hasExplicitTemplateArgs())
       return SourceLocation();
-    
+
     return getExplicitTemplateArgs().RAngleLoc;
   }
-  
+
   static bool classof(const Stmt *T) {
     return T->getStmtClass() == DeclRefExprClass;
   }
@@ -871,7 +870,7 @@
 
   // Iterators
   child_range children() { return child_range(); }
-  
+
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
 };

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=130667&r1=130666&r2=130667&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sun May  1 16:55:21 2011
@@ -281,11 +281,8 @@
   : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false),
     D(D), Loc(NameLoc) {
   DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0;
-  if (QualifierLoc) {
-    DeclRefExprBits.HasQualifier = 1;
-    NameQualifier *NQ = getNameQualifier();
-    NQ->QualifierLoc = QualifierLoc;
-  }
+  if (QualifierLoc)
+    getNameQualifier().QualifierLoc =  QualifierLoc;
 
   DeclRefExprBits.HasExplicitTemplateArgs = TemplateArgs ? 1 : 0;
   if (TemplateArgs) {
@@ -302,10 +299,8 @@
   : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false),
     D(D), Loc(NameInfo.getLoc()), DNLoc(NameInfo.getInfo()) {
   DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0;
-  if (QualifierLoc) {
-    NameQualifier *NQ = getNameQualifier();
-    NQ->QualifierLoc = QualifierLoc;
-  }
+  if (QualifierLoc)
+    getNameQualifier().QualifierLoc =  QualifierLoc;
 
   DeclRefExprBits.HasExplicitTemplateArgs = TemplateArgs ? 1 : 0;
   if (TemplateArgs)

Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=130667&r1=130666&r2=130667&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Sun May  1 16:55:21 2011
@@ -432,7 +432,7 @@
     NumTemplateArgs = Record[Idx++];
 
   if (E->hasQualifier())
-    E->getNameQualifier()->QualifierLoc
+    E->getNameQualifier().QualifierLoc
       = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
 
   if (E->hasExplicitTemplateArgs())





More information about the cfe-commits mailing list