Chris Lattner | f42cce7 | 2006-10-25 04:09:21 +0000 | [diff] [blame] | 1 | //===--- Stmt.cpp - Statement AST Node Implementation ---------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Chris Lattner and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the Stmt class and statement subclasses. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "clang/AST/Stmt.h" |
Chris Lattner | 2937565 | 2006-12-04 18:06:35 +0000 | [diff] [blame] | 15 | #include "clang/AST/ExprCXX.h" |
Chris Lattner | 5e9a878 | 2006-11-04 06:21:51 +0000 | [diff] [blame] | 16 | #include "clang/AST/StmtVisitor.h" |
Chris Lattner | f42cce7 | 2006-10-25 04:09:21 +0000 | [diff] [blame] | 17 | using namespace llvm; |
| 18 | using namespace clang; |
| 19 | |
Chris Lattner | 76af844 | 2006-11-04 20:54:18 +0000 | [diff] [blame] | 20 | // Implement all the AST node visit methods using the StmtNodes.def database. |
Steve Naroff | 7f890eb | 2007-02-27 02:53:10 +0000 | [diff] [blame] | 21 | #define STMT(N, CLASS, PARENT) \ |
Chris Lattner | 9ea960a | 2006-11-04 07:16:04 +0000 | [diff] [blame] | 22 | void CLASS::visit(StmtVisitor &V) { return V.Visit##CLASS(this); } |
Chris Lattner | e5cca06 | 2006-10-25 04:29:46 +0000 | [diff] [blame] | 23 | |
Steve Naroff | 7f890eb | 2007-02-27 02:53:10 +0000 | [diff] [blame] | 24 | STMT(0, Stmt, ) |
Chris Lattner | 76af844 | 2006-11-04 20:54:18 +0000 | [diff] [blame] | 25 | #include "clang/AST/StmtNodes.def" |
Steve Naroff | f1e5369 | 2007-03-23 22:27:02 +0000 | [diff] [blame^] | 26 | |
| 27 | static struct StmtClassNameTable { |
| 28 | int enumValue; |
| 29 | const char *className; |
| 30 | } sNames[] = { |
| 31 | #define STMT(N, CLASS, PARENT) { N, #CLASS }, |
| 32 | #include "clang/AST/StmtNodes.def" |
| 33 | { 0, 0 } |
| 34 | }; |
| 35 | |
| 36 | const char *Stmt::getStmtClassName() const { |
| 37 | for (int i = 0; sNames[i].className; i++) { |
| 38 | if (sClass == sNames[i].enumValue) |
| 39 | return sNames[i].className; |
| 40 | } |
| 41 | return 0; // should never happen.... |
| 42 | } |
| 43 | |