1 //=== SelectorExtras.h - Helpers for checkers using selectors -----*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SELECTOREXTRAS_H
11 #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SELECTOREXTRAS_H
13 #include "clang/AST/ASTContext.h"
19 static inline Selector getKeywordSelectorImpl(ASTContext &Ctx,
22 SmallVector<IdentifierInfo*, 10> II;
23 II.push_back(&Ctx.Idents.get(First));
25 while (const char *s = va_arg(argp, const char *))
26 II.push_back(&Ctx.Idents.get(s));
28 return Ctx.Selectors.getSelector(II.size(), &II[0]);
31 static inline Selector getKeywordSelector(ASTContext &Ctx, va_list argp) {
32 const char *First = va_arg(argp, const char *);
33 assert(First && "keyword selectors must have at least one argument");
34 return getKeywordSelectorImpl(Ctx, First, argp);
38 static inline Selector getKeywordSelector(ASTContext &Ctx,
39 const char *First, ...) {
41 va_start(argp, First);
42 Selector result = getKeywordSelectorImpl(Ctx, First, argp);
48 static inline void lazyInitKeywordSelector(Selector &Sel, ASTContext &Ctx,
49 const char *First, ...) {
53 va_start(argp, First);
54 Sel = getKeywordSelectorImpl(Ctx, First, argp);
58 static inline void lazyInitNullarySelector(Selector &Sel, ASTContext &Ctx,
62 Sel = GetNullarySelector(Name, Ctx);
65 } // end namespace ento
66 } // end namespace clang