[cfe-commits] r39346 - in /cfe/cfe/trunk: AST/ASTStreamer.cpp AST/Sema.cpp AST/Sema.h Driver/clang.cpp Sema/ASTStreamer.cpp Sema/Sema.cpp Sema/Sema.h include/clang/AST/ASTStreamer.h include/clang/Sema/ASTStreamer.h
snaroff at cs.uiuc.edu
snaroff at cs.uiuc.edu
Wed Jul 11 09:43:25 PDT 2007
Author: snaroff
Date: Wed Jul 11 11:43:25 2007
New Revision: 39346
URL: http://llvm.org/viewvc/llvm-project?rev=39346&view=rev
Log:
Go back to having the clang driver create ASTContext explicitly, passing
it to Sema/ASTStreamer (separating the lifetime of ASTContext from
the lifetime of Sema). One day it might be useful to consider creating
a context object implicitly if one isn't provided (using default arguments in
Sema's constructor). At this point, adding this convenience isn't necessary.
Modified:
cfe/cfe/trunk/AST/ASTStreamer.cpp
cfe/cfe/trunk/AST/Sema.cpp
cfe/cfe/trunk/AST/Sema.h
cfe/cfe/trunk/Driver/clang.cpp
cfe/cfe/trunk/Sema/ASTStreamer.cpp
cfe/cfe/trunk/Sema/Sema.cpp
cfe/cfe/trunk/Sema/Sema.h
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=39346&r1=39345&r2=39346&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/ASTStreamer.cpp (original)
+++ cfe/cfe/trunk/AST/ASTStreamer.cpp Wed Jul 11 11:43:25 2007
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTStreamer.h"
+#include "clang/AST/ASTContext.h"
#include "Sema.h"
#include "clang/Parse/Action.h"
#include "clang/Parse/Parser.h"
@@ -23,8 +24,8 @@
Parser P;
std::vector<Decl*> LastInGroupList;
public:
- ASTStreamer(Preprocessor &pp, unsigned MainFileID)
- : P(pp, *new Sema(pp, LastInGroupList)) {
+ ASTStreamer(Preprocessor &pp, ASTContext &ctxt, unsigned MainFileID)
+ : P(pp, *new Sema(pp, ctxt, LastInGroupList)) {
pp.EnterSourceFile(MainFileID, 0, true);
// Initialize the parser.
@@ -78,7 +79,6 @@
}
void ASTStreamer::PrintStats() const {
- static_cast<Sema &>(P.getActions()).PrintStats();
}
//===----------------------------------------------------------------------===//
@@ -88,8 +88,9 @@
/// ASTStreamer_Init - Create an ASTStreamer with the specified preprocessor
/// and FileID.
ASTStreamerTy *llvm::clang::ASTStreamer_Init(Preprocessor &pp,
+ ASTContext &ctxt,
unsigned MainFileID) {
- return new ASTStreamer(pp, MainFileID);
+ return new ASTStreamer(pp, ctxt, MainFileID);
}
/// ASTStreamer_ReadTopLevelDecl - Parse and return one top-level declaration. This
Modified: cfe/cfe/trunk/AST/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.cpp?rev=39346&r1=39345&r2=39346&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Sema.cpp (original)
+++ cfe/cfe/trunk/AST/Sema.cpp Wed Jul 11 11:43:25 2007
@@ -18,14 +18,8 @@
using namespace llvm;
using namespace clang;
-Sema::Sema(Preprocessor &pp, std::vector<Decl*> &prevInGroup)
- : PP(pp),
- Context(*new ASTContext(pp.getTargetInfo(), pp.getIdentifierTable())),
- CurFunctionDecl(0), LastInGroupList(prevInGroup) {
-}
-
-void Sema::PrintStats() {
- Context.PrintStats();
+Sema::Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup)
+ : PP(pp), Context(ctxt), CurFunctionDecl(0), LastInGroupList(prevInGroup) {
}
//===----------------------------------------------------------------------===//
Modified: cfe/cfe/trunk/AST/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.h?rev=39346&r1=39345&r2=39346&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/Sema.h (original)
+++ cfe/cfe/trunk/AST/Sema.h Wed Jul 11 11:43:25 2007
@@ -47,15 +47,13 @@
/// ASTStreamer.
std::vector<Decl*> &LastInGroupList;
public:
- Sema(Preprocessor &pp, std::vector<Decl*> &prevInGroup);
+ Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup);
const LangOptions &getLangOptions() const;
void Diag(SourceLocation Loc, unsigned DiagID,
const std::string &Msg = std::string());
- void PrintStats();
-
//===--------------------------------------------------------------------===//
// Type Analysis / Processing: SemaType.cpp.
//
Modified: cfe/cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Driver/clang.cpp?rev=39346&r1=39345&r2=39346&view=diff
==============================================================================
--- cfe/cfe/trunk/Driver/clang.cpp (original)
+++ cfe/cfe/trunk/Driver/clang.cpp Wed Jul 11 11:43:25 2007
@@ -803,13 +803,15 @@
//===----------------------------------------------------------------------===//
static void BuildASTs(Preprocessor &PP, unsigned MainFileID) {
- ASTStreamerTy *Streamer = ASTStreamer_Init(PP, MainFileID);
+ ASTContext Context(PP.getTargetInfo(), PP.getIdentifierTable());
+ ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID);
while (ASTStreamer_ReadTopLevelDecl(Streamer))
/* keep reading */;
if (Stats) {
std::cerr << "\nSTATISTICS:\n";
ASTStreamer_PrintStats(Streamer);
+ Context.PrintStats();
}
ASTStreamer_Terminate(Streamer);
@@ -860,7 +862,8 @@
}
static void PrintASTs(Preprocessor &PP, unsigned MainFileID) {
- ASTStreamerTy *Streamer = ASTStreamer_Init(PP, MainFileID);
+ ASTContext Context(PP.getTargetInfo(), PP.getIdentifierTable());
+ ASTStreamerTy *Streamer = ASTStreamer_Init(PP, Context, MainFileID);
while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
@@ -875,6 +878,7 @@
if (Stats) {
std::cerr << "\nSTATISTICS:\n";
ASTStreamer_PrintStats(Streamer);
+ Context.PrintStats();
}
ASTStreamer_Terminate(Streamer);
Modified: cfe/cfe/trunk/Sema/ASTStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/ASTStreamer.cpp?rev=39346&r1=39345&r2=39346&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/ASTStreamer.cpp (original)
+++ cfe/cfe/trunk/Sema/ASTStreamer.cpp Wed Jul 11 11:43:25 2007
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTStreamer.h"
+#include "clang/AST/ASTContext.h"
#include "Sema.h"
#include "clang/Parse/Action.h"
#include "clang/Parse/Parser.h"
@@ -23,8 +24,8 @@
Parser P;
std::vector<Decl*> LastInGroupList;
public:
- ASTStreamer(Preprocessor &pp, unsigned MainFileID)
- : P(pp, *new Sema(pp, LastInGroupList)) {
+ ASTStreamer(Preprocessor &pp, ASTContext &ctxt, unsigned MainFileID)
+ : P(pp, *new Sema(pp, ctxt, LastInGroupList)) {
pp.EnterSourceFile(MainFileID, 0, true);
// Initialize the parser.
@@ -78,7 +79,6 @@
}
void ASTStreamer::PrintStats() const {
- static_cast<Sema &>(P.getActions()).PrintStats();
}
//===----------------------------------------------------------------------===//
@@ -88,8 +88,9 @@
/// ASTStreamer_Init - Create an ASTStreamer with the specified preprocessor
/// and FileID.
ASTStreamerTy *llvm::clang::ASTStreamer_Init(Preprocessor &pp,
+ ASTContext &ctxt,
unsigned MainFileID) {
- return new ASTStreamer(pp, MainFileID);
+ return new ASTStreamer(pp, ctxt, MainFileID);
}
/// ASTStreamer_ReadTopLevelDecl - Parse and return one top-level declaration. This
Modified: cfe/cfe/trunk/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.cpp?rev=39346&r1=39345&r2=39346&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/Sema.cpp (original)
+++ cfe/cfe/trunk/Sema/Sema.cpp Wed Jul 11 11:43:25 2007
@@ -18,14 +18,8 @@
using namespace llvm;
using namespace clang;
-Sema::Sema(Preprocessor &pp, std::vector<Decl*> &prevInGroup)
- : PP(pp),
- Context(*new ASTContext(pp.getTargetInfo(), pp.getIdentifierTable())),
- CurFunctionDecl(0), LastInGroupList(prevInGroup) {
-}
-
-void Sema::PrintStats() {
- Context.PrintStats();
+Sema::Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup)
+ : PP(pp), Context(ctxt), CurFunctionDecl(0), LastInGroupList(prevInGroup) {
}
//===----------------------------------------------------------------------===//
Modified: cfe/cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.h?rev=39346&r1=39345&r2=39346&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/Sema.h (original)
+++ cfe/cfe/trunk/Sema/Sema.h Wed Jul 11 11:43:25 2007
@@ -47,15 +47,13 @@
/// ASTStreamer.
std::vector<Decl*> &LastInGroupList;
public:
- Sema(Preprocessor &pp, std::vector<Decl*> &prevInGroup);
+ Sema(Preprocessor &pp, ASTContext &ctxt, std::vector<Decl*> &prevInGroup);
const LangOptions &getLangOptions() const;
void Diag(SourceLocation Loc, unsigned DiagID,
const std::string &Msg = std::string());
- void PrintStats();
-
//===--------------------------------------------------------------------===//
// Type Analysis / Processing: SemaType.cpp.
//
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=39346&r1=39345&r2=39346&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/ASTStreamer.h (original)
+++ cfe/cfe/trunk/include/clang/AST/ASTStreamer.h Wed Jul 11 11:43:25 2007
@@ -17,6 +17,7 @@
namespace llvm {
namespace clang {
class Preprocessor;
+ class ASTContext;
class Decl;
/// ASTStreamerTy - This is an opaque type used to reference ASTStreamer
@@ -25,7 +26,8 @@
/// ASTStreamer_Init - Create an ASTStreamer with the specified ASTContext
/// and FileID.
- ASTStreamerTy *ASTStreamer_Init(Preprocessor &pp, unsigned MainFileID);
+ ASTStreamerTy *ASTStreamer_Init(Preprocessor &pp, ASTContext &ctxt,
+ unsigned MainFileID);
/// ASTStreamer_ReadTopLevelDecl - Parse and return one top-level declaration.
/// This returns null at end of file.
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=39346&r1=39345&r2=39346&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h (original)
+++ cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h Wed Jul 11 11:43:25 2007
@@ -17,6 +17,7 @@
namespace llvm {
namespace clang {
class Preprocessor;
+ class ASTContext;
class Decl;
/// ASTStreamerTy - This is an opaque type used to reference ASTStreamer
@@ -25,7 +26,8 @@
/// ASTStreamer_Init - Create an ASTStreamer with the specified ASTContext
/// and FileID.
- ASTStreamerTy *ASTStreamer_Init(Preprocessor &pp, unsigned MainFileID);
+ ASTStreamerTy *ASTStreamer_Init(Preprocessor &pp, ASTContext &ctxt,
+ unsigned MainFileID);
/// ASTStreamer_ReadTopLevelDecl - Parse and return one top-level declaration.
/// This returns null at end of file.
More information about the cfe-commits
mailing list