aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Lex
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-20 22:31:31 +0000
committerChris Lattner <sabre@nondot.org>2009-02-20 22:31:31 +0000
commitcf29e0716bb3ecbbc15b74cd648367d6b075fdf0 (patch)
treed7c63bce9ff21325790470ef37f04f8ea69bd3fd /include/clang/Lex
parent0301b3ff132a4d986c092d161cb77d74b04cd2a6 (diff)
detemplatify setArgumentList and some other cleanups.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65187 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex')
-rw-r--r--include/clang/Lex/MacroInfo.h28
1 files changed, 19 insertions, 9 deletions
diff --git a/include/clang/Lex/MacroInfo.h b/include/clang/Lex/MacroInfo.h
index a09c564fd9..7c3136ac11 100644
--- a/include/clang/Lex/MacroInfo.h
+++ b/include/clang/Lex/MacroInfo.h
@@ -72,16 +72,26 @@ private:
/// been used, or if it is not defined in the main file. This is used to
/// emit -Wunused-macros diagnostics.
bool IsUsed : 1;
-public:
- MacroInfo(SourceLocation DefLoc);
~MacroInfo() {
assert(ArgumentList == 0 && "Didn't call destroy before dtor!");
}
- void Destroy() {
+public:
+ MacroInfo(SourceLocation DefLoc);
+
+ /// FreeArgumentList - Free the argument list of the macro, restoring it to a
+ /// state where it can be reused for other devious purposes.
+ void FreeArgumentList() {
delete[] ArgumentList;
ArgumentList = 0;
+ NumArguments = 0;
+ }
+
+ /// Destroy - destroy this MacroInfo object.
+ void Destroy() {
+ FreeArgumentList();
+ this->~MacroInfo();
}
/// getDefinitionLoc - Return the location that the macro was defined at.
@@ -107,15 +117,15 @@ public:
/// setArgumentList - Set the specified list of identifiers as the argument
/// list for this macro.
- template<typename ItTy>
- void setArgumentList(ItTy ArgBegin, ItTy ArgEnd) {
- assert(ArgumentList == 0 && "Argument list already set!");
- unsigned NumArgs = ArgEnd-ArgBegin;
+ void setArgumentList(IdentifierInfo* const *List, unsigned NumArgs) {
+ assert(ArgumentList == 0 && NumArguments == 0 &&
+ "Argument list already set!");
if (NumArgs == 0) return;
+
NumArguments = NumArgs;
ArgumentList = new IdentifierInfo*[NumArgs];
- for (unsigned i = 0; ArgBegin != ArgEnd; ++i, ++ArgBegin)
- ArgumentList[i] = *ArgBegin;
+ for (unsigned i = 0; i != NumArgs; ++i)
+ ArgumentList[i] = List[i];
}
/// Arguments - The list of arguments for a function-like macro. This can be