Skip to content
  1. 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
    • 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
  2. 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
  3. 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
    • Steve Naroff's avatar
      Bug #: · b01bbe3e
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Refactored code that deals with float/complex conversions (the previous commit).
      
      - Removed 6 predicates that identify the built-in float/complex types.
      - Added two helper functions GetFloatingRank() & ConvertFloatingRankToComplexType().
      At present, these are static functions in SemaExpr.cpp. Conceptually, they would be nice
      to move to Type, however there are layering problems with that (i.e. no ASTContext).
      Another possibility is to move them to ASTContext?
      - Simplified the logic in UsualArithmeticConversions() considerably.
      
      llvm-svn: 39413
      b01bbe3e
  4. Apr 24, 2007
    • Steve Naroff's avatar
      Bug #: · bf223ba1
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      -Lot's of detail work in UsualArithmeticConversion(). Needed to expand
      the code for dealing with floating types. This code still has a couple
      of FIXME's and could be refactored a bit.
      -Added a bunch of Type predicates to simplify the float conversions.
      Used the opportunity to convert a bunch of predicates to dyn_cast (it's cleaner
      when just dealing with Builtin types).
      
      llvm-svn: 39412
      bf223ba1
    • Steve Naroff's avatar
      Bug #: · 1926c836
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Lot's of changes related to type checking binary expressions.
      - Changed the name/proto of ImplicitConversion. It is now named UsualUnaryConversion - it takes a
      type and returns a type. This allowed me to remove the explicit node creation for array/function->pointer conversions.
      - Added function UsualArithmeticConversions().
      - Changed all the "Check" functions for binary ops. They use the new "Usual" functions above.
      - new predicates on Type, isSignedIntegerType()/isUnsignedIntegerType().
      - moved getDecl() out of the Sema class. It is now a static helper function in SemaExpr.cpp. It was also renamed getPrimaryDeclaration().
      - Added CheckArithmeticOperand() for consistency with the other unary "Check" functions.
      
      Should finish up the binary expressions tomorrow...with a small number of "FIXME's"
      
      llvm-svn: 39411
      1926c836
  5. Apr 21, 2007
    • Steve Naroff's avatar
      Bug #: · 5c10d4ba
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Start hacking on binary ops...
      Important bug fix...was ignoring the return value from ImplicitConversion.
      This didn't bother the type checking logic, however the AST was malformed.
      
      llvm-svn: 39410
      5c10d4ba
    • Steve Naroff's avatar
      Bug #: · 4b7ce03f
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - Added Type::isPromotableIntegerType().
      - The unary operators are now largely complete (Sema::ParseUnaryOp and friends).
      - Implemented ImplicitConversion hook (was a stub).
      
      llvm-svn: 39409
      4b7ce03f
  6. Apr 20, 2007
    • Steve Naroff's avatar
      Bug #: · 4750051e
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Continue working on type checking for unary operators. Added:
      
      - Two 3 private functions to Sema: CheckAddressOfOperand(), CheckIndirectionOperand(),
      and getDecl().
      - Added Expr::isLvalue() - it was needed for CheckAddressOfOperand(). It will
      also be needed for ++/-- and the assignment operators.
      - Added a couple diagnostics for invalid lvalues (for & of).
      
      llvm-svn: 39408
      4750051e
  7. Apr 06, 2007
    • Steve Naroff's avatar
      Bug #: · e5aa9be0
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      -Changed the name of TypeRef to QualType. Many diffs.
      -Changed the QualType constructor to require Quals be passed. This makes the code a bit
      more verbose, however will make the code easier to work on. Given the complexity
      of types, this should help spot bogosities.
      -Changed the Expr constructor to require a QualType. Same motivation.
      
      llvm-svn: 39395
      e5aa9be0
  8. Apr 05, 2007
    • Steve Naroff's avatar
      Bug #: · d50c88e4
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Fix "FIXME: does this lose qualifiers from the typedef??" in ASTContext::getTypedefType().
      
      This change was fairly pervasive...nevertheless, here are the highlights:
      - Change the type of Type::CanonicalType to TypeRef (was "Type *").
      - Change the implementation of TypeRef::getCanonicalType() to work for typedefs.
      - Make the implementation of Type::getCanonicalType private (only TypeRef should access). This
      will force clients to use TypeRef::getCanonicalType (the correct version of the function). Since
      TypeRef overloads "->", it was very easy to fall into this bug...
      - Changed many references of "Type *" to "TypeRef"...when the raw type pointer is required, use t.getTypePtr().
      - Changed all the *Type classes to take a TypeRef.
      - Made the Type constructor protected (cleanup).
      - Removed function Expr::getType().
      - Convert functions in SemaExpr to use the above support. This fixed the "const" bug I was originally investigating.
      
      I will follow this check-in up with a rename of TypeRef->QualType. I will also make sure the constructor does not default to 0 (which can lead to broken code...).
      
      llvm-svn: 39394
      d50c88e4
  9. Apr 04, 2007
    • Steve Naroff's avatar
      Bug #: · 46ba1eba
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - Typechecking for ++/-- not operating on canonical type (fixed).
      - Many changes to Decl.h...
      -- Changed ObjectDecl->ValueDecl.
      -- ValueDecl doesn't define a storage class. The storage class is now
      defined by VarDecl/FunctionDecl. EnumConstant decls don't need a storage class.
      -- FieldDecl now inherits directly from Decl (it is not a value).
      - Changed SemaExpr to use the new Decl.h. Also added a couple diagnostics for
      bogus storage class usage. For example:
      z.c:6:10: error: illegal storage class on function
      auto int func();
               ^
      z.c:7:14: error: illegal storage class on file-scoped variable
      register int b;
                   ^
      
      llvm-svn: 39379
      46ba1eba
  10. Apr 03, 2007
    • Steve Naroff's avatar
      Bug #: · 0f6256d0
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      declare getSizeType() const and fix typo in comment...
      
      llvm-svn: 39376
      0f6256d0
    • Steve Naroff's avatar
      Bug #: · 7840336c
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Avoid including "clang/AST/Expr.h" in Sema.h just to access
      UnaryOperator::Opcode. While the inclusion wasn't objectionable in terms
      of layering, it is nice to keep the inclusions as modest as possible.
      
      llvm-svn: 39375
      7840336c
    • Steve Naroff's avatar
      Bug #: · 92e30f8c
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Incorporate code review feedback from Chris...
      - minor restructure of ParseMemberReferenceExpr logic. The last statement
      is now the instantiation of the AST node (which I like a lot and will conform
      to throughout Sema).
      - declare StmtClassNameTable const.
      - reword an error diagnostic.
      - install the correct type for ParseSizeOfAlignOfTypeExpr. Added hook in
      ASTContext. For now, simply return Context.UnsignedLongTy. Added a FIXME
      to revisit (i.e. compute using TargetInfo).
      
      llvm-svn: 39374
      92e30f8c
  11. Apr 02, 2007
    • Steve Naroff's avatar
      Bug #: · ef2ab6a5
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Add three new classes to Decl.h: BlockVarDecl, FileVarDecl, and ParmVarDecl.
      
      Made the constructor to VarDecl protected, to indicate it is "abstract".
      
      Reorganized the Decl::Kind enum to allow us to add ObjectDecls/TypeDecls with
      minimal breakage.  In the process, realized the isa support for ObjectDecl was already broken (so
      the reorg paid for itself already:-) The range check should also be more efficient...
      
      llvm-svn: 39373
      ef2ab6a5
  12. Apr 01, 2007
    • Steve Naroff's avatar
      Bug #: · fc49d67a
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - Finished up incomplete type analysis for varibles (in Sema::ParseDeclarator()).
      - Added many spec refs, since this area is confusing (for top level decls
      in particular).
      - Added a FIXME to MergeVarDecl()...it needs to be taught about tentative
      definitions. As a result, we currently issue some bogus diagnostics.
      
      llvm-svn: 39372
      fc49d67a
    • Steve Naroff's avatar
      Bug #: · ca8f7128
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      - ParseMemberReferenceExpr wasn't operating on the canonical type. From
      now on, I will make sure the prologue to each Parse/Check function has
      both the qualified type and the canonical type.
      - More refinements to ParseDeclarator. It was allowing variable declarations
      to incomplete types (e.g. void, struct foo, where foo wasn't defined).
      
      llvm-svn: 39371
      ca8f7128
  13. Mar 31, 2007
    • Steve Naroff's avatar
      Bug #: · 95af013c
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Incorporate feedback from Chris (on the last check-in).
      - added a shared hook for pre/post ++/-- CheckIncrementDecrementOperand().
      - handle invalid arithmetic on incomplete types (void *, struct foo *, where the
      body isn't in scope). Added a diagnostic for this case.
      - added some comments and C99 annotations.
      - Sema.h now includes Expr.h. I'd prefer not to, however it doesn't break
      any layering.
      
      llvm-svn: 39370
      95af013c
  14. Mar 30, 2007
    • Steve Naroff's avatar
      Bug #: · bc2f0993
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Implement ++/-- typechecking for pre/post unary expressions. This includes:
      
      - added isLvalue, isModifiableLvalue (on TypeRef, Type, and RecordType).
      - added isRealType, isRealFloatingType, isComplexType.
      - hacked Diag to take a TypeRef (I was sick of writing the 2 line "setup":-)
      In addition, this will likely lead to less bugs...I already had written code
      that was doing a getAsString on "Type" (which is wrong...since it doesn't include
      any qualifiers).
      - Changed UnaryOperator to take a TypeRef...pass it the right stuff.
      - Removed redundant ternary expressions in several predicates.
      - A couple diagnostics.
      
      llvm-svn: 39369
      bc2f0993
  15. Mar 28, 2007
    • Steve Naroff's avatar
      Bug #: · c1aadb17
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Finish up Sema::ParseArraySubscriptExpr. This involved:
      - adding a couple predicates to Type.h (isObjectType, isDerivedType).
      - added a diagnostic for subscripting non-object types (e.g. void (*)()).
      - pass the correct result type...a minor detail:-)
      - added some spec references to Type.h
      
      llvm-svn: 39368
      c1aadb17
  16. Mar 27, 2007
    • Steve Naroff's avatar
      Bug #: · d9e7bd46
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Make an error diagnosic a bit more expression (in Sema::GetTypeForDeclarator)
      
      llvm-svn: 39367
      d9e7bd46
    • Steve Naroff's avatar
      Bug #: · bc57d0fe
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Finish up fixes to Sema::GetTypeForDeclarator(). The typechecking should
      now conform to the standard.
      
      llvm-svn: 39366
      bc57d0fe
    • Steve Naroff's avatar
      Bug #: · 06deba91
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Fix a couple bugs in Sema::GetTypeForDeclarator(). Need to disallow:
      - void arrayOfFunctions[3]()
      - void arrayOfVoids[3]
      Need to talk to Chris about the return value...
      
      llvm-svn: 39365
      06deba91
    • Steve Naroff's avatar
      Bug #: · cc321429
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Finish up Sema::ParseMemberReferenceExpr. This involved:
      - added a getMember() function to RecordDecl.
      - added stronger typing for "Members" (from Decl->FieldDecl).
      - added a dignostic for members not found.
      - changed MemberExpr to install the correct TypeRef.
      - In general, simplified and cleaned up the routing.
      
      llvm-svn: 39364
      cc321429
  17. Mar 26, 2007
  18. Mar 23, 2007
    • Steve Naroff's avatar
      Bug #: · f1e53698
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      
      Type Checking...round 2. This checkin "breaks" parsing carbon.h. I imagine
      that this will be true for the next week or so. Nevertheless, this round of
      changes includes the following:
      
      - Hacked various Expr classes to pass the appropriate TypeRef. Still have
      a few more classes to touch.
      - Implement type checking for ParseArraySubscriptExpr and ParseMemberReferenceExpr.
      - Added a debug hook to derive the class name for Stmt/Expr nodes. Currently a
      linear search...could easily optimize if important.
      - Changed the name of TaggedType->TagType. Now we have TagType and TagDecl (which
      are easier to remember).
      - Fixed a bug in StringLiteral conversion I did a couple weeks ago. hadError was
      not initialized (oops).
      - changed Sema::Diag to return true. This streamlines the type checking code
      considerably.
      - Added many diagnositics.
      
      This should be it!
      
      llvm-svn: 39361
      f1e53698
  19. Mar 21, 2007
    • Steve Naroff's avatar
      Bug #: · 26c8ea5f
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Implement type checking. First round of changes are:
      - Added predicates to Type.
      - Added predicates to BinExpr.
      - Added Check hooks that model the categories for Binary ops.
      - Added TypeRef to Expr. Will lazily eval subclasses...
      - Misc bug fixes/cleanups.
      
      llvm-svn: 39360
      26c8ea5f
  20. Mar 16, 2007
    • Steve Naroff's avatar
      Bug #: · 97035855
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Down to 0 warning/errors for Carbon.h. Also made a couple trivial name
      changes...
      
      llvm-svn: 39358
      97035855
    • Steve Naroff's avatar
      Bug #: · 6fbf0dcb
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      carbon.h looking good! Only 1 warning left...no parse errors!
      
      This fixes 3 bugs...
      - A couple tricky bugs with type canonicalization. Nested typedef's  weren't being
      handled properly. For example, the following didn't work:
      
      typdef int __darwin_pid_t;
      typedef __darwin_pid_t pid_t;
      
      int getpgid(pid_t);
      int getpgid(int);
      
      - The storage class wasn't being preserved. As a result, Sema was complaining
      about the  following:
      
      extern char *foo;
      char *foo;
      
      - various built-ins weren't registered...resulting in spurious warnings.
      
      llvm-svn: 39357
      6fbf0dcb
  21. Mar 14, 2007
    • Steve Naroff's avatar
      Bug #: · 3273c228
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      This is a "small" checkin.  #include_next wasn't working properly on
      Leopard. This is because the driver has some hard coded paths that
      don't work on Leopard. The real fix is to derive them, however I don't
      think we need to solve this now. At this point, anyone working on clang
      should be able to use Leopard. This fix removed 11 errors processing
      "carbon.h". The bug that bubbles up to the top is in MergeFunctionDecl().
      As part of digging into this part of Sema, I rearranged some methods
      (and changed the visibility).
      
      llvm-svn: 39356
      3273c228
    • Steve Naroff's avatar
      Bug #: · b7d4924e
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Added size expression to ArrayType. This was needed to implement
      Type::isIncompleteType(). At the moment, there is no support for
      determining if we have a constant expression (which won't be too
      difficult now that we have support for literal parsing/ast's).
      Nevertheless, the parser will allow "struct foo { int a[b]; }"
      (which is illegal). There is still significant work to fully analyze
      array types. The good news is "carbon.h" goes from 288 bogus errors
      down to 26!
      
      llvm-svn: 39355
      b7d4924e
  22. Mar 13, 2007
    • Steve Naroff's avatar
      Bug #: · 4f88b311
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Move string literal parsing from Sema=>LiteralSupport. This consolidates
      all the quirky parsing code within the Lexer subsystem (yeah!). This
      simplifies Sema and (more importantly) allows future parsers
      (i.e. subclasses of Action) to benefit from this code.
      
      llvm-svn: 39354
      4f88b311
    • Steve Naroff's avatar
      Bug #: · f2fb89e7
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Misc. cleanup/polish of NumericLiteralParser and it's two clients, the
      C preprocessor and AST builder...
      
      llvm-svn: 39353
      f2fb89e7
    • Steve Naroff's avatar
      Bug #: · 451d8f16
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      -Converted the preprocessor to use NumericLiteralParser.
      -Several minor changes to LiteralSupport interface/implementation.
      -Added an error diagnostic for floating point usage in pp expr's.
      
      llvm-svn: 39352
      451d8f16
  23. Mar 10, 2007
    • Steve Naroff's avatar
      Bug #: · 09ef4741
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Moved numeric literal support from SemaExpr.cpp to LiteralSupport.[h,cpp]
      in Lex. This will allow it to be used by both Sema and Preprocessor (and
      should be the last major refactoring of this sub-system).. Over
      time, it will be reused by anyone implementing an actions module (i.e.
      any subclass of llvm::clang::Action. Minor changes to IntegerLiteral in Expr.h.
      More to come...
      
      llvm-svn: 39351
      09ef4741
  24. Mar 07, 2007
    • Steve Naroff's avatar
      Bug #: · cf30755a
      Steve Naroff authored
      Submitted by:
      Reviewed by:
      Refactored ParseNumericConstant using SkipDigits and friends. This
      cleaned up the code and removed many "breaks". In the process, I found
      several bugs that needed to be fixed (proof that this refactoring had
      real value, not simply aesthetics). Also simplified error handling logic
      and removed an unused error condition from Diagnostics.def.
      
      llvm-svn: 39350
      cf30755a
Loading