[cfe-commits] r39153 - in /cfe/cfe/trunk: AST/ASTStreamer.cpp AST/Sema.cpp AST/Sema.h Sema/ASTStreamer.cpp Sema/Sema.cpp Sema/Sema.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:40:01 PDT 2007


Author: sabre
Date: Wed Jul 11 11:40:01 2007
New Revision: 39153

URL: http://llvm.org/viewvc/llvm-project?rev=39153&view=rev
Log:
rename ASTBuilder to Sema

Modified:
    cfe/cfe/trunk/AST/ASTStreamer.cpp
    cfe/cfe/trunk/AST/Sema.cpp
    cfe/cfe/trunk/AST/Sema.h
    cfe/cfe/trunk/Sema/ASTStreamer.cpp
    cfe/cfe/trunk/Sema/Sema.cpp
    cfe/cfe/trunk/Sema/Sema.h

Modified: cfe/cfe/trunk/AST/ASTStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/ASTStreamer.cpp?rev=39153&r1=39152&r2=39153&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/ASTStreamer.cpp (original)
+++ cfe/cfe/trunk/AST/ASTStreamer.cpp Wed Jul 11 11:40:01 2007
@@ -24,7 +24,7 @@
     std::vector<Decl*> LastInGroupList;
   public:
     ASTStreamer(Preprocessor &PP, unsigned MainFileID)
-      : P(PP, *new ASTBuilder(PP, LastInGroupList)) {
+      : P(PP, *new Sema(PP, LastInGroupList)) {
       PP.EnterSourceFile(MainFileID, 0, true);
       
       // Initialize the parser.

Modified: cfe/cfe/trunk/AST/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.cpp?rev=39153&r1=39152&r2=39153&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/Sema.cpp (original)
+++ cfe/cfe/trunk/AST/Sema.cpp Wed Jul 11 11:40:01 2007
@@ -29,14 +29,14 @@
 // Symbol table tracking callbacks.
 //===----------------------------------------------------------------------===//
 
-bool ASTBuilder::isTypeName(const IdentifierInfo &II, Scope *S) const {
+bool Sema::isTypeName(const IdentifierInfo &II, Scope *S) const {
   Decl *D = II.getFETokenInfo<Decl>();
   return D != 0 && D->getDeclSpec().StorageClassSpec == DeclSpec::SCS_typedef;
 }
 
 Action::DeclTy *
-ASTBuilder::ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init, 
-                            DeclTy *LastInGroup) {
+Sema::ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init, 
+                      DeclTy *LastInGroup) {
   IdentifierInfo *II = D.getIdentifier();
   Decl *PrevDecl = II ? II->getFETokenInfo<Decl>() : 0;
 
@@ -62,7 +62,7 @@
 }
 
 Action::DeclTy *
-ASTBuilder::ParseFunctionDefinition(Scope *S, Declarator &D, StmtTy *Body) {
+Sema::ParseFunctionDefinition(Scope *S, Declarator &D, StmtTy *Body) {
   FunctionDecl *FD = (FunctionDecl *)ParseDeclarator(S, D, 0, 0);
   
   FD->setBody((Stmt*)Body);
@@ -70,7 +70,7 @@
   return FD;
 }
 
-void ASTBuilder::PopScope(SourceLocation Loc, Scope *S) {
+void Sema::PopScope(SourceLocation Loc, Scope *S) {
   for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end();
        I != E; ++I) {
     IdentifierInfo &II = *static_cast<IdentifierInfo*>(*I);
@@ -91,8 +91,8 @@
 //===--------------------------------------------------------------------===//
 
 Action::StmtResult 
-ASTBuilder::ParseCompoundStmt(SourceLocation L, SourceLocation R,
-                              StmtTy **Elts, unsigned NumElts) {
+Sema::ParseCompoundStmt(SourceLocation L, SourceLocation R,
+                        StmtTy **Elts, unsigned NumElts) {
   if (NumElts > 1)
     return new CompoundStmt((Stmt**)Elts, NumElts);
   else if (NumElts == 1)
@@ -102,80 +102,78 @@
 }
 
 Action::StmtResult
-ASTBuilder::ParseCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
-                          SourceLocation DotDotDotLoc, ExprTy *RHSVal,
-                          SourceLocation ColonLoc, StmtTy *SubStmt) {
+Sema::ParseCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
+                    SourceLocation DotDotDotLoc, ExprTy *RHSVal,
+                    SourceLocation ColonLoc, StmtTy *SubStmt) {
   return new CaseStmt((Expr*)LHSVal, (Expr*)RHSVal, (Stmt*)SubStmt);
 }
 
 Action::StmtResult
-ASTBuilder::ParseDefaultStmt(SourceLocation DefaultLoc,
-                             SourceLocation ColonLoc, StmtTy *SubStmt) {
+Sema::ParseDefaultStmt(SourceLocation DefaultLoc,
+                       SourceLocation ColonLoc, StmtTy *SubStmt) {
   return new DefaultStmt((Stmt*)SubStmt);
 }
 
 Action::StmtResult
-ASTBuilder::ParseLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
-                           SourceLocation ColonLoc, StmtTy *SubStmt) {
+Sema::ParseLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
+                     SourceLocation ColonLoc, StmtTy *SubStmt) {
   return new LabelStmt(II, (Stmt*)SubStmt);
 }
 
 Action::StmtResult 
-ASTBuilder::ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
-                        StmtTy *ThenVal, SourceLocation ElseLoc,
-                        StmtTy *ElseVal) {
+Sema::ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
+                  StmtTy *ThenVal, SourceLocation ElseLoc,
+                  StmtTy *ElseVal) {
   return new IfStmt((Expr*)CondVal, (Stmt*)ThenVal, (Stmt*)ElseVal);
 }
 Action::StmtResult
-ASTBuilder::ParseSwitchStmt(SourceLocation SwitchLoc, ExprTy *Cond,
-                            StmtTy *Body) {
+Sema::ParseSwitchStmt(SourceLocation SwitchLoc, ExprTy *Cond, StmtTy *Body) {
   return new SwitchStmt((Expr*)Cond, (Stmt*)Body);
 }
 
 Action::StmtResult
-ASTBuilder::ParseWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, StmtTy *Body){
+Sema::ParseWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, StmtTy *Body){
   return new WhileStmt((Expr*)Cond, (Stmt*)Body);
 }
 
 Action::StmtResult
-ASTBuilder::ParseDoStmt(SourceLocation DoLoc, StmtTy *Body,
-                        SourceLocation WhileLoc, ExprTy *Cond) {
+Sema::ParseDoStmt(SourceLocation DoLoc, StmtTy *Body,
+                  SourceLocation WhileLoc, ExprTy *Cond) {
   return new DoStmt((Stmt*)Body, (Expr*)Cond);
 }
 
 Action::StmtResult 
-ASTBuilder::ParseForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, 
-                         StmtTy *First, ExprTy *Second, ExprTy *Third,
-                         SourceLocation RParenLoc, StmtTy *Body) {
+Sema::ParseForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, 
+                   StmtTy *First, ExprTy *Second, ExprTy *Third,
+                   SourceLocation RParenLoc, StmtTy *Body) {
   return new ForStmt((Stmt*)First, (Expr*)Second, (Expr*)Third, (Stmt*)Body);
 }
 
 
 Action::StmtResult 
-ASTBuilder::ParseGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
-                          IdentifierInfo *LabelII) {
+Sema::ParseGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
+                    IdentifierInfo *LabelII) {
   return new GotoStmt(LabelII);
 }
 Action::StmtResult 
-ASTBuilder::ParseIndirectGotoStmt(SourceLocation GotoLoc,SourceLocation StarLoc,
-                                  ExprTy *DestExp) {
+Sema::ParseIndirectGotoStmt(SourceLocation GotoLoc,SourceLocation StarLoc,
+                            ExprTy *DestExp) {
   return new IndirectGotoStmt((Expr*)DestExp);
 }
 
 Action::StmtResult 
-ASTBuilder::ParseContinueStmt(SourceLocation ContinueLoc) {
+Sema::ParseContinueStmt(SourceLocation ContinueLoc) {
   return new ContinueStmt();
 }
 
 Action::StmtResult 
-ASTBuilder::ParseBreakStmt(SourceLocation GotoLoc) {
+Sema::ParseBreakStmt(SourceLocation GotoLoc) {
   return new BreakStmt();
 }
 
 
 Action::StmtResult
-ASTBuilder::ParseReturnStmt(SourceLocation ReturnLoc,
-                            ExprTy *RetValExp) {
+Sema::ParseReturnStmt(SourceLocation ReturnLoc, ExprTy *RetValExp) {
   return new ReturnStmt((Expr*)RetValExp);
 }
 
@@ -183,8 +181,8 @@
 // Expression Parsing Callbacks.
 //===--------------------------------------------------------------------===//
 
-Action::ExprResult ASTBuilder::ParseSimplePrimaryExpr(SourceLocation Loc,
-                                                      tok::TokenKind Kind) {
+Action::ExprResult Sema::ParseSimplePrimaryExpr(SourceLocation Loc,
+                                                tok::TokenKind Kind) {
   switch (Kind) {
   default:
     assert(0 && "Unknown simple primary expr!");
@@ -203,16 +201,15 @@
   }
 }
 
-Action::ExprResult ASTBuilder::ParseIntegerConstant(SourceLocation Loc) {
+Action::ExprResult Sema::ParseIntegerConstant(SourceLocation Loc) {
   return new IntegerConstant();
 }
-Action::ExprResult ASTBuilder::ParseFloatingConstant(SourceLocation Loc) {
+Action::ExprResult Sema::ParseFloatingConstant(SourceLocation Loc) {
   return new FloatingConstant();
 }
 
-Action::ExprResult ASTBuilder::ParseParenExpr(SourceLocation L, 
-                                              SourceLocation R,
-                                              ExprTy *Val) {
+Action::ExprResult Sema::ParseParenExpr(SourceLocation L, SourceLocation R,
+                                        ExprTy *Val) {
   return Val;
 }
 
@@ -236,8 +233,7 @@
 /// #6]), so it may come from multiple tokens.
 /// 
 Action::ExprResult
-ASTBuilder::ParseStringExpr(const LexerToken *StringToks,
-                            unsigned NumStringToks) {
+Sema::ParseStringExpr(const LexerToken *StringToks, unsigned NumStringToks) {
   assert(NumStringToks && "Must have at least one string!");
 
   // Scan all of the string portions, remember the max individual token length,
@@ -436,9 +432,8 @@
 }
 
 // Unary Operators.  'Tok' is the token for the operator.
-Action::ExprResult ASTBuilder::ParseUnaryOp(SourceLocation OpLoc,
-                                            tok::TokenKind Op,
-                                            ExprTy *Input) {
+Action::ExprResult Sema::ParseUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
+                                      ExprTy *Input) {
   UnaryOperator::Opcode Opc;
   switch (Op) {
   default: assert(0 && "Unknown unary op!");
@@ -464,7 +459,7 @@
   return new UnaryOperator((Expr*)Input, Opc);
 }
 
-Action::ExprResult ASTBuilder::
+Action::ExprResult Sema::
 ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof, 
                            SourceLocation LParenLoc, TypeTy *Ty,
                            SourceLocation RParenLoc) {
@@ -472,9 +467,9 @@
 }
 
 
-Action::ExprResult ASTBuilder::ParsePostfixUnaryOp(SourceLocation OpLoc, 
-                                                   tok::TokenKind Kind,
-                                                   ExprTy *Input) {
+Action::ExprResult Sema::ParsePostfixUnaryOp(SourceLocation OpLoc, 
+                                             tok::TokenKind Kind,
+                                             ExprTy *Input) {
   UnaryOperator::Opcode Opc;
   switch (Kind) {
   default: assert(0 && "Unknown unary op!");
@@ -485,13 +480,13 @@
   return new UnaryOperator((Expr*)Input, Opc);
 }
 
-Action::ExprResult ASTBuilder::
+Action::ExprResult Sema::
 ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
                         ExprTy *Idx, SourceLocation RLoc) {
   return new ArraySubscriptExpr((Expr*)Base, (Expr*)Idx);
 }
 
-Action::ExprResult ASTBuilder::
+Action::ExprResult Sema::
 ParseMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
                          tok::TokenKind OpKind, SourceLocation MemberLoc,
                          IdentifierInfo &Member) {
@@ -503,14 +498,14 @@
 /// ParseCallExpr - Handle a call to Fn with the specified array of arguments.
 /// This provides the location of the left/right parens and a list of comma
 /// locations.
-Action::ExprResult ASTBuilder::
+Action::ExprResult Sema::
 ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
               ExprTy **Args, unsigned NumArgs,
               SourceLocation *CommaLocs, SourceLocation RParenLoc) {
   return new CallExpr((Expr*)Fn, (Expr**)Args, NumArgs);
 }
 
-Action::ExprResult ASTBuilder::
+Action::ExprResult Sema::
 ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
               SourceLocation RParenLoc, ExprTy *Op) {
   return new CastExpr((Type*)Ty, (Expr*)Op);
@@ -519,9 +514,8 @@
 
 
 // Binary Operators.  'Tok' is the token for the operator.
-Action::ExprResult ASTBuilder::ParseBinOp(SourceLocation TokLoc, 
-                                          tok::TokenKind Kind, ExprTy *LHS,
-                                          ExprTy *RHS) {
+Action::ExprResult Sema::ParseBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
+                                    ExprTy *LHS, ExprTy *RHS) {
   BinaryOperator::Opcode Opc;
   switch (Kind) {
   default: assert(0 && "Unknown binop!");
@@ -562,10 +556,10 @@
 
 /// ParseConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
 /// in the case of a the GNU conditional expr extension.
-Action::ExprResult ASTBuilder::ParseConditionalOp(SourceLocation QuestionLoc, 
-                                                  SourceLocation ColonLoc,
-                                                  ExprTy *Cond, ExprTy *LHS,
-                                                  ExprTy *RHS) {
+Action::ExprResult Sema::ParseConditionalOp(SourceLocation QuestionLoc, 
+                                            SourceLocation ColonLoc,
+                                            ExprTy *Cond, ExprTy *LHS,
+                                            ExprTy *RHS) {
   return new ConditionalOperator((Expr*)Cond, (Expr*)LHS, (Expr*)RHS);
 }
 

Modified: cfe/cfe/trunk/AST/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.h?rev=39153&r1=39152&r2=39153&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/Sema.h (original)
+++ cfe/cfe/trunk/AST/Sema.h Wed Jul 11 11:40:01 2007
@@ -1,4 +1,4 @@
-//===--- ASTBuilder.h - Stream ASTs for top-level decls --------*- C++ -*-===//
+//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,12 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  This file defines the ASTBuilder interface.
+// This file defines the Sema class, which performs semantic analysis and
+// builds ASTs.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_AST_ASTBUILDER_H
-#define LLVM_CLANG_AST_ASTBUILDER_H
+#ifndef LLVM_CLANG_AST_SEMA_H
+#define LLVM_CLANG_AST_SEMA_H
 
 #include "clang/Parse/Action.h"
 #include <vector>
@@ -22,11 +23,8 @@
   class Preprocessor;
   class Decl;
   
-/// ASTBuilder - This is a simple implementation of the actions module which
-/// builds AST nodes for the code being parsed.  Clients can either use this
-/// unmodified or subclass it and overload methods to do more specialized
-/// things.
-class ASTBuilder : public Action {
+/// Sema - This implements semantic analysis and AST building for C.
+class Sema : public Action {
   Preprocessor &PP;
   
   /// LastInGroupList - This vector is populated when there are multiple
@@ -35,7 +33,7 @@
   /// ASTStreamer.
   std::vector<Decl*> &LastInGroupList;
 public:
-  ASTBuilder(Preprocessor &pp, std::vector<Decl*> &prevInGroup)
+  Sema(Preprocessor &pp, std::vector<Decl*> &prevInGroup)
     : PP(pp), LastInGroupList(prevInGroup) {}
   
   //===--------------------------------------------------------------------===//

Modified: cfe/cfe/trunk/Sema/ASTStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/ASTStreamer.cpp?rev=39153&r1=39152&r2=39153&view=diff

==============================================================================
--- cfe/cfe/trunk/Sema/ASTStreamer.cpp (original)
+++ cfe/cfe/trunk/Sema/ASTStreamer.cpp Wed Jul 11 11:40:01 2007
@@ -24,7 +24,7 @@
     std::vector<Decl*> LastInGroupList;
   public:
     ASTStreamer(Preprocessor &PP, unsigned MainFileID)
-      : P(PP, *new ASTBuilder(PP, LastInGroupList)) {
+      : P(PP, *new Sema(PP, LastInGroupList)) {
       PP.EnterSourceFile(MainFileID, 0, true);
       
       // Initialize the parser.

Modified: cfe/cfe/trunk/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.cpp?rev=39153&r1=39152&r2=39153&view=diff

==============================================================================
--- cfe/cfe/trunk/Sema/Sema.cpp (original)
+++ cfe/cfe/trunk/Sema/Sema.cpp Wed Jul 11 11:40:01 2007
@@ -29,14 +29,14 @@
 // Symbol table tracking callbacks.
 //===----------------------------------------------------------------------===//
 
-bool ASTBuilder::isTypeName(const IdentifierInfo &II, Scope *S) const {
+bool Sema::isTypeName(const IdentifierInfo &II, Scope *S) const {
   Decl *D = II.getFETokenInfo<Decl>();
   return D != 0 && D->getDeclSpec().StorageClassSpec == DeclSpec::SCS_typedef;
 }
 
 Action::DeclTy *
-ASTBuilder::ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init, 
-                            DeclTy *LastInGroup) {
+Sema::ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init, 
+                      DeclTy *LastInGroup) {
   IdentifierInfo *II = D.getIdentifier();
   Decl *PrevDecl = II ? II->getFETokenInfo<Decl>() : 0;
 
@@ -62,7 +62,7 @@
 }
 
 Action::DeclTy *
-ASTBuilder::ParseFunctionDefinition(Scope *S, Declarator &D, StmtTy *Body) {
+Sema::ParseFunctionDefinition(Scope *S, Declarator &D, StmtTy *Body) {
   FunctionDecl *FD = (FunctionDecl *)ParseDeclarator(S, D, 0, 0);
   
   FD->setBody((Stmt*)Body);
@@ -70,7 +70,7 @@
   return FD;
 }
 
-void ASTBuilder::PopScope(SourceLocation Loc, Scope *S) {
+void Sema::PopScope(SourceLocation Loc, Scope *S) {
   for (Scope::decl_iterator I = S->decl_begin(), E = S->decl_end();
        I != E; ++I) {
     IdentifierInfo &II = *static_cast<IdentifierInfo*>(*I);
@@ -91,8 +91,8 @@
 //===--------------------------------------------------------------------===//
 
 Action::StmtResult 
-ASTBuilder::ParseCompoundStmt(SourceLocation L, SourceLocation R,
-                              StmtTy **Elts, unsigned NumElts) {
+Sema::ParseCompoundStmt(SourceLocation L, SourceLocation R,
+                        StmtTy **Elts, unsigned NumElts) {
   if (NumElts > 1)
     return new CompoundStmt((Stmt**)Elts, NumElts);
   else if (NumElts == 1)
@@ -102,80 +102,78 @@
 }
 
 Action::StmtResult
-ASTBuilder::ParseCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
-                          SourceLocation DotDotDotLoc, ExprTy *RHSVal,
-                          SourceLocation ColonLoc, StmtTy *SubStmt) {
+Sema::ParseCaseStmt(SourceLocation CaseLoc, ExprTy *LHSVal,
+                    SourceLocation DotDotDotLoc, ExprTy *RHSVal,
+                    SourceLocation ColonLoc, StmtTy *SubStmt) {
   return new CaseStmt((Expr*)LHSVal, (Expr*)RHSVal, (Stmt*)SubStmt);
 }
 
 Action::StmtResult
-ASTBuilder::ParseDefaultStmt(SourceLocation DefaultLoc,
-                             SourceLocation ColonLoc, StmtTy *SubStmt) {
+Sema::ParseDefaultStmt(SourceLocation DefaultLoc,
+                       SourceLocation ColonLoc, StmtTy *SubStmt) {
   return new DefaultStmt((Stmt*)SubStmt);
 }
 
 Action::StmtResult
-ASTBuilder::ParseLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
-                           SourceLocation ColonLoc, StmtTy *SubStmt) {
+Sema::ParseLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
+                     SourceLocation ColonLoc, StmtTy *SubStmt) {
   return new LabelStmt(II, (Stmt*)SubStmt);
 }
 
 Action::StmtResult 
-ASTBuilder::ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
-                        StmtTy *ThenVal, SourceLocation ElseLoc,
-                        StmtTy *ElseVal) {
+Sema::ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
+                  StmtTy *ThenVal, SourceLocation ElseLoc,
+                  StmtTy *ElseVal) {
   return new IfStmt((Expr*)CondVal, (Stmt*)ThenVal, (Stmt*)ElseVal);
 }
 Action::StmtResult
-ASTBuilder::ParseSwitchStmt(SourceLocation SwitchLoc, ExprTy *Cond,
-                            StmtTy *Body) {
+Sema::ParseSwitchStmt(SourceLocation SwitchLoc, ExprTy *Cond, StmtTy *Body) {
   return new SwitchStmt((Expr*)Cond, (Stmt*)Body);
 }
 
 Action::StmtResult
-ASTBuilder::ParseWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, StmtTy *Body){
+Sema::ParseWhileStmt(SourceLocation WhileLoc, ExprTy *Cond, StmtTy *Body){
   return new WhileStmt((Expr*)Cond, (Stmt*)Body);
 }
 
 Action::StmtResult
-ASTBuilder::ParseDoStmt(SourceLocation DoLoc, StmtTy *Body,
-                        SourceLocation WhileLoc, ExprTy *Cond) {
+Sema::ParseDoStmt(SourceLocation DoLoc, StmtTy *Body,
+                  SourceLocation WhileLoc, ExprTy *Cond) {
   return new DoStmt((Stmt*)Body, (Expr*)Cond);
 }
 
 Action::StmtResult 
-ASTBuilder::ParseForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, 
-                         StmtTy *First, ExprTy *Second, ExprTy *Third,
-                         SourceLocation RParenLoc, StmtTy *Body) {
+Sema::ParseForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, 
+                   StmtTy *First, ExprTy *Second, ExprTy *Third,
+                   SourceLocation RParenLoc, StmtTy *Body) {
   return new ForStmt((Stmt*)First, (Expr*)Second, (Expr*)Third, (Stmt*)Body);
 }
 
 
 Action::StmtResult 
-ASTBuilder::ParseGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
-                          IdentifierInfo *LabelII) {
+Sema::ParseGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
+                    IdentifierInfo *LabelII) {
   return new GotoStmt(LabelII);
 }
 Action::StmtResult 
-ASTBuilder::ParseIndirectGotoStmt(SourceLocation GotoLoc,SourceLocation StarLoc,
-                                  ExprTy *DestExp) {
+Sema::ParseIndirectGotoStmt(SourceLocation GotoLoc,SourceLocation StarLoc,
+                            ExprTy *DestExp) {
   return new IndirectGotoStmt((Expr*)DestExp);
 }
 
 Action::StmtResult 
-ASTBuilder::ParseContinueStmt(SourceLocation ContinueLoc) {
+Sema::ParseContinueStmt(SourceLocation ContinueLoc) {
   return new ContinueStmt();
 }
 
 Action::StmtResult 
-ASTBuilder::ParseBreakStmt(SourceLocation GotoLoc) {
+Sema::ParseBreakStmt(SourceLocation GotoLoc) {
   return new BreakStmt();
 }
 
 
 Action::StmtResult
-ASTBuilder::ParseReturnStmt(SourceLocation ReturnLoc,
-                            ExprTy *RetValExp) {
+Sema::ParseReturnStmt(SourceLocation ReturnLoc, ExprTy *RetValExp) {
   return new ReturnStmt((Expr*)RetValExp);
 }
 
@@ -183,8 +181,8 @@
 // Expression Parsing Callbacks.
 //===--------------------------------------------------------------------===//
 
-Action::ExprResult ASTBuilder::ParseSimplePrimaryExpr(SourceLocation Loc,
-                                                      tok::TokenKind Kind) {
+Action::ExprResult Sema::ParseSimplePrimaryExpr(SourceLocation Loc,
+                                                tok::TokenKind Kind) {
   switch (Kind) {
   default:
     assert(0 && "Unknown simple primary expr!");
@@ -203,16 +201,15 @@
   }
 }
 
-Action::ExprResult ASTBuilder::ParseIntegerConstant(SourceLocation Loc) {
+Action::ExprResult Sema::ParseIntegerConstant(SourceLocation Loc) {
   return new IntegerConstant();
 }
-Action::ExprResult ASTBuilder::ParseFloatingConstant(SourceLocation Loc) {
+Action::ExprResult Sema::ParseFloatingConstant(SourceLocation Loc) {
   return new FloatingConstant();
 }
 
-Action::ExprResult ASTBuilder::ParseParenExpr(SourceLocation L, 
-                                              SourceLocation R,
-                                              ExprTy *Val) {
+Action::ExprResult Sema::ParseParenExpr(SourceLocation L, SourceLocation R,
+                                        ExprTy *Val) {
   return Val;
 }
 
@@ -236,8 +233,7 @@
 /// #6]), so it may come from multiple tokens.
 /// 
 Action::ExprResult
-ASTBuilder::ParseStringExpr(const LexerToken *StringToks,
-                            unsigned NumStringToks) {
+Sema::ParseStringExpr(const LexerToken *StringToks, unsigned NumStringToks) {
   assert(NumStringToks && "Must have at least one string!");
 
   // Scan all of the string portions, remember the max individual token length,
@@ -436,9 +432,8 @@
 }
 
 // Unary Operators.  'Tok' is the token for the operator.
-Action::ExprResult ASTBuilder::ParseUnaryOp(SourceLocation OpLoc,
-                                            tok::TokenKind Op,
-                                            ExprTy *Input) {
+Action::ExprResult Sema::ParseUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
+                                      ExprTy *Input) {
   UnaryOperator::Opcode Opc;
   switch (Op) {
   default: assert(0 && "Unknown unary op!");
@@ -464,7 +459,7 @@
   return new UnaryOperator((Expr*)Input, Opc);
 }
 
-Action::ExprResult ASTBuilder::
+Action::ExprResult Sema::
 ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof, 
                            SourceLocation LParenLoc, TypeTy *Ty,
                            SourceLocation RParenLoc) {
@@ -472,9 +467,9 @@
 }
 
 
-Action::ExprResult ASTBuilder::ParsePostfixUnaryOp(SourceLocation OpLoc, 
-                                                   tok::TokenKind Kind,
-                                                   ExprTy *Input) {
+Action::ExprResult Sema::ParsePostfixUnaryOp(SourceLocation OpLoc, 
+                                             tok::TokenKind Kind,
+                                             ExprTy *Input) {
   UnaryOperator::Opcode Opc;
   switch (Kind) {
   default: assert(0 && "Unknown unary op!");
@@ -485,13 +480,13 @@
   return new UnaryOperator((Expr*)Input, Opc);
 }
 
-Action::ExprResult ASTBuilder::
+Action::ExprResult Sema::
 ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
                         ExprTy *Idx, SourceLocation RLoc) {
   return new ArraySubscriptExpr((Expr*)Base, (Expr*)Idx);
 }
 
-Action::ExprResult ASTBuilder::
+Action::ExprResult Sema::
 ParseMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
                          tok::TokenKind OpKind, SourceLocation MemberLoc,
                          IdentifierInfo &Member) {
@@ -503,14 +498,14 @@
 /// ParseCallExpr - Handle a call to Fn with the specified array of arguments.
 /// This provides the location of the left/right parens and a list of comma
 /// locations.
-Action::ExprResult ASTBuilder::
+Action::ExprResult Sema::
 ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
               ExprTy **Args, unsigned NumArgs,
               SourceLocation *CommaLocs, SourceLocation RParenLoc) {
   return new CallExpr((Expr*)Fn, (Expr**)Args, NumArgs);
 }
 
-Action::ExprResult ASTBuilder::
+Action::ExprResult Sema::
 ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
               SourceLocation RParenLoc, ExprTy *Op) {
   return new CastExpr((Type*)Ty, (Expr*)Op);
@@ -519,9 +514,8 @@
 
 
 // Binary Operators.  'Tok' is the token for the operator.
-Action::ExprResult ASTBuilder::ParseBinOp(SourceLocation TokLoc, 
-                                          tok::TokenKind Kind, ExprTy *LHS,
-                                          ExprTy *RHS) {
+Action::ExprResult Sema::ParseBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
+                                    ExprTy *LHS, ExprTy *RHS) {
   BinaryOperator::Opcode Opc;
   switch (Kind) {
   default: assert(0 && "Unknown binop!");
@@ -562,10 +556,10 @@
 
 /// ParseConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
 /// in the case of a the GNU conditional expr extension.
-Action::ExprResult ASTBuilder::ParseConditionalOp(SourceLocation QuestionLoc, 
-                                                  SourceLocation ColonLoc,
-                                                  ExprTy *Cond, ExprTy *LHS,
-                                                  ExprTy *RHS) {
+Action::ExprResult Sema::ParseConditionalOp(SourceLocation QuestionLoc, 
+                                            SourceLocation ColonLoc,
+                                            ExprTy *Cond, ExprTy *LHS,
+                                            ExprTy *RHS) {
   return new ConditionalOperator((Expr*)Cond, (Expr*)LHS, (Expr*)RHS);
 }
 

Modified: cfe/cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.h?rev=39153&r1=39152&r2=39153&view=diff

==============================================================================
--- cfe/cfe/trunk/Sema/Sema.h (original)
+++ cfe/cfe/trunk/Sema/Sema.h Wed Jul 11 11:40:01 2007
@@ -1,4 +1,4 @@
-//===--- ASTBuilder.h - Stream ASTs for top-level decls --------*- C++ -*-===//
+//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,12 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  This file defines the ASTBuilder interface.
+// This file defines the Sema class, which performs semantic analysis and
+// builds ASTs.
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_AST_ASTBUILDER_H
-#define LLVM_CLANG_AST_ASTBUILDER_H
+#ifndef LLVM_CLANG_AST_SEMA_H
+#define LLVM_CLANG_AST_SEMA_H
 
 #include "clang/Parse/Action.h"
 #include <vector>
@@ -22,11 +23,8 @@
   class Preprocessor;
   class Decl;
   
-/// ASTBuilder - This is a simple implementation of the actions module which
-/// builds AST nodes for the code being parsed.  Clients can either use this
-/// unmodified or subclass it and overload methods to do more specialized
-/// things.
-class ASTBuilder : public Action {
+/// Sema - This implements semantic analysis and AST building for C.
+class Sema : public Action {
   Preprocessor &PP;
   
   /// LastInGroupList - This vector is populated when there are multiple
@@ -35,7 +33,7 @@
   /// ASTStreamer.
   std::vector<Decl*> &LastInGroupList;
 public:
-  ASTBuilder(Preprocessor &pp, std::vector<Decl*> &prevInGroup)
+  Sema(Preprocessor &pp, std::vector<Decl*> &prevInGroup)
     : PP(pp), LastInGroupList(prevInGroup) {}
   
   //===--------------------------------------------------------------------===//





More information about the cfe-commits mailing list