[cfe-commits] r72214 - in /cfe/trunk: include/clang/Parse/Ownership.h lib/Parse/AstGuard.h lib/Parse/ParseDecl.cpp lib/Parse/ParseDeclCXX.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseExprCXX.cpp lib/Parse/ParseInit.cpp lib/Parse/ParseObjc.cpp lib/Parse/ParseStmt.cpp lib/Parse/ParseTemplate.cpp lib/Sema/SemaTemplateInstantiateExpr.cpp lib/Sema/SemaTemplateInstantiateStmt.cpp
Douglas Gregor
dgregor at apple.com
Thu May 21 09:25:12 PDT 2009
Author: dgregor
Date: Thu May 21 11:25:11 2009
New Revision: 72214
URL: http://llvm.org/viewvc/llvm-project?rev=72214&view=rev
Log:
Merge the ASTVector and ASTOwningVector templates, since they offered
redundant functionality. The result (ASTOwningVector) lives in
clang/Parse/Ownership.h and is used by both the parser and semantic
analysis. No intended functionality change.
Removed:
cfe/trunk/lib/Parse/AstGuard.h
Modified:
cfe/trunk/include/clang/Parse/Ownership.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseInit.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp
Modified: cfe/trunk/include/clang/Parse/Ownership.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Ownership.h?rev=72214&r1=72213&r2=72214&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Ownership.h (original)
+++ cfe/trunk/include/clang/Parse/Ownership.h Thu May 21 11:25:11 2009
@@ -724,8 +724,8 @@
};
/// \brief A small vector that owns a set of AST nodes.
- template <ASTDestroyer Destroyer>
- class ASTOwningVector : public llvm::SmallVector<void *, 8> {
+ template <ASTDestroyer Destroyer, unsigned N = 8>
+ class ASTOwningVector : public llvm::SmallVector<void *, N> {
#if !defined(DISABLE_SMART_POINTERS)
ActionBase &Actions;
bool Owned;
@@ -746,7 +746,7 @@
if (!Owned)
return;
- for (unsigned I = 0, N = this->size(); I != N; ++I)
+ for (unsigned I = 0, Last = this->size(); I != Last; ++I)
(Actions.*Destroyer)((*this)[I]);
}
#endif
@@ -759,8 +759,27 @@
}
template<typename T> T **takeAs() { return (T**)take(); }
+
+#if !defined(DISABLE_SMART_POINTERS)
+ ActionBase &getActions() const { return Actions; }
+#endif
};
+ /// A SmallVector of statements, with stack size 32 (as that is the only one
+ /// used.)
+ typedef ASTOwningVector<&ActionBase::DeleteStmt, 32> StmtVector;
+ /// A SmallVector of expressions, with stack size 12 (the maximum used.)
+ typedef ASTOwningVector<&ActionBase::DeleteExpr, 12> ExprVector;
+
+ template <ASTDestroyer Destroyer, unsigned N> inline
+ ASTMultiPtr<Destroyer> move_arg(ASTOwningVector<Destroyer, N> &vec) {
+#if !defined(DISABLE_SMART_POINTERS)
+ return ASTMultiPtr<Destroyer>(vec.getActions(), vec.take(), vec.size());
+#else
+ return ASTMultiPtr<Destroyer>(vec.take(), vec.size());
+#endif
+ }
+
#if !defined(DISABLE_SMART_POINTERS)
// Out-of-line implementations due to definition dependencies
Removed: cfe/trunk/lib/Parse/AstGuard.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/AstGuard.h?rev=72213&view=auto
==============================================================================
--- cfe/trunk/lib/Parse/AstGuard.h (original)
+++ cfe/trunk/lib/Parse/AstGuard.h (removed)
@@ -1,83 +0,0 @@
-//===--- AstGuard.h - Parser Ownership Tracking Utilities -------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines RAII objects for managing ExprTy* and StmtTy*.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_PARSE_ASTGUARD_H
-#define LLVM_CLANG_PARSE_ASTGUARD_H
-
-#include "clang/Parse/Action.h"
-#include "llvm/ADT/SmallVector.h"
-
-namespace clang
-{
- /// RAII SmallVector wrapper that holds Action::ExprTy* and similar,
- /// automatically freeing them on destruction unless it's been disowned.
- /// Instantiated for statements and expressions (Action::DeleteStmt and
- /// Action::DeleteExpr).
- template <ASTDestroyer Destroyer, unsigned N>
- class ASTVector : public llvm::SmallVector<void*, N> {
- private:
-#if !defined(DISABLE_SMART_POINTERS)
- Action &Actions;
- bool Owns;
-
- void destroy() {
- if (Owns) {
- while (!this->empty()) {
- (Actions.*Destroyer)(this->back());
- this->pop_back();
- }
- }
- }
-
- ASTVector(const ASTVector&); // DO NOT IMPLEMENT
- // Reference member prevents copy assignment.
-#endif
-
- public:
-#if !defined(DISABLE_SMART_POINTERS)
- ASTVector(Action &actions) : Actions(actions), Owns(true) {}
-
- ~ASTVector() { destroy(); }
-#else
- ASTVector(Action &) {}
-#endif
-
- void **take() {
-#if !defined(DISABLE_SMART_POINTERS)
- Owns = false;
-#endif
- return this->data();
- }
-
-#if !defined(DISABLE_SMART_POINTERS)
- Action &getActions() const { return Actions; }
-#endif
- };
-
- /// A SmallVector of statements, with stack size 32 (as that is the only one
- /// used.)
- typedef ASTVector<&Action::DeleteStmt, 32> StmtVector;
- /// A SmallVector of expressions, with stack size 12 (the maximum used.)
- typedef ASTVector<&Action::DeleteExpr, 12> ExprVector;
-
- template <ASTDestroyer Destroyer, unsigned N> inline
- ASTMultiPtr<Destroyer> move_arg(ASTVector<Destroyer, N> &vec) {
-#if !defined(DISABLE_SMART_POINTERS)
- return ASTMultiPtr<Destroyer>(vec.getActions(), vec.take(), vec.size());
-#else
- return ASTMultiPtr<Destroyer>(vec.take(), vec.size());
-#endif
- }
-}
-
-#endif
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=72214&r1=72213&r2=72214&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu May 21 11:25:11 2009
@@ -15,7 +15,6 @@
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Parse/Scope.h"
#include "ExtensionRAIIObject.h"
-#include "AstGuard.h"
#include "llvm/ADT/SmallSet.h"
using namespace clang;
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=72214&r1=72213&r2=72214&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Thu May 21 11:25:11 2009
@@ -15,7 +15,6 @@
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"
-#include "AstGuard.h"
#include "ExtensionRAIIObject.h"
using namespace clang;
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=72214&r1=72213&r2=72214&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu May 21 11:25:11 2009
@@ -24,7 +24,6 @@
#include "clang/Parse/Scope.h"
#include "clang/Basic/PrettyStackTrace.h"
#include "ExtensionRAIIObject.h"
-#include "AstGuard.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SmallString.h"
using namespace clang;
Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=72214&r1=72213&r2=72214&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Thu May 21 11:25:11 2009
@@ -14,7 +14,6 @@
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Parse/Parser.h"
#include "clang/Parse/DeclSpec.h"
-#include "AstGuard.h"
using namespace clang;
/// ParseOptionalCXXScopeSpecifier - Parse global scope or
Modified: cfe/trunk/lib/Parse/ParseInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseInit.cpp?rev=72214&r1=72213&r2=72214&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseInit.cpp (original)
+++ cfe/trunk/lib/Parse/ParseInit.cpp Thu May 21 11:25:11 2009
@@ -13,7 +13,6 @@
#include "clang/Parse/Designator.h"
#include "clang/Parse/Parser.h"
-#include "AstGuard.h"
#include "clang/Parse/ParseDiagnostic.h"
#include "llvm/ADT/SmallString.h"
using namespace clang;
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=72214&r1=72213&r2=72214&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu May 21 11:25:11 2009
@@ -14,7 +14,6 @@
#include "clang/Parse/Parser.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"
-#include "AstGuard.h"
#include "clang/Parse/ParseDiagnostic.h"
#include "llvm/ADT/SmallVector.h"
using namespace clang;
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=72214&r1=72213&r2=72214&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Thu May 21 11:25:11 2009
@@ -14,7 +14,6 @@
#include "clang/Parse/Parser.h"
#include "ExtensionRAIIObject.h"
-#include "AstGuard.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"
#include "clang/Basic/Diagnostic.h"
Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=72214&r1=72213&r2=72214&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Thu May 21 11:25:11 2009
@@ -15,7 +15,6 @@
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Scope.h"
-#include "AstGuard.h"
using namespace clang;
/// \brief Parse a template declaration, explicit instantiation, or
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=72214&r1=72213&r2=72214&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Thu May 21 11:25:11 2009
@@ -282,8 +282,7 @@
= ((Expr *)Callee.get())->getSourceRange().getBegin();
return SemaRef.ActOnCallExpr(/*Scope=*/0, move(Callee),
/*FIXME:*/FakeLParenLoc,
- Sema::MultiExprArg(SemaRef,
- Args.take(), Args.size()),
+ move_arg(Args),
/*FIXME:*/&FakeCommaLocs.front(),
E->getRParenLoc());
}
@@ -671,9 +670,7 @@
/*, FIXME*/),
T.getAsOpaquePtr(),
/*FIXME*/E->getTypeBeginLoc(),
- Sema::MultiExprArg(SemaRef,
- Args.take(),
- Args.size()),
+ move_arg(Args),
/*HACK*/&CommaLoc,
E->getSourceRange().getEnd());
}
@@ -924,9 +921,7 @@
return SemaRef.BuildCXXNew(E->getSourceRange().getBegin(),
E->isGlobalNew(),
/*FIXME*/SourceLocation(),
- Sema::MultiExprArg(SemaRef,
- PlacementArgs.take(),
- PlacementArgs.size()),
+ move_arg(PlacementArgs),
/*FIXME*/SourceLocation(),
E->isParenTypeId(),
AllocType,
@@ -979,9 +974,7 @@
E->getLParenLoc()),
T.getAsOpaquePtr(),
E->getLParenLoc(),
- Sema::MultiExprArg(SemaRef,
- Args.take(),
- Args.size()),
+ move_arg(Args),
&FakeCommaLocs.front(),
E->getRParenLoc());
}
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp?rev=72214&r1=72213&r2=72214&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp Thu May 21 11:25:11 2009
@@ -314,9 +314,7 @@
}
return SemaRef.ActOnCXXTryBlock(S->getTryLoc(), move(TryBlock),
- Sema::MultiStmtArg(SemaRef,
- Handlers.take(),
- Handlers.size()));
+ move_arg(Handlers));
}
Sema::OwningStmtResult
@@ -442,8 +440,5 @@
}
return ActOnCompoundStmt(S->getLBracLoc(), S->getRBracLoc(),
- Sema::MultiStmtArg(*this,
- Statements.take(),
- Statements.size()),
- isStmtExpr);
+ move_arg(Statements), isStmtExpr);
}
More information about the cfe-commits
mailing list