summaryrefslogtreecommitdiffstats
path: root/include/clang/Sema/CodeCompleteConsumer.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-01 22:57:45 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-01 22:57:45 +0000
commitdae687575010c9c49a4b552f5eef82cd6279d9ac (patch)
tree761782a397e30df66392dd5c7218c412116d0b21 /include/clang/Sema/CodeCompleteConsumer.h
parentdaef9cc7e379c83e272f50de2fb3b7ab2e7e42db (diff)
Create a special allocator class for code completion, so that all of
the string copying goes through a single place that can have associated state. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124698 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema/CodeCompleteConsumer.h')
-rw-r--r--include/clang/Sema/CodeCompleteConsumer.h25
1 files changed, 16 insertions, 9 deletions
diff --git a/include/clang/Sema/CodeCompleteConsumer.h b/include/clang/Sema/CodeCompleteConsumer.h
index 9daefd72a5..8cb8e75393 100644
--- a/include/clang/Sema/CodeCompleteConsumer.h
+++ b/include/clang/Sema/CodeCompleteConsumer.h
@@ -421,13 +421,20 @@ public:
std::string getAsString() const;
};
+/// \brief An allocator used specifically for the purpose of code completion.
+class CodeCompletionAllocator : public llvm::BumpPtrAllocator {
+public:
+ /// \brief Copy the given string into this allocator.
+ const char *CopyString(llvm::StringRef String);
+};
+
/// \brief A builder class used to construct new code-completion strings.
class CodeCompletionBuilder {
public:
typedef CodeCompletionString::Chunk Chunk;
private:
- llvm::BumpPtrAllocator &Allocator;
+ CodeCompletionAllocator &Allocator;
unsigned Priority;
CXAvailabilityKind Availability;
@@ -435,17 +442,17 @@ private:
llvm::SmallVector<Chunk, 4> Chunks;
public:
- CodeCompletionBuilder(llvm::BumpPtrAllocator &Allocator)
+ CodeCompletionBuilder(CodeCompletionAllocator &Allocator)
: Allocator(Allocator), Priority(0), Availability(CXAvailability_Available){
}
- CodeCompletionBuilder(llvm::BumpPtrAllocator &Allocator,
+ CodeCompletionBuilder(CodeCompletionAllocator &Allocator,
unsigned Priority, CXAvailabilityKind Availability)
: Allocator(Allocator), Priority(Priority), Availability(Availability) { }
/// \brief Retrieve the allocator into which the code completion
/// strings will be
- llvm::BumpPtrAllocator &getAllocator() const { return Allocator; }
+ CodeCompletionAllocator &getAllocator() const { return Allocator; }
/// \brief Take the resulting completion string.
///
@@ -630,7 +637,7 @@ public:
/// \param Allocator The allocator that will be used to allocate the
/// string itself.
CodeCompletionString *CreateCodeCompletionString(Sema &S,
- llvm::BumpPtrAllocator &Allocator);
+ CodeCompletionAllocator &Allocator);
/// \brief Determine a base priority for the given declaration.
static unsigned getPriorityFromDecl(NamedDecl *ND);
@@ -742,7 +749,7 @@ public:
/// signature of this overload candidate.
CodeCompletionString *CreateSignatureString(unsigned CurrentArg,
Sema &S,
- llvm::BumpPtrAllocator &Allocator) const;
+ CodeCompletionAllocator &Allocator) const;
};
CodeCompleteConsumer() : IncludeMacros(false), IncludeCodePatterns(false),
@@ -791,7 +798,7 @@ public:
/// \brief Retrieve the allocator that will be used to allocate
/// code completion strings.
- virtual llvm::BumpPtrAllocator &getAllocator() = 0;
+ virtual CodeCompletionAllocator &getAllocator() = 0;
};
/// \brief A simple code-completion consumer that prints the results it
@@ -800,7 +807,7 @@ class PrintingCodeCompleteConsumer : public CodeCompleteConsumer {
/// \brief The raw output stream.
llvm::raw_ostream &OS;
- llvm::BumpPtrAllocator Allocator;
+ CodeCompletionAllocator Allocator;
public:
/// \brief Create a new printing code-completion consumer that prints its
@@ -821,7 +828,7 @@ public:
OverloadCandidate *Candidates,
unsigned NumCandidates);
- virtual llvm::BumpPtrAllocator &getAllocator() { return Allocator; }
+ virtual CodeCompletionAllocator &getAllocator() { return Allocator; }
};
} // end namespace clang