diff options
author | dim <dim@FreeBSD.org> | 2015-06-21 14:00:56 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-06-21 14:00:56 +0000 |
commit | 9dd834653b811ad20382e98a87dff824980c9916 (patch) | |
tree | a764184c2fc9486979b074250b013a0937ee64e5 /lib/Format/TokenAnnotator.h | |
parent | bb9760db9b86e93a638ed430d0a14785f7ff9064 (diff) | |
download | FreeBSD-src-9dd834653b811ad20382e98a87dff824980c9916.zip FreeBSD-src-9dd834653b811ad20382e98a87dff824980c9916.tar.gz |
Vendor import of clang trunk r240225:
https://llvm.org/svn/llvm-project/cfe/trunk@240225
Diffstat (limited to 'lib/Format/TokenAnnotator.h')
-rw-r--r-- | lib/Format/TokenAnnotator.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/Format/TokenAnnotator.h b/lib/Format/TokenAnnotator.h index a948cdb..b8a6be0 100644 --- a/lib/Format/TokenAnnotator.h +++ b/lib/Format/TokenAnnotator.h @@ -59,7 +59,7 @@ public: I->Tok->Previous = Current; Current = Current->Next; Current->Children.clear(); - for (const auto& Child : Node.Children) { + for (const auto &Child : Node.Children) { Children.push_back(new AnnotatedLine(Child)); Current->Children.push_back(Children.back()); } @@ -80,6 +80,12 @@ public: } } + /// \c true if this line starts with the given tokens in order, ignoring + /// comments. + template <typename... Ts> bool startsWith(Ts... Tokens) const { + return startsWith(First, Tokens...); + } + FormatToken *First; FormatToken *Last; @@ -107,6 +113,18 @@ private: // Disallow copying. AnnotatedLine(const AnnotatedLine &) = delete; void operator=(const AnnotatedLine &) = delete; + + template <typename A, typename... Ts> + bool startsWith(FormatToken *Tok, A K1) const { + while (Tok && Tok->is(tok::comment)) + Tok = Tok->Next; + return Tok && Tok->is(K1); + } + + template <typename A, typename... Ts> + bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const { + return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...); + } }; /// \brief Determines extra information about the tokens comprising an |