clang  3.9.0
SelectorExtras.h
Go to the documentation of this file.
1 //=== SelectorExtras.h - Helpers for checkers using selectors -----*- C++ -*-=//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SELECTOREXTRAS_H
11 #define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SELECTOREXTRAS_H
12 
13 #include "clang/AST/ASTContext.h"
14 #include <cstdarg>
15 
16 namespace clang {
17 namespace ento {
18 
20  const char *First,
21  va_list argp) {
23  II.push_back(&Ctx.Idents.get(First));
24 
25  while (const char *s = va_arg(argp, const char *))
26  II.push_back(&Ctx.Idents.get(s));
27 
28  return Ctx.Selectors.getSelector(II.size(), &II[0]);
29 }
30 
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);
35 }
36 
37 LLVM_END_WITH_NULL
39  const char *First, ...) {
40  va_list argp;
41  va_start(argp, First);
42  Selector result = getKeywordSelectorImpl(Ctx, First, argp);
43  va_end(argp);
44  return result;
45 }
46 
47 LLVM_END_WITH_NULL
48 static inline void lazyInitKeywordSelector(Selector &Sel, ASTContext &Ctx,
49  const char *First, ...) {
50  if (!Sel.isNull())
51  return;
52  va_list argp;
53  va_start(argp, First);
54  Sel = getKeywordSelectorImpl(Ctx, First, argp);
55  va_end(argp);
56 }
57 
58 static inline void lazyInitNullarySelector(Selector &Sel, ASTContext &Ctx,
59  const char *Name) {
60  if (!Sel.isNull())
61  return;
62  Sel = GetNullarySelector(Name, Ctx);
63 }
64 
65 } // end namespace ento
66 } // end namespace clang
67 
68 #endif
Defines the clang::ASTContext interface.
static Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
Definition: ASTContext.h:2605
Smart pointer class that efficiently represents Objective-C method names.
#define va_end(ap)
Definition: stdarg.h:34
static Selector getKeywordSelector(ASTContext &Ctx, va_list argp)
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4549
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:92
bool isNull() const
Determine whether this is the empty selector.
IdentifierTable & Idents
Definition: ASTContext.h:459
static void lazyInitNullarySelector(Selector &Sel, ASTContext &Ctx, const char *Name)
static Selector getKeywordSelectorImpl(ASTContext &Ctx, const char *First, va_list argp)
#define va_arg(ap, type)
Definition: stdarg.h:35
static LLVM_END_WITH_NULL void lazyInitKeywordSelector(Selector &Sel, ASTContext &Ctx, const char *First,...)
SelectorTable & Selectors
Definition: ASTContext.h:460
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
#define va_start(ap, param)
Definition: stdarg.h:33
__builtin_va_list va_list
Definition: stdarg.h:30
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.