aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Lex/Preprocessor.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-11-13 17:11:24 +0000
committerTed Kremenek <kremenek@apple.com>2008-11-13 17:11:24 +0000
commitcaaa7df2c78bbd40197823034c0275f3dcbd63e7 (patch)
tree7a0a65d87706be1009b4d0fa1c0e4bf4548a0f43 /include/clang/Lex/Preprocessor.h
parented04c4cdca11119cac7d2fd65685444ce25f9e37 (diff)
Using llvm::OwningPtr<> for CurLexer and CurTokenLexer. This makes both the ownership semantics of these objects explicit within the Preprocessor and also tightens up the code (explicit deletes not needed).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59249 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex/Preprocessor.h')
-rw-r--r--include/clang/Lex/Preprocessor.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h
index 9f8494eef4..47ada4fe1a 100644
--- a/include/clang/Lex/Preprocessor.h
+++ b/include/clang/Lex/Preprocessor.h
@@ -20,6 +20,7 @@
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/OwningPtr.h"
namespace clang {
@@ -93,7 +94,7 @@ class Preprocessor {
/// CurLexer - This is the current top of the stack that we're lexing from if
/// not expanding a macro. One of CurLexer and CurTokenLexer must be null.
- Lexer *CurLexer;
+ llvm::OwningPtr<Lexer> CurLexer;
/// CurLookup - The DirectoryLookup structure used to find the current
/// FileEntry, if CurLexer is non-null and if applicable. This allows us to
@@ -102,7 +103,7 @@ class Preprocessor {
/// CurTokenLexer - This is the current macro we are expanding, if we are
/// expanding a macro. One of CurLexer and CurTokenLexer must be null.
- TokenLexer *CurTokenLexer;
+ llvm::OwningPtr<TokenLexer> CurTokenLexer;
/// IncludeMacroStack - This keeps track of the stack of files currently
/// #included, and macros currently being expanded from, not counting
@@ -191,7 +192,7 @@ public:
/// isCurrentLexer - Return true if we are lexing directly from the specified
/// lexer.
bool isCurrentLexer(const Lexer *L) const {
- return CurLexer == L;
+ return CurLexer.get() == L;
}
/// getCurrentLexer - Return the current file lexer being lexed from. Note
@@ -484,16 +485,14 @@ public:
private:
void PushIncludeMacroStack() {
- IncludeMacroStack.push_back(IncludeStackInfo(CurLexer, CurDirLookup,
- CurTokenLexer));
- CurLexer = 0;
- CurTokenLexer = 0;
+ IncludeMacroStack.push_back(IncludeStackInfo(CurLexer.take(), CurDirLookup,
+ CurTokenLexer.take()));
}
void PopIncludeMacroStack() {
- CurLexer = IncludeMacroStack.back().TheLexer;
+ CurLexer.reset(IncludeMacroStack.back().TheLexer);
CurDirLookup = IncludeMacroStack.back().TheDirLookup;
- CurTokenLexer = IncludeMacroStack.back().TheTokenLexer;
+ CurTokenLexer.reset(IncludeMacroStack.back().TheTokenLexer);
IncludeMacroStack.pop_back();
}