Skip to content
  1. May 17, 2007
    • Steve Naroff's avatar
      Bug #: · 53f07dc5
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Refinements to the SourceRange/SourceLocation work.
      
      - Renamed Expr::getSourceLocation() helper function to getLocStart(). Added
      Expr::getLocEnd(). Converted all the getSourceRange() methods to use the new helpers.
      - Removed many getSourceLocation() accessors. The Expr::getLocStart() helper
      is the "right" way to get a source location. If we want to add class specific
      getters (for location), then the names should be reflective of the specific class.
      For examaple, UnaryOperator::getOpLocation(). For now, I see no reason to have these.
      - Fixed StringLiteral.
      - Start actually instantiating ParenExpr()!
      
      llvm-svn: 39453
      53f07dc5
    • Steve Naroff's avatar
      Bug #: · 509fe025
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - Added a getSourceRange() method to all subclasses of Expr.
      - Changed all the constructors and instantiators.
      - Only added SourceLocations's when necessary. For example, binary
      expression *don't* carry the operator location...it isn't
      necessary to implement getSourceRange(). On the other hand, unary
      expressions *do* carry the operator location.
      - Added trivial SourceRange value class to SourceLocation.
      
      Note: need to talk to Chris about the FIXME for StringLiteral...
      llvm-svn: 39452
      509fe025
  2. May 16, 2007
    • Steve Naroff's avatar
      Bug #: · a78fe7e3
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - Implement type checking for Sema::CheckConditionalOperands.
      - Fixed crasher in Sema::UsualUnaryConversion (incorrect use of cast<>).
      - Added a few diagnostics and started passing 2 args! (Thanks Chris!).
      
      Here's some diagnostic output that is much nicer than gcc...
      
      [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang cond.c
      cond.c:12:14: error: used type 'struct foo' where arithmetic or pointer type is required
        result = s ? 1 : 2;
                   ^
      cond.c:13:14: error: incompatible operand types ('struct foo' and 'struct bar')
        result = a ? s : s2;
                   ^
      cond.c:14:14: warning: pointer type mismatch ('struct foo *' and 'struct bar *')
        result = a ? ps : ps2;
                   ^
      cond.c:14:10: warning: assignment makes integer from pointer without a cast
        result = a ? ps : ps2;
               ^
      cond.c:15:14: error: incompatible operand types ('struct foo *' and 'struct foo')
        result = a ? ps : s;
                   ^
      cond.c:16:14: warning: pointer type mismatch ('void (*)(int)' and 'void (*)(int, int)')
        result = a ? func : func2;
                   ^
      cond.c:16:10: warning: assignment makes integer from pointer without a cast
        result = a ? func : func2;
               ^
      7 diagnostics generated.
      [dylan:~/llvm/tools/clang] admin% cc -c cond.c
      cond.c: In function 'main':
      cond.c:12: error: used struct type value where scalar is required
      cond.c:13: error: type mismatch in conditional expression
      cond.c:14: warning: pointer type mismatch in conditional expression
      cond.c:14: warning: assignment makes integer from pointer without a cast
      cond.c:15: error: type mismatch in conditional expression
      cond.c:16: warning: pointer type mismatch in conditional expression
      cond.c:16: warning: assignment makes integer from pointer without a cast
      
      llvm-svn: 39451
      a78fe7e3
    • Chris Lattner's avatar
      Remove the Sema::Diag helper that takes a type. Convert clients to use · c04bd6ae
      Chris Lattner authored
      the version that takes a string.
      
      llvm-svn: 39450
      c04bd6ae
    • Chris Lattner's avatar
      Rename type::getAsString to getAsStringInternal. Add a new · 3dc3d775
      Chris Lattner authored
      QualType::getAsString() that returns a string, which is much easier
      for clients to use.  Convert clients to use it.
      
      llvm-svn: 39449
      3dc3d775
    • Chris Lattner's avatar
      Add helper to emit two strings for a diagnostic. · d6647d3d
      Chris Lattner authored
      llvm-svn: 39448
      d6647d3d
    • Chris Lattner's avatar
      36982e43
  3. May 15, 2007
    • Steve Naroff's avatar
      Bug #: · f8a28c53
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - Unified isConstantExpr/isIntegerConstantExpr by creating a private function
      named isConstantExpr (that takes a bool to indicate the flavor). isConstantExpr
      and isIntegerConstantExpr are now inline wrapper/helper functions.
      - Fixed bug in expression based sizeof (it needed to make sure the type is constant).
      - Added Sema::CheckConditionalOperands() stub. Will add contraints in my next commit.
      
      llvm-svn: 39446
      f8a28c53
    • Steve Naroff's avatar
      Bug #: · 043d45da
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - Completed Expr::isConstantExpr() and Expr::isIntegerConstantExpr().
      - Completed Sema::ParseUnaryOp(), it lacked support for sizeof/alignof.
      - Added Sema::CheckSizeOfAlignOfOperand(), used by ParseUnaryOp/ParseSizeOfAlignOfTypeExpr.
      - Fixed a couple bugs in CheckRelationalOperands/CheckEqualityOperands (make sure extensions aren't treated as errors).
      - Changed a bunch of predicates (in BinaryOperator/UnaryOperator) to member functions (the static members weren't being used).
      - Added UnaryOperator::isIncrementDecrementOp/isSizeOfAlignOfOp.
      
      llvm-svn: 39445
      043d45da
  4. May 14, 2007
    • Steve Naroff's avatar
      Bug #: · 5dd642eb
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Some minor cleanup (comments, spec refs, simplied some expressions).
      
      llvm-svn: 39444
      5dd642eb
    • Steve Naroff's avatar
      Bug #: · 475cca0d
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Fixed a bug in Sema::CheckAddressOfOperand(). It was (incorrectly) using
      isModifiableLvalue() instead of isLvalue(). This motivated me to (finally)
      cleanup methods surrounding lsLvalue/isModifiableLvalue. Cleanup involved:
      - adding Expr::isLvalue().
      - modified Expr::isModifiableLvalue() to use Expr::isLvalue().
      - removed Type::isLvalue(), Type::isModifiableLvalue(), and
      QualType::isModifiableLvalue(). They were confusing...the respective logic
      is now a part of the Expr member functions...
      - also added some comments and spec references, since these methods are
      so central to expressions working properly.
      
      llvm-svn: 39443
      475cca0d
  5. May 13, 2007
    • Steve Naroff's avatar
      Bug #: · 094046fd
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Two bug fixes to CheckIncrementDecrementOperand:
      - removed "constantOne" usage and simply use Context.IntTy.
      - fix the last constraint check...the lvalue test needs to be on the
      expression, not the type! (duh).
      
      llvm-svn: 39442
      094046fd
  6. May 12, 2007
    • Steve Naroff's avatar
      Bug #: · 29d386c8
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Removed a couple superflous checks from typesAreCompatible. Moved the
      spec references up to a comment.
      
      llvm-svn: 39441
      29d386c8
    • Steve Naroff's avatar
      Bug #: · 3f597295
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      This check-in should finally "nail" complex pointer assignments (involving
      qualifiers, etc.).
      - Replaced pointerTypeQualifiersAlign() with CheckPointerTypesForAssignment()
      This also simplified UsualAssignmentConversions().
      - Fixed Type::pointerTypesAreCompatible() and Type::typesAreCompatible()
      to closely reflect the spec. They were (unfortunately) compensating for some of the
      missing logic in the assignment checking code.
      
      llvm-svn: 39440
      3f597295
  7. May 11, 2007
    • Steve Naroff's avatar
      Bug #: · 1f4d7272
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - Enhanced UsualAssignmentConversions() to properly handle type qualifiers on
      pointers.
      - Added helper function Sema::pointerTypeQualifiersAlign().
      - Noticed several errors improperly named "ext_" (fixed).
      - Combined structureTypesAreCompatible/unionTypesAreCompatible into
      tagTypesAreCompatible.
      - Renamed Type::getCanonicalType() to Type::getCanonicalTypeInternal(). It
      will never confuse/bite me again:-)
      - Added a couple extension diagnostics for discarded type qualifiers.
      
      llvm-svn: 39439
      1f4d7272
  8. May 09, 2007
    • Steve Naroff's avatar
      Bug #: · b8c289df
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Fix a couple bugs in ParseCallExpr().
      - check isVariadic().
      - make sure an AST isn't created if the number of args don't match but the
      types do!
      - rename "n" to something more descriptive:-)
      
      llvm-svn: 39438
      b8c289df
  9. May 08, 2007
    • Steve Naroff's avatar
      Bug #: · 8eeeb134
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - Added Sema::isConstantArrayType() and Type::isConstantSizeType().
      - Implemented type checking for "variably modified" types (i.e. VLA's).
      Added checking for file scope variables, static variables, member variables,
      and typedefs.
      - Changed Expr::isIntegerConstantExpr() to non-virtual implementation.
      Fixed bug with sizeof/alignof. Looking at the diff, I may need to
      add a check to exclude alignof.
      - Added Expr::isConstantExpr()...non-virtual, like above.
      - Added typechecking for case statements (found a bug with actions/parsing...).
      - Added several diagnostics.
      - Fixed several comments.
      Started implemented constant expression checking for arrays.
      
      llvm-svn: 39437
      8eeeb134
  10. May 07, 2007
    • Steve Naroff's avatar
      Bug #: · 63969215
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Start work on typechecking constant expressions.
      
      - Added isIntegerConstantExpr() predicate to all exprs.
      - Use the predicate to implement checking for enum constant initializers.
      - Added diagnostic.
      - Added Init slot to EnumConstantDecl class/constructor.
      
      llvm-svn: 39436
      63969215
    • Steve Naroff's avatar
      Bug #: · 35d8515b
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - Unified CheckSimpleAssignmentOperands/CheckCompoundAssignmentOperands
      into one function, named CheckAssignmentOperands. One less function to maintain.
      - Converted the unary check functions (ParseUnaryOp and friends) to have
      the same API as their binary counterparts.
      - Implemented CheckIndirectionOperand (was stubbed). While testing, noticed
      that Expr::isModifiableLvalue was incomplete (fixed and referenced draft).
      - Added constantOne instance variable to Sema.
      - Removed CheckArithmeticOperand (the code was so simple that it is now
      part of ParseUnaryOp). The name wasn't great anyway:-)
      
      llvm-svn: 39435
      35d8515b
    • Chris Lattner's avatar
      Adjust to change in MemoryBuffer interface · 776050e9
      Chris Lattner authored
      llvm-svn: 39434
      776050e9
  11. May 04, 2007
    • Steve Naroff's avatar
      Bug #: · 218bc2b3
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Implemented type checking for compound assignments (*=, /=, etc.).
      
      This encouraged me to do a fairly dramatic refactoring of the Check* functions.
      (since I wanted to reuse the existing work, rather than duplicate the logic).
      
      For example, I changed all the Check* functions to return a QualType (instead
      of returning an Expr). This had a very nice side benefit...there is now
      only one instantiation point for BinaryOperator()! (A property I've always
      wanted...separating type checking from AST building is *much* nicer). Another
      change is to remove "code" from all the Check* functions (this allowed
      me to remove the weird comment about enums/unsigned:-). Removing the
      code forced me to add a few functions, however. For example,
      
      <   ExprResult CheckAdditiveOperands( // C99 6.5.6
      <     Expr *lex, Expr *rex, SourceLocation OpLoc, unsigned OpCode);
      
      >   inline QualType CheckAdditionOperands( // C99 6.5.6
      >     Expr *lex, Expr *rex, SourceLocation OpLoc);
      >   inline QualType CheckSubtractionOperands( // C99 6.5.6
      >     Expr *lex, Expr *rex, SourceLocation OpLoc);
      
      While this isn't as terse, it more closely reflects the differences in
      the typechecking logic. For example, I disliked having to check the code again
      in CheckMultiplicativeOperands/CheckAdditiveOperands.
      
      Created the following helper functions:
      - Expr::isNullPointerConstant().
      - SemaExpr.cpp: static inline BinaryOperator::Opcode ConvertTokenKindToBinaryOpcode().
      This was purely asethetic, since ParseBinOp() is now larger. I didn't feel
      like looking at 2 huge switch statements. ParseBinOp() now avoids using
      any of the BinaryOperator predicates (since I switched to a switch statement:-)
      
      Only one regret (minor). I couldn't figure out how to avoid having two assign functions,
      CheckCompoundAssignmentOperands, CheckSimpleAssignmentOperands. Conceptually,
      the two functions make sense. Unfortunately, their implementation contains a lot of
      duplication (thought they aren't that be in the first place).
      
      llvm-svn: 39433
      218bc2b3
  12. May 03, 2007
    • Steve Naroff's avatar
      Bug #: · 17f76e04
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Work on finishing up typechecking for simple assignments (=) and function
      calls. Here is an overview:
      - implemented type checking for function calls (in Sema::ParseCallExpr).
      - refactored UsualAssignmentConversions to return the result of the conversion.
      This enum will allow all clients to emit different diagnostics based on context.
      - fixed bug in Expr::isLvalue()...it wasn't handling arrays properly. Also
      changed the name to isModifiableLvalue, which is consistent with the function on QualType.
      - Added 6 diagnostics (3 errors, 3 extensions).
      
      llvm-svn: 39432
      17f76e04
    • Steve Naroff's avatar
      Bug #: · b891de39
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      More refinements to UsualAssignmentConversions(). Added a call
      to do the UsualUnaryConversion for arrays/functions. I believe this is
      correct (but subtle). This enabled me to remove code for dealing with
      arrays/functions explictly (which more closely reflects the spec).
      
      llvm-svn: 39431
      b891de39
    • Chris Lattner's avatar
      Do not invoke objc parser actions when a top level +/- is seen, unless objc · c24278d9
      Chris Lattner authored
      is enabled.
      
      llvm-svn: 39430
      c24278d9
  13. May 02, 2007
    • Steve Naroff's avatar
      Bug #: · 9eb2465a
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Refactored assignment conversion code.
      
      - added Sema::UsualAssignmentConversions(). It will service simple
      assignment, argument passing, initialization, and return.
      - simplified Sema::CheckAssignmentOperands() using the previous function.
      
      llvm-svn: 39429
      9eb2465a
    • Steve Naroff's avatar
      Bug #: · 38a9dae3
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - implement Type::functionTypesAreCompatible().
      - fix bug in Sema::CheckAssignmentOperands(). Spec allows any pointer type
      to be assigned to _Bool.
      
      llvm-svn: 39428
      38a9dae3
    • Steve Naroff's avatar
      Bug #: · dd92b932
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Implement CheckAssignmentOperands(). This includes...
      
      - Adding 6 static member predicates to Type.
      - Adding 2 error diagnostics and 3 GCC extensions.
      - Adding a "getValue" accessor to IntegerLiteral.
      
      Still more work to do (including implement compound assignments).
      
      llvm-svn: 39427
      dd92b932
  14. Apr 29, 2007
  15. Apr 28, 2007
  16. Apr 27, 2007
    • Steve Naroff's avatar
      Bug #: · 0af91209
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - Disabled -pedantic for now (until it ignores system headers).
      - Removed convertSignedWithGreaterRankThanUnsigned() and convertFloatingRankToComplexType().
      The logic is now inlined in maxIntegerType and maxComplexType().
      - Removed getIntegerRank/getFloatingRank from the private interface. These
      are now really private helpers:-)
      - Declare maxIntegerType/maxFloatingType static. maxComplexType const.
      - Added an enum for the floating ranks.
      - Several fixed to getIntegerRank: add Bool, Char, and a clause for enums.
      
      llvm-svn: 39421
      0af91209
    • Chris Lattner's avatar
      Fix an error recovery bug, we were would issue: · da6c2ce6
      Chris Lattner authored
      enum {
              CSSM_FALSE = 0,
              CSSM_TRUE = !&CSSM_FALSE
      };
      
      t.c:4:15: error: invalid lvalue in address expression
              CSSM_TRUE = !&CSSM_FALSE
                           ^
      t.c:6:2: error: expected '}'
      };
       ^
      t.c:2:6: error: to match this '{'
      enum {
           ^
      3 diagnostics generated.
      
      
      
      We now issue:
      t.c:4:15: error: invalid lvalue in address expression
              CSSM_TRUE = !&CSSM_FALSE
                           ^
      1 diagnostics generated.
      
      llvm-svn: 39420
      da6c2ce6
    • Chris Lattner's avatar
      Generalize the skipping logic to allow skipping until any one of a set of · 83b94e09
      Chris Lattner authored
      tokens is found.
      
      llvm-svn: 39419
      83b94e09
    • Steve Naroff's avatar
      Bug #: · e471889d
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      More typechecking, refactoring...
      - Implemented the following routines...CheckAdditiveOperands,
      CheckCommaOperands, CheckLogicalOperands.
      - Added maxComplexType, maxFloatingType, & maxIntegerType to ASTContext.
      Ranking helper functions moved to ASTContext as well (they are private:-)
      - Simplified UsualArithmeticConversions using the new ASTContext hooks.
      - Fixed isAssignmentOp()...is was preventing comma exprs from ever being created:-(
      - Changed a GCC compat extension to truly be an extension (and turned extensions
      on by default). This now produces a warning by default.
      
      llvm-svn: 39418
      e471889d
  17. Apr 26, 2007
    • Steve Naroff's avatar
      Bug #: · 1cbdf71d
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Carbon.h now compiles without error!
      
      All 14 errors were the result of two Type predicates (isArithmeticType
      and isScalarType) not allowing enums. Note: this could have been avoided by rigorously using
      isIntegerType. For efficiency, I decided not to have predicates use predicates.
      
      Still more work to do, however this is a nice milestone considering how much "work" is being done...
      
      llvm-svn: 39417
      1cbdf71d
    • Steve Naroff's avatar
      Bug #: · ae4143ea
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Misc. changes driven by getting "carbon.h" to compile...
      
      - Added ParseCharacterConstant() hook to Action, Sema, etc.
      - Added CheckAssignmentOperands() & CheckCommaOperands() to Sema.
      - Added CharacterLiteral AST node.
      - Fixed CallExpr instantiation - install the correct type.
      - Install a bunch of temp types and annotate with FIXME's.
      
      llvm-svn: 39416
      ae4143ea
  18. Apr 25, 2007
    • Steve Naroff's avatar
      Bug #: · 82ceca59
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Implement FIXME's for signed/unsigned operands in UsualArithmeticConversions()...
      - Added GetIntegerRank() and used it in the appropriate places.
      - Added ConvertSignedWithGreaterRankThanUnsigned(), with a FIXME.
      Misc...converted a bunch of static_cast usage to dyn_cast (in Type.cpp)
      
      A and handled signed/unsigned combos.
      
      llvm-svn: 39415
      82ceca59
    • Steve Naroff's avatar
      Bug #: · f633d091
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      A bunch of "small" changes...
      - Fixed a bug in ConvertFloatingRankToComplexType() that rendered it useless.
      ASTContext was being copied by default (as the result of declaring the argument
      incorrectly). Chris gave me the magic potion to disallow this in ASTContext.
      - Removed a tab:-)
      - Added some much needed comments to the float/complex promotion madness.
      - Improved some aesthetics (based on code review w/Chris).
      
      llvm-svn: 39414
      f633d091
Loading