[cfe-commits] r38914 - in /cfe/cfe/trunk: Driver/clang.cpp Parse/MinimalAction.cpp include/clang/Parse/Action.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:25:43 PDT 2007
Author: sabre
Date: Wed Jul 11 11:25:43 2007
New Revision: 38914
URL: http://llvm.org/viewvc/llvm-project?rev=38914&view=rev
Log:
Stub out the EmptyAction class.
Added:
cfe/cfe/trunk/Parse/MinimalAction.cpp (with props)
Modified:
cfe/cfe/trunk/Driver/clang.cpp
cfe/cfe/trunk/include/clang/Parse/Action.h
Modified: cfe/cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Driver/clang.cpp?rev=38914&r1=38913&r2=38914&view=diff
==============================================================================
--- cfe/cfe/trunk/Driver/clang.cpp (original)
+++ cfe/cfe/trunk/Driver/clang.cpp Wed Jul 11 11:25:43 2007
@@ -752,7 +752,7 @@
//ParseFile(PP, new ParserPrintActions(PP), MainFileID);
break;
case ParseSyntaxOnly: // -fsyntax-only
- ParseFile(PP, new Action(), MainFileID);
+ ParseFile(PP, new EmptyAction(), MainFileID);
break;
}
Added: cfe/cfe/trunk/Parse/MinimalAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/MinimalAction.cpp?rev=38914&view=auto
==============================================================================
--- cfe/cfe/trunk/Parse/MinimalAction.cpp (added)
+++ cfe/cfe/trunk/Parse/MinimalAction.cpp Wed Jul 11 11:25:43 2007
@@ -0,0 +1,37 @@
+//===--- EmptyAction.cpp - Minimalistic action implementation -------------===//
+//
+// 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 implements the EmptyAction interface.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Parse/Parser.h"
+//#include "clang/Parse/Declarations.h"
+//#include "clang/Parse/Scope.h"
+using namespace llvm;
+using namespace clang;
+
+/// isTypedefName - This looks at the IdentifierInfo::FETokenInfo field to
+/// determine whether the name is a typedef or not in this scope.
+bool EmptyAction::isTypedefName(const IdentifierInfo &II, Scope *S) const {
+ return true;
+}
+
+/// ParseDeclarator - If this is a typedef declarator, we modify the
+/// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is
+/// popped.
+void EmptyAction::ParseDeclarator(SourceLocation Loc, Scope *S, Declarator &D,
+ ExprTy *Init) {
+}
+
+/// PopScope - When a scope is popped, if any typedefs are now out-of-scope,
+/// they are removed from the IdentifierInfo::FETokenInfo field.
+void EmptyAction::PopScope(SourceLocation Loc, Scope *S) {
+
+}
Propchange: cfe/cfe/trunk/Parse/MinimalAction.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/cfe/trunk/Parse/MinimalAction.cpp
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: cfe/cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/Action.h?rev=38914&r1=38913&r2=38914&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/Action.h Wed Jul 11 11:25:43 2007
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file defines the Action interface.
+// This file defines the Action and EmptyAction interface.
//
//===----------------------------------------------------------------------===//
@@ -18,10 +18,11 @@
namespace llvm {
namespace clang {
- // Parse.
- class Scope;
// Semantic.
class Declarator;
+ // Parse.
+ class Scope;
+ class Action;
/// Action - As the parser reads the input file and recognizes the productions
/// of the grammar, it invokes methods on this class to turn the parsed input
@@ -31,9 +32,9 @@
/// the parser has just done or is about to do when the method is called. They
/// are not requests that the actions module do the specified action.
///
-/// All of the methods here are optional, but you must specify information about
-/// whether something is a typedef or not in order for the parse to complete
-/// accurately. The EmptyAction class does this bare-minimum of tracking.
+/// All of the methods here are optional except isTypedefName(), which must be
+/// specified in order for the parse to complete accurately. The EmptyAction
+/// class does this bare-minimum of tracking to implement this functionality.
class Action {
public:
/// Out-of-line virtual destructor to provide home for this class.
@@ -47,6 +48,10 @@
// Symbol table tracking callbacks.
//===--------------------------------------------------------------------===//
+ /// isTypedefName - Return true if the specified identifier is a typedef name
+ /// in the current scope.
+ virtual bool isTypedefName(const IdentifierInfo &II, Scope *S) const = 0;
+
/// ParseDeclarator - This callback is invoked when a declarator is parsed and
/// 'Init' specifies the initializer if any. This is for things like:
/// "int X = 4" or "typedef int foo".
@@ -58,6 +63,28 @@
virtual void PopScope(SourceLocation Loc, Scope *S) {}
};
+
+
+/// EmptyAction - This is a simple (bare-minimum) implementation of the Action
+/// class, which only keeps track of which typedefs are in-scope. This class is
+/// useful to subclass if clients want to implement some actions without having
+/// to reimplement all of the scoping rules.
+class EmptyAction : public Action {
+
+ /// isTypedefName - This looks at the IdentifierInfo::FETokenInfo field to
+ /// determine whether the name is a typedef or not in this scope.
+ virtual bool isTypedefName(const IdentifierInfo &II, Scope *S) const;
+
+ /// ParseDeclarator - If this is a typedef declarator, we modify the
+ /// IdentifierInfo::FETokenInfo field to keep track of this fact, until S is
+ /// popped.
+ virtual void ParseDeclarator(SourceLocation Loc, Scope *S, Declarator &D,
+ ExprTy *Init);
+
+ /// PopScope - When a scope is popped, if any typedefs are now out-of-scope,
+ /// they are removed from the IdentifierInfo::FETokenInfo field.
+ virtual void PopScope(SourceLocation Loc, Scope *S);
+};
} // end namespace clang
} // end namespace llvm
More information about the cfe-commits
mailing list