[cfe-commits] r75485 - in /cfe/trunk: include/clang/AST/Type.h lib/Sema/SemaExpr.cpp

Steve Naroff snaroff at apple.com
Mon Jul 13 12:07:01 PDT 2009


Author: snaroff
Date: Mon Jul 13 14:06:52 2009
New Revision: 75485

URL: http://llvm.org/viewvc/llvm-project?rev=75485&view=rev
Log:

- Improve comment for Type::getPointeeType().
- Remove a couple redundant casts/returns.
- Fix 80 column violations for all getAsStringInternal() methods.


Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=75485&r1=75484&r2=75485&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Jul 13 14:06:52 2009
@@ -467,8 +467,8 @@
   /// This method should never be used when type qualifiers are meaningful.
   const Type *getArrayElementTypeNoTypeQual() const;
   
-  /// getPointeeType - If this is a pointer or ObjC object pointer, this
-  /// returns the respective pointee.
+  /// getPointeeType - If this is a pointer, ObjC object pointer, or block
+  /// pointer, this returns the respective pointee.
   QualType getPointeeType() const;
   
   /// getDesugaredType - Return the specified type with any "sugar" removed from
@@ -505,7 +505,8 @@
 
   QualType getCanonicalTypeInternal() const { return CanonicalType; }
   void dump() const;
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const = 0;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const = 0;
   static bool classof(const Type *) { return true; }
 };
 
@@ -538,7 +539,8 @@
   QualType::GCAttrTypes getObjCGCAttr() const { return GCAttrType; }
   unsigned getAddressSpace() const { return AddressSpace; }
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
   
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, getBaseType(), AddressSpace, GCAttrType);
@@ -600,7 +602,8 @@
   Kind getKind() const { return TypeKind; }
   const char *getName(const LangOptions &LO) const;
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
   
   static bool classof(const Type *T) { return T->getTypeClass() == Builtin; }
   static bool classof(const BuiltinType *) { return true; }
@@ -621,7 +624,8 @@
   bool isSigned() const { return Signed; }
   const char *getName() const;
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
   
   static bool classof(const Type *T) { return T->getTypeClass() == FixedWidthInt; }
   static bool classof(const FixedWidthIntType *) { return true; }
@@ -640,7 +644,8 @@
 public:
   QualType getElementType() const { return ElementType; }
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
     
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, getElementType());
@@ -664,7 +669,8 @@
   friend class ASTContext;  // ASTContext creates these.
 public:
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
   
   QualType getPointeeType() const { return PointeeType; }
 
@@ -695,7 +701,8 @@
   // Get the pointee type. Pointee is required to always be a function type.
   QualType getPointeeType() const { return PointeeType; }
 
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
     
   void Profile(llvm::FoldingSetNodeID &ID) {
       Profile(ID, getPointeeType());
@@ -745,7 +752,8 @@
   }
   friend class ASTContext; // ASTContext creates these
 public:
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   static bool classof(const Type *T) {
     return T->getTypeClass() == LValueReference;
@@ -761,7 +769,8 @@
   }
   friend class ASTContext; // ASTContext creates these
 public:
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   static bool classof(const Type *T) {
     return T->getTypeClass() == RValueReference;
@@ -789,7 +798,8 @@
 
   const Type *getClass() const { return Class; }
 
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, getPointeeType(), getClass());
@@ -877,7 +887,8 @@
   friend class ASTContext;  // ASTContext creates these.
 public:
   const llvm::APInt &getSize() const { return Size; }
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
   
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, getElementType(), getSize(), 
@@ -976,7 +987,8 @@
     : ArrayType(IncompleteArray, et, can, sm, tq) {}
   friend class ASTContext;  // ASTContext creates these.
 public:
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   static bool classof(const Type *T) { 
     return T->getTypeClass() == IncompleteArray; 
@@ -1037,7 +1049,8 @@
   SourceLocation getLBracketLoc() const { return Brackets.getBegin(); }
   SourceLocation getRBracketLoc() const { return Brackets.getEnd(); }
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
   
   static bool classof(const Type *T) { 
     return T->getTypeClass() == VariableArray; 
@@ -1087,7 +1100,8 @@
   SourceLocation getLBracketLoc() const { return Brackets.getBegin(); }
   SourceLocation getRBracketLoc() const { return Brackets.getEnd(); }
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
   
   static bool classof(const Type *T) { 
     return T->getTypeClass() == DependentSizedArray; 
@@ -1127,7 +1141,8 @@
   QualType getElementType() const { return ElementType; }
   SourceLocation getAttributeLoc() const { return loc; }
 
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
   
   static bool classof(const Type *T) { 
     return T->getTypeClass() == DependentSizedExtVector; 
@@ -1161,7 +1176,8 @@
   QualType getElementType() const { return ElementType; }
   unsigned getNumElements() const { return NumElements; } 
 
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
   
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, getElementType(), getNumElements(), getTypeClass());
@@ -1235,7 +1251,8 @@
       return unsigned(idx-1) < NumElements;
     return false;
   }
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   static bool classof(const Type *T) { 
     return T->getTypeClass() == ExtVector; 
@@ -1291,7 +1308,8 @@
 public:
   // No additional state past what FunctionType provides.
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, getResultType());
@@ -1398,7 +1416,8 @@
     return exception_begin() + NumExceptions;
   }
 
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   static bool classof(const Type *T) {
     return T->getTypeClass() == FunctionProto;
@@ -1434,7 +1453,8 @@
   /// looking through the typedefs for B will give you "const volatile A".
   QualType LookThroughTypedefs() const;
     
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   static bool classof(const Type *T) { return T->getTypeClass() == Typedef; }
   static bool classof(const TypedefType *) { return true; }
@@ -1448,7 +1468,8 @@
 public:
   Expr *getUnderlyingExpr() const { return TOExpr; }
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   static bool classof(const Type *T) { return T->getTypeClass() == TypeOfExpr; }
   static bool classof(const TypeOfExprType *) { return true; }
@@ -1465,7 +1486,8 @@
 public:
   QualType getUnderlyingType() const { return TOType; }
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   static bool classof(const Type *T) { return T->getTypeClass() == TypeOf; }
   static bool classof(const TypeOfType *) { return true; }
@@ -1514,7 +1536,8 @@
   bool isBeingDefined() const { return decl.getInt(); }
   void setBeingDefined(bool Def) { decl.setInt(Def? 1 : 0); }
 
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   static bool classof(const Type *T) { 
     return T->getTypeClass() >= TagFirst && T->getTypeClass() <= TagLast;
@@ -1597,7 +1620,8 @@
   bool isParameterPack() const { return ParameterPack; }
   IdentifierInfo *getName() const { return Name; }
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, Depth, Index, ParameterPack, Name);
@@ -1683,7 +1707,8 @@
   /// \precondition @c isArgType(Arg)
   const TemplateArgument &getArg(unsigned Idx) const;
 
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, Template, getArgs(), NumArgs);
@@ -1726,7 +1751,8 @@
   /// \brief Retrieve the type named by the qualified-id.
   QualType getNamedType() const { return NamedType; }
 
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, NNS, NamedType);
@@ -1802,7 +1828,8 @@
     return Name.dyn_cast<const TemplateSpecializationType *>();
   }
 
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
 
   void Profile(llvm::FoldingSetNodeID &ID) {
     Profile(ID, NNS, Name);
@@ -1854,7 +1881,8 @@
   /// interface type, or 0 if there are none.
   inline unsigned getNumProtocols() const;
   
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
   static bool classof(const Type *T) { 
     return T->getTypeClass() == ObjCInterface ||
            T->getTypeClass() == ObjCQualifiedInterface; 
@@ -1962,7 +1990,8 @@
   qual_iterator qual_begin() const { return Protocols.begin(); }
   qual_iterator qual_end() const   { return Protocols.end(); }
                                      
-  virtual void getAsStringInternal(std::string &InnerString, const PrintingPolicy &Policy) const;
+  virtual void getAsStringInternal(std::string &InnerString, 
+                                   const PrintingPolicy &Policy) const;
   
   void Profile(llvm::FoldingSetNodeID &ID);
   static void Profile(llvm::FoldingSetNodeID &ID, 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=75485&r1=75484&r2=75485&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jul 13 14:06:52 2009
@@ -4278,8 +4278,6 @@
           !Context.typesAreCompatible(lType, rType)) {
         Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers)
           << lType << rType << lex->getSourceRange() << rex->getSourceRange();
-        ImpCastExprToType(rex, lType);
-        return ResultTy;
       }
       ImpCastExprToType(rex, lType);
       return ResultTy;
@@ -4293,8 +4291,6 @@
         if (!ObjCQualifiedIdTypesAreCompatible(lType, rType, true))
           Diag(Loc, diag::warn_incompatible_qualified_id_operands)
             << lType << rType << lex->getSourceRange() << rex->getSourceRange();
-        ImpCastExprToType(rex, lType);
-        return ResultTy;
       }
       ImpCastExprToType(rex, lType);
       return ResultTy;





More information about the cfe-commits mailing list