[cfe-commits] r39095 - in /cfe/cfe/trunk: AST/ASTStreamer.cpp AST/Sema.cpp AST/Sema.h Lex/MacroExpander.cpp Sema/ASTStreamer.cpp Sema/Sema.cpp Sema/Sema.h include/clang/AST/ASTStreamer.h include/clang/Sema/ASTStreamer.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:27:29 PDT 2007
Author: sabre
Date: Wed Jul 11 11:27:29 2007
New Revision: 39095
URL: http://llvm.org/viewvc/llvm-project?rev=39095&view=rev
Log:
Export the ASTBuilder class from the AST module.
Added:
cfe/cfe/trunk/AST/Sema.h (with props)
cfe/cfe/trunk/Sema/Sema.h (with props)
Modified:
cfe/cfe/trunk/AST/ASTStreamer.cpp
cfe/cfe/trunk/AST/Sema.cpp
cfe/cfe/trunk/Lex/MacroExpander.cpp
cfe/cfe/trunk/Sema/ASTStreamer.cpp
cfe/cfe/trunk/Sema/Sema.cpp
cfe/cfe/trunk/include/clang/AST/ASTStreamer.h
cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h
Modified: cfe/cfe/trunk/AST/ASTStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/ASTStreamer.cpp?rev=39095&r1=39094&r2=39095&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/ASTStreamer.cpp (original)
+++ cfe/cfe/trunk/AST/ASTStreamer.cpp Wed Jul 11 11:27:29 2007
@@ -12,24 +12,19 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTStreamer.h"
+#include "clang/AST/ASTBuilder.h"
#include "clang/Parse/Action.h"
#include "clang/Parse/Parser.h"
using namespace llvm;
using namespace clang;
-/// Interface to the Builder.cpp file.
-///
-Action *CreateASTBuilderActions(Preprocessor &PP, bool FullLocInfo,
- std::vector<Decl*> &LastInGroupList);
-
-
namespace {
class ASTStreamer {
Parser P;
std::vector<Decl*> LastInGroupList;
public:
ASTStreamer(Preprocessor &PP, unsigned MainFileID, bool FullLocInfo)
- : P(PP, *CreateASTBuilderActions(PP, FullLocInfo, LastInGroupList)) {
+ : P(PP, *new ASTBuilder(PP, FullLocInfo, 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=39095&r1=39094&r2=39095&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Sema.cpp (original)
+++ cfe/cfe/trunk/AST/Sema.cpp Wed Jul 11 11:27:29 2007
@@ -1,4 +1,4 @@
-//===--- Builder.cpp - AST Builder Implementation -------------------------===//
+//===--- ASTBuilder.cpp - AST Builder Implementation ----------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/AST/ASTBuilder.h"
#include "clang/Parse/Action.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
@@ -22,107 +23,6 @@
using namespace llvm;
using namespace clang;
-/// ASTBuilder
-namespace {
-class VISIBILITY_HIDDEN ASTBuilder : public Action {
- Preprocessor &PP;
-
- /// FullLocInfo - If this is true, the ASTBuilder constructs AST Nodes that
- /// capture maximal location information for each source-language construct.
- bool FullLocInfo;
-
- /// LastInGroupList - This vector is populated when there are multiple
- /// declarators in a single decl group (e.g. "int A, B, C"). In this case,
- /// all but the last decl will be entered into this. This is used by the
- /// ASTStreamer.
- std::vector<Decl*> &LastInGroupList;
-public:
- ASTBuilder(Preprocessor &pp, bool fullLocInfo,
- std::vector<Decl*> &prevInGroup)
- : PP(pp), FullLocInfo(fullLocInfo), LastInGroupList(prevInGroup) {}
-
- //===--------------------------------------------------------------------===//
- // Symbol table tracking callbacks.
- //
- virtual bool isTypeName(const IdentifierInfo &II, Scope *S) const;
- virtual DeclTy *ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init,
- DeclTy *LastInGroup);
- virtual DeclTy *ParseFunctionDefinition(Scope *S, Declarator &D,
- StmtTy *Body);
- virtual void PopScope(SourceLocation Loc, Scope *S);
-
- //===--------------------------------------------------------------------===//
- // Statement Parsing Callbacks.
-
- virtual StmtResult ParseCompoundStmt(SourceLocation L, SourceLocation R,
- StmtTy **Elts, unsigned NumElts);
- virtual StmtResult ParseExprStmt(ExprTy *Expr) {
- // TODO: Full info should track this with a node.
- return Expr; // Exprs are Stmts.
- }
-
- virtual StmtResult ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
- StmtTy *ThenVal, SourceLocation ElseLoc,
- StmtTy *ElseVal);
-
- virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
- ExprTy *RetValExp);
-
- //===--------------------------------------------------------------------===//
- // Expression Parsing Callbacks.
-
- // Primary Expressions.
- virtual ExprResult ParseSimplePrimaryExpr(SourceLocation Loc,
- tok::TokenKind Kind);
- virtual ExprResult ParseIntegerConstant(SourceLocation Loc);
- virtual ExprResult ParseFloatingConstant(SourceLocation Loc);
- virtual ExprResult ParseParenExpr(SourceLocation L, SourceLocation R,
- ExprTy *Val);
- virtual ExprResult ParseStringExpr(const char *StrData, unsigned StrLen,
- bool isWide,
- SourceLocation *TokLocs, unsigned NumToks);
-
- // Binary/Unary Operators. 'Tok' is the token for the operator.
- virtual ExprResult ParseUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
- ExprTy *Input);
- virtual ExprResult
- ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof,
- SourceLocation LParenLoc, TypeTy *Ty,
- SourceLocation RParenLoc);
-
- virtual ExprResult ParsePostfixUnaryOp(SourceLocation OpLoc,
- tok::TokenKind Kind, ExprTy *Input);
-
- virtual ExprResult ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
- ExprTy *Idx, SourceLocation RLoc);
- virtual ExprResult ParseMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc,
- tok::TokenKind OpKind,
- SourceLocation MemberLoc,
- IdentifierInfo &Member);
-
- /// 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.
- virtual ExprResult ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
- ExprTy **Args, unsigned NumArgs,
- SourceLocation *CommaLocs,
- SourceLocation RParenLoc);
-
- virtual ExprResult ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
- SourceLocation RParenLoc, ExprTy *Op);
-
- virtual ExprResult ParseBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
- ExprTy *LHS,ExprTy *RHS);
-
- /// ParseConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
- /// in the case of a the GNU conditional expr extension.
- virtual ExprResult ParseConditionalOp(SourceLocation QuestionLoc,
- SourceLocation ColonLoc,
- ExprTy *Cond, ExprTy *LHS, ExprTy *RHS);
-};
-} // end anonymous namespace
-
-
//===----------------------------------------------------------------------===//
// Symbol table tracking callbacks.
//===----------------------------------------------------------------------===//
@@ -432,11 +332,3 @@
ColonLoc, (Expr*)RHS);
}
-
-/// Interface to the Builder.cpp file.
-///
-Action *CreateASTBuilderActions(Preprocessor &PP, bool FullLocInfo,
- std::vector<Decl*> &LastInGroupList) {
- return new ASTBuilder(PP, FullLocInfo, LastInGroupList);
-}
-
Added: cfe/cfe/trunk/AST/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.h?rev=39095&view=auto
==============================================================================
--- cfe/cfe/trunk/AST/Sema.h (added)
+++ cfe/cfe/trunk/AST/Sema.h Wed Jul 11 11:27:29 2007
@@ -0,0 +1,130 @@
+//===--- ASTBuilder.h - Stream ASTs for top-level decls --------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Chris Lattner and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the ASTBuilder interface.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_AST_ASTBUILDER_H
+#define LLVM_CLANG_AST_ASTBUILDER_H
+
+#include "clang/Parse/Action.h"
+#include <vector>
+
+namespace llvm {
+namespace clang {
+ 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 {
+ Preprocessor &PP;
+
+ /// FullLocInfo - If this is true, the ASTBuilder constructs AST Nodes that
+ /// capture maximal location information for each source-language construct.
+ bool FullLocInfo;
+
+ /// LastInGroupList - This vector is populated when there are multiple
+ /// declarators in a single decl group (e.g. "int A, B, C"). In this case,
+ /// all but the last decl will be entered into this. This is used by the
+ /// ASTStreamer.
+ std::vector<Decl*> &LastInGroupList;
+public:
+ ASTBuilder(Preprocessor &pp, bool fullLocInfo,
+ std::vector<Decl*> &prevInGroup)
+ : PP(pp), FullLocInfo(fullLocInfo), LastInGroupList(prevInGroup) {}
+
+ //===--------------------------------------------------------------------===//
+ // Symbol table tracking callbacks.
+ //
+ virtual bool isTypeName(const IdentifierInfo &II, Scope *S) const;
+ virtual DeclTy *ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init,
+ DeclTy *LastInGroup);
+ virtual DeclTy *ParseFunctionDefinition(Scope *S, Declarator &D,
+ StmtTy *Body);
+ virtual void PopScope(SourceLocation Loc, Scope *S);
+
+ //===--------------------------------------------------------------------===//
+ // Statement Parsing Callbacks.
+
+ virtual StmtResult ParseCompoundStmt(SourceLocation L, SourceLocation R,
+ StmtTy **Elts, unsigned NumElts);
+ virtual StmtResult ParseExprStmt(ExprTy *Expr) {
+ // TODO: Full info should track this with a node.
+ return Expr; // Exprs are Stmts.
+ }
+
+ virtual StmtResult ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
+ StmtTy *ThenVal, SourceLocation ElseLoc,
+ StmtTy *ElseVal);
+
+ virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
+ ExprTy *RetValExp);
+
+ //===--------------------------------------------------------------------===//
+ // Expression Parsing Callbacks.
+
+ // Primary Expressions.
+ virtual ExprResult ParseSimplePrimaryExpr(SourceLocation Loc,
+ tok::TokenKind Kind);
+ virtual ExprResult ParseIntegerConstant(SourceLocation Loc);
+ virtual ExprResult ParseFloatingConstant(SourceLocation Loc);
+ virtual ExprResult ParseParenExpr(SourceLocation L, SourceLocation R,
+ ExprTy *Val);
+ virtual ExprResult ParseStringExpr(const char *StrData, unsigned StrLen,
+ bool isWide,
+ SourceLocation *TokLocs, unsigned NumToks);
+
+ // Binary/Unary Operators. 'Tok' is the token for the operator.
+ virtual ExprResult ParseUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
+ ExprTy *Input);
+ virtual ExprResult
+ ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof,
+ SourceLocation LParenLoc, TypeTy *Ty,
+ SourceLocation RParenLoc);
+
+ virtual ExprResult ParsePostfixUnaryOp(SourceLocation OpLoc,
+ tok::TokenKind Kind, ExprTy *Input);
+
+ virtual ExprResult ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
+ ExprTy *Idx, SourceLocation RLoc);
+ virtual ExprResult ParseMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc,
+ tok::TokenKind OpKind,
+ SourceLocation MemberLoc,
+ IdentifierInfo &Member);
+
+ /// 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.
+ virtual ExprResult ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
+ ExprTy **Args, unsigned NumArgs,
+ SourceLocation *CommaLocs,
+ SourceLocation RParenLoc);
+
+ virtual ExprResult ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
+ SourceLocation RParenLoc, ExprTy *Op);
+
+ virtual ExprResult ParseBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
+ ExprTy *LHS,ExprTy *RHS);
+
+ /// ParseConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
+ /// in the case of a the GNU conditional expr extension.
+ virtual ExprResult ParseConditionalOp(SourceLocation QuestionLoc,
+ SourceLocation ColonLoc,
+ ExprTy *Cond, ExprTy *LHS, ExprTy *RHS);
+};
+
+
+} // end namespace clang
+} // end namespace llvm
+
+#endif
Propchange: cfe/cfe/trunk/AST/Sema.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/cfe/trunk/AST/Sema.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: cfe/cfe/trunk/Lex/MacroExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/MacroExpander.cpp?rev=39095&r1=39094&r2=39095&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/MacroExpander.cpp (original)
+++ cfe/cfe/trunk/Lex/MacroExpander.cpp Wed Jul 11 11:27:29 2007
@@ -523,6 +523,7 @@
// Allocate space for the result token. This is guaranteed to be enough for
// the two tokens and a null terminator.
+ // FIXME: Use a smallvector here.
char *Buffer = (char*)alloca(Tok.getLength() + RHS.getLength() + 1);
// Get the spelling of the LHS token in Buffer.
Modified: cfe/cfe/trunk/Sema/ASTStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/ASTStreamer.cpp?rev=39095&r1=39094&r2=39095&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/ASTStreamer.cpp (original)
+++ cfe/cfe/trunk/Sema/ASTStreamer.cpp Wed Jul 11 11:27:29 2007
@@ -12,24 +12,19 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTStreamer.h"
+#include "clang/AST/ASTBuilder.h"
#include "clang/Parse/Action.h"
#include "clang/Parse/Parser.h"
using namespace llvm;
using namespace clang;
-/// Interface to the Builder.cpp file.
-///
-Action *CreateASTBuilderActions(Preprocessor &PP, bool FullLocInfo,
- std::vector<Decl*> &LastInGroupList);
-
-
namespace {
class ASTStreamer {
Parser P;
std::vector<Decl*> LastInGroupList;
public:
ASTStreamer(Preprocessor &PP, unsigned MainFileID, bool FullLocInfo)
- : P(PP, *CreateASTBuilderActions(PP, FullLocInfo, LastInGroupList)) {
+ : P(PP, *new ASTBuilder(PP, FullLocInfo, 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=39095&r1=39094&r2=39095&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/Sema.cpp (original)
+++ cfe/cfe/trunk/Sema/Sema.cpp Wed Jul 11 11:27:29 2007
@@ -1,4 +1,4 @@
-//===--- Builder.cpp - AST Builder Implementation -------------------------===//
+//===--- ASTBuilder.cpp - AST Builder Implementation ----------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,6 +12,7 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/AST/ASTBuilder.h"
#include "clang/Parse/Action.h"
#include "clang/AST/Decl.h"
#include "clang/AST/Expr.h"
@@ -22,107 +23,6 @@
using namespace llvm;
using namespace clang;
-/// ASTBuilder
-namespace {
-class VISIBILITY_HIDDEN ASTBuilder : public Action {
- Preprocessor &PP;
-
- /// FullLocInfo - If this is true, the ASTBuilder constructs AST Nodes that
- /// capture maximal location information for each source-language construct.
- bool FullLocInfo;
-
- /// LastInGroupList - This vector is populated when there are multiple
- /// declarators in a single decl group (e.g. "int A, B, C"). In this case,
- /// all but the last decl will be entered into this. This is used by the
- /// ASTStreamer.
- std::vector<Decl*> &LastInGroupList;
-public:
- ASTBuilder(Preprocessor &pp, bool fullLocInfo,
- std::vector<Decl*> &prevInGroup)
- : PP(pp), FullLocInfo(fullLocInfo), LastInGroupList(prevInGroup) {}
-
- //===--------------------------------------------------------------------===//
- // Symbol table tracking callbacks.
- //
- virtual bool isTypeName(const IdentifierInfo &II, Scope *S) const;
- virtual DeclTy *ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init,
- DeclTy *LastInGroup);
- virtual DeclTy *ParseFunctionDefinition(Scope *S, Declarator &D,
- StmtTy *Body);
- virtual void PopScope(SourceLocation Loc, Scope *S);
-
- //===--------------------------------------------------------------------===//
- // Statement Parsing Callbacks.
-
- virtual StmtResult ParseCompoundStmt(SourceLocation L, SourceLocation R,
- StmtTy **Elts, unsigned NumElts);
- virtual StmtResult ParseExprStmt(ExprTy *Expr) {
- // TODO: Full info should track this with a node.
- return Expr; // Exprs are Stmts.
- }
-
- virtual StmtResult ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
- StmtTy *ThenVal, SourceLocation ElseLoc,
- StmtTy *ElseVal);
-
- virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
- ExprTy *RetValExp);
-
- //===--------------------------------------------------------------------===//
- // Expression Parsing Callbacks.
-
- // Primary Expressions.
- virtual ExprResult ParseSimplePrimaryExpr(SourceLocation Loc,
- tok::TokenKind Kind);
- virtual ExprResult ParseIntegerConstant(SourceLocation Loc);
- virtual ExprResult ParseFloatingConstant(SourceLocation Loc);
- virtual ExprResult ParseParenExpr(SourceLocation L, SourceLocation R,
- ExprTy *Val);
- virtual ExprResult ParseStringExpr(const char *StrData, unsigned StrLen,
- bool isWide,
- SourceLocation *TokLocs, unsigned NumToks);
-
- // Binary/Unary Operators. 'Tok' is the token for the operator.
- virtual ExprResult ParseUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
- ExprTy *Input);
- virtual ExprResult
- ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof,
- SourceLocation LParenLoc, TypeTy *Ty,
- SourceLocation RParenLoc);
-
- virtual ExprResult ParsePostfixUnaryOp(SourceLocation OpLoc,
- tok::TokenKind Kind, ExprTy *Input);
-
- virtual ExprResult ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
- ExprTy *Idx, SourceLocation RLoc);
- virtual ExprResult ParseMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc,
- tok::TokenKind OpKind,
- SourceLocation MemberLoc,
- IdentifierInfo &Member);
-
- /// 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.
- virtual ExprResult ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
- ExprTy **Args, unsigned NumArgs,
- SourceLocation *CommaLocs,
- SourceLocation RParenLoc);
-
- virtual ExprResult ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
- SourceLocation RParenLoc, ExprTy *Op);
-
- virtual ExprResult ParseBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
- ExprTy *LHS,ExprTy *RHS);
-
- /// ParseConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
- /// in the case of a the GNU conditional expr extension.
- virtual ExprResult ParseConditionalOp(SourceLocation QuestionLoc,
- SourceLocation ColonLoc,
- ExprTy *Cond, ExprTy *LHS, ExprTy *RHS);
-};
-} // end anonymous namespace
-
-
//===----------------------------------------------------------------------===//
// Symbol table tracking callbacks.
//===----------------------------------------------------------------------===//
@@ -432,11 +332,3 @@
ColonLoc, (Expr*)RHS);
}
-
-/// Interface to the Builder.cpp file.
-///
-Action *CreateASTBuilderActions(Preprocessor &PP, bool FullLocInfo,
- std::vector<Decl*> &LastInGroupList) {
- return new ASTBuilder(PP, FullLocInfo, LastInGroupList);
-}
-
Added: cfe/cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.h?rev=39095&view=auto
==============================================================================
--- cfe/cfe/trunk/Sema/Sema.h (added)
+++ cfe/cfe/trunk/Sema/Sema.h Wed Jul 11 11:27:29 2007
@@ -0,0 +1,130 @@
+//===--- ASTBuilder.h - Stream ASTs for top-level decls --------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Chris Lattner and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the ASTBuilder interface.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_AST_ASTBUILDER_H
+#define LLVM_CLANG_AST_ASTBUILDER_H
+
+#include "clang/Parse/Action.h"
+#include <vector>
+
+namespace llvm {
+namespace clang {
+ 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 {
+ Preprocessor &PP;
+
+ /// FullLocInfo - If this is true, the ASTBuilder constructs AST Nodes that
+ /// capture maximal location information for each source-language construct.
+ bool FullLocInfo;
+
+ /// LastInGroupList - This vector is populated when there are multiple
+ /// declarators in a single decl group (e.g. "int A, B, C"). In this case,
+ /// all but the last decl will be entered into this. This is used by the
+ /// ASTStreamer.
+ std::vector<Decl*> &LastInGroupList;
+public:
+ ASTBuilder(Preprocessor &pp, bool fullLocInfo,
+ std::vector<Decl*> &prevInGroup)
+ : PP(pp), FullLocInfo(fullLocInfo), LastInGroupList(prevInGroup) {}
+
+ //===--------------------------------------------------------------------===//
+ // Symbol table tracking callbacks.
+ //
+ virtual bool isTypeName(const IdentifierInfo &II, Scope *S) const;
+ virtual DeclTy *ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init,
+ DeclTy *LastInGroup);
+ virtual DeclTy *ParseFunctionDefinition(Scope *S, Declarator &D,
+ StmtTy *Body);
+ virtual void PopScope(SourceLocation Loc, Scope *S);
+
+ //===--------------------------------------------------------------------===//
+ // Statement Parsing Callbacks.
+
+ virtual StmtResult ParseCompoundStmt(SourceLocation L, SourceLocation R,
+ StmtTy **Elts, unsigned NumElts);
+ virtual StmtResult ParseExprStmt(ExprTy *Expr) {
+ // TODO: Full info should track this with a node.
+ return Expr; // Exprs are Stmts.
+ }
+
+ virtual StmtResult ParseIfStmt(SourceLocation IfLoc, ExprTy *CondVal,
+ StmtTy *ThenVal, SourceLocation ElseLoc,
+ StmtTy *ElseVal);
+
+ virtual StmtResult ParseReturnStmt(SourceLocation ReturnLoc,
+ ExprTy *RetValExp);
+
+ //===--------------------------------------------------------------------===//
+ // Expression Parsing Callbacks.
+
+ // Primary Expressions.
+ virtual ExprResult ParseSimplePrimaryExpr(SourceLocation Loc,
+ tok::TokenKind Kind);
+ virtual ExprResult ParseIntegerConstant(SourceLocation Loc);
+ virtual ExprResult ParseFloatingConstant(SourceLocation Loc);
+ virtual ExprResult ParseParenExpr(SourceLocation L, SourceLocation R,
+ ExprTy *Val);
+ virtual ExprResult ParseStringExpr(const char *StrData, unsigned StrLen,
+ bool isWide,
+ SourceLocation *TokLocs, unsigned NumToks);
+
+ // Binary/Unary Operators. 'Tok' is the token for the operator.
+ virtual ExprResult ParseUnaryOp(SourceLocation OpLoc, tok::TokenKind Op,
+ ExprTy *Input);
+ virtual ExprResult
+ ParseSizeOfAlignOfTypeExpr(SourceLocation OpLoc, bool isSizeof,
+ SourceLocation LParenLoc, TypeTy *Ty,
+ SourceLocation RParenLoc);
+
+ virtual ExprResult ParsePostfixUnaryOp(SourceLocation OpLoc,
+ tok::TokenKind Kind, ExprTy *Input);
+
+ virtual ExprResult ParseArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc,
+ ExprTy *Idx, SourceLocation RLoc);
+ virtual ExprResult ParseMemberReferenceExpr(ExprTy *Base,SourceLocation OpLoc,
+ tok::TokenKind OpKind,
+ SourceLocation MemberLoc,
+ IdentifierInfo &Member);
+
+ /// 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.
+ virtual ExprResult ParseCallExpr(ExprTy *Fn, SourceLocation LParenLoc,
+ ExprTy **Args, unsigned NumArgs,
+ SourceLocation *CommaLocs,
+ SourceLocation RParenLoc);
+
+ virtual ExprResult ParseCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
+ SourceLocation RParenLoc, ExprTy *Op);
+
+ virtual ExprResult ParseBinOp(SourceLocation TokLoc, tok::TokenKind Kind,
+ ExprTy *LHS,ExprTy *RHS);
+
+ /// ParseConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
+ /// in the case of a the GNU conditional expr extension.
+ virtual ExprResult ParseConditionalOp(SourceLocation QuestionLoc,
+ SourceLocation ColonLoc,
+ ExprTy *Cond, ExprTy *LHS, ExprTy *RHS);
+};
+
+
+} // end namespace clang
+} // end namespace llvm
+
+#endif
Propchange: cfe/cfe/trunk/Sema/Sema.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/cfe/trunk/Sema/Sema.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: cfe/cfe/trunk/include/clang/AST/ASTStreamer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/ASTStreamer.h?rev=39095&r1=39094&r2=39095&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/ASTStreamer.h (original)
+++ cfe/cfe/trunk/include/clang/AST/ASTStreamer.h Wed Jul 11 11:27:29 2007
@@ -41,4 +41,4 @@
} // end namespace clang
} // end namespace llvm
-#endif
\ No newline at end of file
+#endif
Modified: cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h?rev=39095&r1=39094&r2=39095&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h (original)
+++ cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h Wed Jul 11 11:27:29 2007
@@ -41,4 +41,4 @@
} // end namespace clang
} // end namespace llvm
-#endif
\ No newline at end of file
+#endif
More information about the cfe-commits
mailing list