diff options
author | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
commit | c72c57c9e9b69944e3e009cd5e209634839581d3 (patch) | |
tree | 4fc2f184c499d106f29a386c452b49e5197bf63d /lib/AST/CommentCommandTraits.cpp | |
parent | 5b20025c30d23d521e12c1f33ec8fa6b821952cd (diff) | |
download | FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.zip FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.tar.gz |
Vendor import of clang trunk r178860:
http://llvm.org/svn/llvm-project/cfe/trunk@178860
Diffstat (limited to 'lib/AST/CommentCommandTraits.cpp')
-rw-r--r-- | lib/AST/CommentCommandTraits.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/lib/AST/CommentCommandTraits.cpp b/lib/AST/CommentCommandTraits.cpp index e7e40fd..e24d542 100644 --- a/lib/AST/CommentCommandTraits.cpp +++ b/lib/AST/CommentCommandTraits.cpp @@ -15,9 +15,21 @@ namespace comments { #include "clang/AST/CommentCommandInfo.inc" -CommandTraits::CommandTraits(llvm::BumpPtrAllocator &Allocator) : - NextID(llvm::array_lengthof(Commands)), Allocator(Allocator) -{ } +CommandTraits::CommandTraits(llvm::BumpPtrAllocator &Allocator, + const CommentOptions &CommentOptions) : + NextID(llvm::array_lengthof(Commands)), Allocator(Allocator) { + registerCommentOptions(CommentOptions); +} + +void CommandTraits::registerCommentOptions( + const CommentOptions &CommentOptions) { + for (CommentOptions::BlockCommandNamesTy::const_iterator + I = CommentOptions.BlockCommandNames.begin(), + E = CommentOptions.BlockCommandNames.end(); + I != E; I++) { + registerBlockCommand(*I); + } +} const CommandInfo *CommandTraits::getCommandInfoOrNULL(StringRef Name) const { if (const CommandInfo *Info = getBuiltinCommandInfo(Name)) @@ -31,7 +43,7 @@ const CommandInfo *CommandTraits::getCommandInfo(unsigned CommandID) const { return getRegisteredCommandInfo(CommandID); } -const CommandInfo *CommandTraits::registerUnknownCommand(StringRef CommandName) { +CommandInfo *CommandTraits::createCommandInfoWithName(StringRef CommandName) { char *Name = Allocator.Allocate<char>(CommandName.size() + 1); memcpy(Name, CommandName.data(), CommandName.size()); Name[CommandName.size()] = '\0'; @@ -40,13 +52,25 @@ const CommandInfo *CommandTraits::registerUnknownCommand(StringRef CommandName) CommandInfo *Info = new (Allocator) CommandInfo(); Info->Name = Name; Info->ID = NextID++; - Info->IsUnknownCommand = true; RegisteredCommands.push_back(Info); return Info; } +const CommandInfo *CommandTraits::registerUnknownCommand( + StringRef CommandName) { + CommandInfo *Info = createCommandInfoWithName(CommandName); + Info->IsUnknownCommand = true; + return Info; +} + +const CommandInfo *CommandTraits::registerBlockCommand(StringRef CommandName) { + CommandInfo *Info = createCommandInfoWithName(CommandName); + Info->IsBlockCommand = true; + return Info; +} + const CommandInfo *CommandTraits::getBuiltinCommandInfo( unsigned CommandID) { if (CommandID < llvm::array_lengthof(Commands)) |