Bug Summary

File:tools/clang/lib/Sema/Sema.cpp
Warning:line 8171, column 9
Null pointer passed as an argument to a 'nonnull' parameter

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name Sema.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-7/lib/clang/7.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/lib/Sema -I /build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema -I /build/llvm-toolchain-snapshot-7~svn329677/tools/clang/include -I /build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include -I /build/llvm-toolchain-snapshot-7~svn329677/build-llvm/include -I /build/llvm-toolchain-snapshot-7~svn329677/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward -internal-isystem /usr/include/clang/7.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-7/lib/clang/7.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/lib/Sema -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fobjc-runtime=gcc -fno-common -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2018-04-11-031539-24776-1 -x c++ /build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp

/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp

1//===--- Sema.cpp - AST Builder and Semantic Analysis Implementation ------===//
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// This file implements the actions class which performs semantic analysis and
11// builds an AST out of a parse stream.
12//
13//===----------------------------------------------------------------------===//
14
15#include "clang/AST/ASTContext.h"
16#include "clang/AST/ASTDiagnostic.h"
17#include "clang/AST/DeclCXX.h"
18#include "clang/AST/DeclFriend.h"
19#include "clang/AST/DeclObjC.h"
20#include "clang/AST/Expr.h"
21#include "clang/AST/ExprCXX.h"
22#include "clang/AST/PrettyDeclStackTrace.h"
23#include "clang/AST/StmtCXX.h"
24#include "clang/Basic/DiagnosticOptions.h"
25#include "clang/Basic/PartialDiagnostic.h"
26#include "clang/Basic/TargetInfo.h"
27#include "clang/Lex/HeaderSearch.h"
28#include "clang/Lex/Preprocessor.h"
29#include "clang/Sema/CXXFieldCollector.h"
30#include "clang/Sema/DelayedDiagnostic.h"
31#include "clang/Sema/ExternalSemaSource.h"
32#include "clang/Sema/Initialization.h"
33#include "clang/Sema/MultiplexExternalSemaSource.h"
34#include "clang/Sema/ObjCMethodList.h"
35#include "clang/Sema/Scope.h"
36#include "clang/Sema/ScopeInfo.h"
37#include "clang/Sema/SemaConsumer.h"
38#include "clang/Sema/SemaInternal.h"
39#include "clang/Sema/TemplateDeduction.h"
40#include "clang/Sema/TemplateInstCallback.h"
41#include "llvm/ADT/DenseMap.h"
42#include "llvm/ADT/SmallSet.h"
43using namespace clang;
44using namespace sema;
45
46SourceLocation Sema::getLocForEndOfToken(SourceLocation Loc, unsigned Offset) {
47 return Lexer::getLocForEndOfToken(Loc, Offset, SourceMgr, LangOpts);
48}
49
50ModuleLoader &Sema::getModuleLoader() const { return PP.getModuleLoader(); }
51
52PrintingPolicy Sema::getPrintingPolicy(const ASTContext &Context,
53 const Preprocessor &PP) {
54 PrintingPolicy Policy = Context.getPrintingPolicy();
55 // Our printing policy is copied over the ASTContext printing policy whenever
56 // a diagnostic is emitted, so recompute it.
57 Policy.Bool = Context.getLangOpts().Bool;
58 if (!Policy.Bool) {
59 if (const MacroInfo *BoolMacro = PP.getMacroInfo(Context.getBoolName())) {
60 Policy.Bool = BoolMacro->isObjectLike() &&
61 BoolMacro->getNumTokens() == 1 &&
62 BoolMacro->getReplacementToken(0).is(tok::kw__Bool);
63 }
64 }
65
66 return Policy;
67}
68
69void Sema::ActOnTranslationUnitScope(Scope *S) {
70 TUScope = S;
71 PushDeclContext(S, Context.getTranslationUnitDecl());
72}
73
74namespace clang {
75namespace sema {
76
77class SemaPPCallbacks : public PPCallbacks {
78 Sema *S = nullptr;
79 llvm::SmallVector<SourceLocation, 8> IncludeStack;
80
81public:
82 void set(Sema &S) { this->S = &S; }
83
84 void reset() { S = nullptr; }
85
86 virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
87 SrcMgr::CharacteristicKind FileType,
88 FileID PrevFID) override {
89 if (!S)
90 return;
91 switch (Reason) {
92 case EnterFile: {
93 SourceManager &SM = S->getSourceManager();
94 SourceLocation IncludeLoc = SM.getIncludeLoc(SM.getFileID(Loc));
95 if (IncludeLoc.isValid()) {
96 IncludeStack.push_back(IncludeLoc);
97 S->DiagnoseNonDefaultPragmaPack(
98 Sema::PragmaPackDiagnoseKind::NonDefaultStateAtInclude, IncludeLoc);
99 }
100 break;
101 }
102 case ExitFile:
103 if (!IncludeStack.empty())
104 S->DiagnoseNonDefaultPragmaPack(
105 Sema::PragmaPackDiagnoseKind::ChangedStateAtExit,
106 IncludeStack.pop_back_val());
107 break;
108 default:
109 break;
110 }
111 }
112};
113
114} // end namespace sema
115} // end namespace clang
116
117Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
118 TranslationUnitKind TUKind, CodeCompleteConsumer *CodeCompleter)
119 : ExternalSource(nullptr), isMultiplexExternalSource(false),
120 FPFeatures(pp.getLangOpts()), LangOpts(pp.getLangOpts()), PP(pp),
121 Context(ctxt), Consumer(consumer), Diags(PP.getDiagnostics()),
122 SourceMgr(PP.getSourceManager()), CollectStats(false),
123 CodeCompleter(CodeCompleter), CurContext(nullptr),
124 OriginalLexicalContext(nullptr), MSStructPragmaOn(false),
125 MSPointerToMemberRepresentationMethod(
126 LangOpts.getMSPointerToMemberRepresentationMethod()),
127 VtorDispStack(MSVtorDispAttr::Mode(LangOpts.VtorDispMode)), PackStack(0),
128 DataSegStack(nullptr), BSSSegStack(nullptr), ConstSegStack(nullptr),
129 CodeSegStack(nullptr), CurInitSeg(nullptr), VisContext(nullptr),
130 PragmaAttributeCurrentTargetDecl(nullptr),
131 IsBuildingRecoveryCallExpr(false), Cleanup{}, LateTemplateParser(nullptr),
132 LateTemplateParserCleanup(nullptr), OpaqueParser(nullptr), IdResolver(pp),
133 StdExperimentalNamespaceCache(nullptr), StdInitializerList(nullptr),
134 CXXTypeInfoDecl(nullptr), MSVCGuidDecl(nullptr), NSNumberDecl(nullptr),
135 NSValueDecl(nullptr), NSStringDecl(nullptr),
136 StringWithUTF8StringMethod(nullptr),
137 ValueWithBytesObjCTypeMethod(nullptr), NSArrayDecl(nullptr),
138 ArrayWithObjectsMethod(nullptr), NSDictionaryDecl(nullptr),
139 DictionaryWithObjectsMethod(nullptr), GlobalNewDeleteDeclared(false),
140 TUKind(TUKind), NumSFINAEErrors(0), AccessCheckingSFINAE(false),
141 InNonInstantiationSFINAEContext(false), NonInstantiationEntries(0),
142 ArgumentPackSubstitutionIndex(-1), CurrentInstantiationScope(nullptr),
143 DisableTypoCorrection(false), TyposCorrected(0), AnalysisWarnings(*this),
144 ThreadSafetyDeclCache(nullptr), VarDataSharingAttributesStack(nullptr),
145 CurScope(nullptr), Ident_super(nullptr), Ident___float128(nullptr) {
146 TUScope = nullptr;
147
148 LoadedExternalKnownNamespaces = false;
149 for (unsigned I = 0; I != NSAPI::NumNSNumberLiteralMethods; ++I)
150 NSNumberLiteralMethods[I] = nullptr;
151
152 if (getLangOpts().ObjC1)
153 NSAPIObj.reset(new NSAPI(Context));
154
155 if (getLangOpts().CPlusPlus)
156 FieldCollector.reset(new CXXFieldCollector());
157
158 // Tell diagnostics how to render things from the AST library.
159 Diags.SetArgToStringFn(&FormatASTNodeDiagnosticArgument, &Context);
160
161 ExprEvalContexts.emplace_back(
162 ExpressionEvaluationContext::PotentiallyEvaluated, 0, CleanupInfo{},
163 nullptr, false);
164
165 PreallocatedFunctionScope.reset(new FunctionScopeInfo(Diags));
166
167 // Initilization of data sharing attributes stack for OpenMP
168 InitDataSharingAttributesStack();
169
170 std::unique_ptr<sema::SemaPPCallbacks> Callbacks =
171 llvm::make_unique<sema::SemaPPCallbacks>();
172 SemaPPCallbackHandler = Callbacks.get();
173 PP.addPPCallbacks(std::move(Callbacks));
174 SemaPPCallbackHandler->set(*this);
175}
176
177void Sema::addImplicitTypedef(StringRef Name, QualType T) {
178 DeclarationName DN = &Context.Idents.get(Name);
179 if (IdResolver.begin(DN) == IdResolver.end())
180 PushOnScopeChains(Context.buildImplicitTypedef(T, Name), TUScope);
181}
182
183void Sema::Initialize() {
184 if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
185 SC->InitializeSema(*this);
186
187 // Tell the external Sema source about this Sema object.
188 if (ExternalSemaSource *ExternalSema
189 = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
190 ExternalSema->InitializeSema(*this);
191
192 // This needs to happen after ExternalSemaSource::InitializeSema(this) or we
193 // will not be able to merge any duplicate __va_list_tag decls correctly.
194 VAListTagName = PP.getIdentifierInfo("__va_list_tag");
195
196 if (!TUScope)
197 return;
198
199 // Initialize predefined 128-bit integer types, if needed.
200 if (Context.getTargetInfo().hasInt128Type()) {
201 // If either of the 128-bit integer types are unavailable to name lookup,
202 // define them now.
203 DeclarationName Int128 = &Context.Idents.get("__int128_t");
204 if (IdResolver.begin(Int128) == IdResolver.end())
205 PushOnScopeChains(Context.getInt128Decl(), TUScope);
206
207 DeclarationName UInt128 = &Context.Idents.get("__uint128_t");
208 if (IdResolver.begin(UInt128) == IdResolver.end())
209 PushOnScopeChains(Context.getUInt128Decl(), TUScope);
210 }
211
212
213 // Initialize predefined Objective-C types:
214 if (getLangOpts().ObjC1) {
215 // If 'SEL' does not yet refer to any declarations, make it refer to the
216 // predefined 'SEL'.
217 DeclarationName SEL = &Context.Idents.get("SEL");
218 if (IdResolver.begin(SEL) == IdResolver.end())
219 PushOnScopeChains(Context.getObjCSelDecl(), TUScope);
220
221 // If 'id' does not yet refer to any declarations, make it refer to the
222 // predefined 'id'.
223 DeclarationName Id = &Context.Idents.get("id");
224 if (IdResolver.begin(Id) == IdResolver.end())
225 PushOnScopeChains(Context.getObjCIdDecl(), TUScope);
226
227 // Create the built-in typedef for 'Class'.
228 DeclarationName Class = &Context.Idents.get("Class");
229 if (IdResolver.begin(Class) == IdResolver.end())
230 PushOnScopeChains(Context.getObjCClassDecl(), TUScope);
231
232 // Create the built-in forward declaratino for 'Protocol'.
233 DeclarationName Protocol = &Context.Idents.get("Protocol");
234 if (IdResolver.begin(Protocol) == IdResolver.end())
235 PushOnScopeChains(Context.getObjCProtocolDecl(), TUScope);
236 }
237
238 // Create the internal type for the *StringMakeConstantString builtins.
239 DeclarationName ConstantString = &Context.Idents.get("__NSConstantString");
240 if (IdResolver.begin(ConstantString) == IdResolver.end())
241 PushOnScopeChains(Context.getCFConstantStringDecl(), TUScope);
242
243 // Initialize Microsoft "predefined C++ types".
244 if (getLangOpts().MSVCCompat) {
245 if (getLangOpts().CPlusPlus &&
246 IdResolver.begin(&Context.Idents.get("type_info")) == IdResolver.end())
247 PushOnScopeChains(Context.buildImplicitRecord("type_info", TTK_Class),
248 TUScope);
249
250 addImplicitTypedef("size_t", Context.getSizeType());
251 }
252
253 // Initialize predefined OpenCL types and supported extensions and (optional)
254 // core features.
255 if (getLangOpts().OpenCL) {
256 getOpenCLOptions().addSupport(Context.getTargetInfo().getSupportedOpenCLOpts());
257 getOpenCLOptions().enableSupportedCore(getLangOpts().OpenCLVersion);
258 addImplicitTypedef("sampler_t", Context.OCLSamplerTy);
259 addImplicitTypedef("event_t", Context.OCLEventTy);
260 if (getLangOpts().OpenCLVersion >= 200) {
261 addImplicitTypedef("clk_event_t", Context.OCLClkEventTy);
262 addImplicitTypedef("queue_t", Context.OCLQueueTy);
263 addImplicitTypedef("reserve_id_t", Context.OCLReserveIDTy);
264 addImplicitTypedef("atomic_int", Context.getAtomicType(Context.IntTy));
265 addImplicitTypedef("atomic_uint",
266 Context.getAtomicType(Context.UnsignedIntTy));
267 auto AtomicLongT = Context.getAtomicType(Context.LongTy);
268 addImplicitTypedef("atomic_long", AtomicLongT);
269 auto AtomicULongT = Context.getAtomicType(Context.UnsignedLongTy);
270 addImplicitTypedef("atomic_ulong", AtomicULongT);
271 addImplicitTypedef("atomic_float",
272 Context.getAtomicType(Context.FloatTy));
273 auto AtomicDoubleT = Context.getAtomicType(Context.DoubleTy);
274 addImplicitTypedef("atomic_double", AtomicDoubleT);
275 // OpenCLC v2.0, s6.13.11.6 requires that atomic_flag is implemented as
276 // 32-bit integer and OpenCLC v2.0, s6.1.1 int is always 32-bit wide.
277 addImplicitTypedef("atomic_flag", Context.getAtomicType(Context.IntTy));
278 auto AtomicIntPtrT = Context.getAtomicType(Context.getIntPtrType());
279 addImplicitTypedef("atomic_intptr_t", AtomicIntPtrT);
280 auto AtomicUIntPtrT = Context.getAtomicType(Context.getUIntPtrType());
281 addImplicitTypedef("atomic_uintptr_t", AtomicUIntPtrT);
282 auto AtomicSizeT = Context.getAtomicType(Context.getSizeType());
283 addImplicitTypedef("atomic_size_t", AtomicSizeT);
284 auto AtomicPtrDiffT = Context.getAtomicType(Context.getPointerDiffType());
285 addImplicitTypedef("atomic_ptrdiff_t", AtomicPtrDiffT);
286
287 // OpenCL v2.0 s6.13.11.6:
288 // - The atomic_long and atomic_ulong types are supported if the
289 // cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics
290 // extensions are supported.
291 // - The atomic_double type is only supported if double precision
292 // is supported and the cl_khr_int64_base_atomics and
293 // cl_khr_int64_extended_atomics extensions are supported.
294 // - If the device address space is 64-bits, the data types
295 // atomic_intptr_t, atomic_uintptr_t, atomic_size_t and
296 // atomic_ptrdiff_t are supported if the cl_khr_int64_base_atomics and
297 // cl_khr_int64_extended_atomics extensions are supported.
298 std::vector<QualType> Atomic64BitTypes;
299 Atomic64BitTypes.push_back(AtomicLongT);
300 Atomic64BitTypes.push_back(AtomicULongT);
301 Atomic64BitTypes.push_back(AtomicDoubleT);
302 if (Context.getTypeSize(AtomicSizeT) == 64) {
303 Atomic64BitTypes.push_back(AtomicSizeT);
304 Atomic64BitTypes.push_back(AtomicIntPtrT);
305 Atomic64BitTypes.push_back(AtomicUIntPtrT);
306 Atomic64BitTypes.push_back(AtomicPtrDiffT);
307 }
308 for (auto &I : Atomic64BitTypes)
309 setOpenCLExtensionForType(I,
310 "cl_khr_int64_base_atomics cl_khr_int64_extended_atomics");
311
312 setOpenCLExtensionForType(AtomicDoubleT, "cl_khr_fp64");
313 }
314
315 setOpenCLExtensionForType(Context.DoubleTy, "cl_khr_fp64");
316
317#define GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext)setOpenCLExtensionForType(Context.Id, Ext); \
318 setOpenCLExtensionForType(Context.Id, Ext);
319#include "clang/Basic/OpenCLImageTypes.def"
320 };
321
322 if (Context.getTargetInfo().hasBuiltinMSVaList()) {
323 DeclarationName MSVaList = &Context.Idents.get("__builtin_ms_va_list");
324 if (IdResolver.begin(MSVaList) == IdResolver.end())
325 PushOnScopeChains(Context.getBuiltinMSVaListDecl(), TUScope);
326 }
327
328 DeclarationName BuiltinVaList = &Context.Idents.get("__builtin_va_list");
329 if (IdResolver.begin(BuiltinVaList) == IdResolver.end())
330 PushOnScopeChains(Context.getBuiltinVaListDecl(), TUScope);
331}
332
333Sema::~Sema() {
334 if (VisContext) FreeVisContext();
335
336 // Kill all the active scopes.
337 for (sema::FunctionScopeInfo *FSI : FunctionScopes)
338 if (FSI != PreallocatedFunctionScope.get())
339 delete FSI;
340
341 // Tell the SemaConsumer to forget about us; we're going out of scope.
342 if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
343 SC->ForgetSema();
344
345 // Detach from the external Sema source.
346 if (ExternalSemaSource *ExternalSema
347 = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
348 ExternalSema->ForgetSema();
349
350 // If Sema's ExternalSource is the multiplexer - we own it.
351 if (isMultiplexExternalSource)
352 delete ExternalSource;
353
354 threadSafety::threadSafetyCleanup(ThreadSafetyDeclCache);
355
356 // Destroys data sharing attributes stack for OpenMP
357 DestroyDataSharingAttributesStack();
358
359 // Detach from the PP callback handler which outlives Sema since it's owned
360 // by the preprocessor.
361 SemaPPCallbackHandler->reset();
362
363 assert(DelayedTypos.empty() && "Uncorrected typos!")(static_cast <bool> (DelayedTypos.empty() && "Uncorrected typos!"
) ? void (0) : __assert_fail ("DelayedTypos.empty() && \"Uncorrected typos!\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 363, __extension__ __PRETTY_FUNCTION__))
;
364}
365
366/// makeUnavailableInSystemHeader - There is an error in the current
367/// context. If we're still in a system header, and we can plausibly
368/// make the relevant declaration unavailable instead of erroring, do
369/// so and return true.
370bool Sema::makeUnavailableInSystemHeader(SourceLocation loc,
371 UnavailableAttr::ImplicitReason reason) {
372 // If we're not in a function, it's an error.
373 FunctionDecl *fn = dyn_cast<FunctionDecl>(CurContext);
374 if (!fn) return false;
1
Assuming 'fn' is non-null
2
Taking false branch
375
376 // If we're in template instantiation, it's an error.
377 if (inTemplateInstantiation())
3
Taking false branch
378 return false;
379
380 // If that function's not in a system header, it's an error.
381 if (!Context.getSourceManager().isInSystemHeader(loc))
4
Taking false branch
382 return false;
383
384 // If the function is already unavailable, it's not an error.
385 if (fn->hasAttr<UnavailableAttr>()) return true;
5
Taking false branch
386
387 fn->addAttr(UnavailableAttr::CreateImplicit(Context, "", reason, loc));
6
Calling 'UnavailableAttr::CreateImplicit'
388 return true;
389}
390
391ASTMutationListener *Sema::getASTMutationListener() const {
392 return getASTConsumer().GetASTMutationListener();
393}
394
395///\brief Registers an external source. If an external source already exists,
396/// creates a multiplex external source and appends to it.
397///
398///\param[in] E - A non-null external sema source.
399///
400void Sema::addExternalSource(ExternalSemaSource *E) {
401 assert(E && "Cannot use with NULL ptr")(static_cast <bool> (E && "Cannot use with NULL ptr"
) ? void (0) : __assert_fail ("E && \"Cannot use with NULL ptr\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 401, __extension__ __PRETTY_FUNCTION__))
;
402
403 if (!ExternalSource) {
404 ExternalSource = E;
405 return;
406 }
407
408 if (isMultiplexExternalSource)
409 static_cast<MultiplexExternalSemaSource*>(ExternalSource)->addSource(*E);
410 else {
411 ExternalSource = new MultiplexExternalSemaSource(*ExternalSource, *E);
412 isMultiplexExternalSource = true;
413 }
414}
415
416/// \brief Print out statistics about the semantic analysis.
417void Sema::PrintStats() const {
418 llvm::errs() << "\n*** Semantic Analysis Stats:\n";
419 llvm::errs() << NumSFINAEErrors << " SFINAE diagnostics trapped.\n";
420
421 BumpAlloc.PrintStats();
422 AnalysisWarnings.PrintStats();
423}
424
425void Sema::diagnoseNullableToNonnullConversion(QualType DstType,
426 QualType SrcType,
427 SourceLocation Loc) {
428 Optional<NullabilityKind> ExprNullability = SrcType->getNullability(Context);
429 if (!ExprNullability || *ExprNullability != NullabilityKind::Nullable)
430 return;
431
432 Optional<NullabilityKind> TypeNullability = DstType->getNullability(Context);
433 if (!TypeNullability || *TypeNullability != NullabilityKind::NonNull)
434 return;
435
436 Diag(Loc, diag::warn_nullability_lost) << SrcType << DstType;
437}
438
439void Sema::diagnoseZeroToNullptrConversion(CastKind Kind, const Expr* E) {
440 if (Diags.isIgnored(diag::warn_zero_as_null_pointer_constant,
441 E->getLocStart()))
442 return;
443 // nullptr only exists from C++11 on, so don't warn on its absence earlier.
444 if (!getLangOpts().CPlusPlus11)
445 return;
446
447 if (Kind != CK_NullToPointer && Kind != CK_NullToMemberPointer)
448 return;
449 if (E->IgnoreParenImpCasts()->getType()->isNullPtrType())
450 return;
451
452 // If it is a macro from system header, and if the macro name is not "NULL",
453 // do not warn.
454 SourceLocation MaybeMacroLoc = E->getLocStart();
455 if (Diags.getSuppressSystemWarnings() &&
456 SourceMgr.isInSystemMacro(MaybeMacroLoc) &&
457 !findMacroSpelling(MaybeMacroLoc, "NULL"))
458 return;
459
460 Diag(E->getLocStart(), diag::warn_zero_as_null_pointer_constant)
461 << FixItHint::CreateReplacement(E->getSourceRange(), "nullptr");
462}
463
464/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
465/// If there is already an implicit cast, merge into the existing one.
466/// The result is of the given category.
467ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
468 CastKind Kind, ExprValueKind VK,
469 const CXXCastPath *BasePath,
470 CheckedConversionKind CCK) {
471#ifndef NDEBUG
472 if (VK == VK_RValue && !E->isRValue()) {
473 switch (Kind) {
474 default:
475 llvm_unreachable("can't implicitly cast lvalue to rvalue with this cast "::llvm::llvm_unreachable_internal("can't implicitly cast lvalue to rvalue with this cast "
"kind", "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 476)
476 "kind")::llvm::llvm_unreachable_internal("can't implicitly cast lvalue to rvalue with this cast "
"kind", "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 476)
;
477 case CK_LValueToRValue:
478 case CK_ArrayToPointerDecay:
479 case CK_FunctionToPointerDecay:
480 case CK_ToVoid:
481 break;
482 }
483 }
484 assert((VK == VK_RValue || !E->isRValue()) && "can't cast rvalue to lvalue")(static_cast <bool> ((VK == VK_RValue || !E->isRValue
()) && "can't cast rvalue to lvalue") ? void (0) : __assert_fail
("(VK == VK_RValue || !E->isRValue()) && \"can't cast rvalue to lvalue\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 484, __extension__ __PRETTY_FUNCTION__))
;
485#endif
486
487 diagnoseNullableToNonnullConversion(Ty, E->getType(), E->getLocStart());
488 diagnoseZeroToNullptrConversion(Kind, E);
489
490 QualType ExprTy = Context.getCanonicalType(E->getType());
491 QualType TypeTy = Context.getCanonicalType(Ty);
492
493 if (ExprTy == TypeTy)
494 return E;
495
496 // C++1z [conv.array]: The temporary materialization conversion is applied.
497 // We also use this to fuel C++ DR1213, which applies to C++11 onwards.
498 if (Kind == CK_ArrayToPointerDecay && getLangOpts().CPlusPlus &&
499 E->getValueKind() == VK_RValue) {
500 // The temporary is an lvalue in C++98 and an xvalue otherwise.
501 ExprResult Materialized = CreateMaterializeTemporaryExpr(
502 E->getType(), E, !getLangOpts().CPlusPlus11);
503 if (Materialized.isInvalid())
504 return ExprError();
505 E = Materialized.get();
506 }
507
508 if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(E)) {
509 if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
510 ImpCast->setType(Ty);
511 ImpCast->setValueKind(VK);
512 return E;
513 }
514 }
515
516 return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK);
517}
518
519/// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
520/// to the conversion from scalar type ScalarTy to the Boolean type.
521CastKind Sema::ScalarTypeToBooleanCastKind(QualType ScalarTy) {
522 switch (ScalarTy->getScalarTypeKind()) {
523 case Type::STK_Bool: return CK_NoOp;
524 case Type::STK_CPointer: return CK_PointerToBoolean;
525 case Type::STK_BlockPointer: return CK_PointerToBoolean;
526 case Type::STK_ObjCObjectPointer: return CK_PointerToBoolean;
527 case Type::STK_MemberPointer: return CK_MemberPointerToBoolean;
528 case Type::STK_Integral: return CK_IntegralToBoolean;
529 case Type::STK_Floating: return CK_FloatingToBoolean;
530 case Type::STK_IntegralComplex: return CK_IntegralComplexToBoolean;
531 case Type::STK_FloatingComplex: return CK_FloatingComplexToBoolean;
532 }
533 llvm_unreachable("unknown scalar type kind")::llvm::llvm_unreachable_internal("unknown scalar type kind",
"/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 533)
;
534}
535
536/// \brief Used to prune the decls of Sema's UnusedFileScopedDecls vector.
537static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) {
538 if (D->getMostRecentDecl()->isUsed())
539 return true;
540
541 if (D->isExternallyVisible())
542 return true;
543
544 if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
545 // If this is a function template and none of its specializations is used,
546 // we should warn.
547 if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
548 for (const auto *Spec : Template->specializations())
549 if (ShouldRemoveFromUnused(SemaRef, Spec))
550 return true;
551
552 // UnusedFileScopedDecls stores the first declaration.
553 // The declaration may have become definition so check again.
554 const FunctionDecl *DeclToCheck;
555 if (FD->hasBody(DeclToCheck))
556 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
557
558 // Later redecls may add new information resulting in not having to warn,
559 // so check again.
560 DeclToCheck = FD->getMostRecentDecl();
561 if (DeclToCheck != FD)
562 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
563 }
564
565 if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
566 // If a variable usable in constant expressions is referenced,
567 // don't warn if it isn't used: if the value of a variable is required
568 // for the computation of a constant expression, it doesn't make sense to
569 // warn even if the variable isn't odr-used. (isReferenced doesn't
570 // precisely reflect that, but it's a decent approximation.)
571 if (VD->isReferenced() &&
572 VD->isUsableInConstantExpressions(SemaRef->Context))
573 return true;
574
575 if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
576 // If this is a variable template and none of its specializations is used,
577 // we should warn.
578 for (const auto *Spec : Template->specializations())
579 if (ShouldRemoveFromUnused(SemaRef, Spec))
580 return true;
581
582 // UnusedFileScopedDecls stores the first declaration.
583 // The declaration may have become definition so check again.
584 const VarDecl *DeclToCheck = VD->getDefinition();
585 if (DeclToCheck)
586 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
587
588 // Later redecls may add new information resulting in not having to warn,
589 // so check again.
590 DeclToCheck = VD->getMostRecentDecl();
591 if (DeclToCheck != VD)
592 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
593 }
594
595 return false;
596}
597
598static bool isFunctionOrVarDeclExternC(NamedDecl *ND) {
599 if (auto *FD = dyn_cast<FunctionDecl>(ND))
600 return FD->isExternC();
601 return cast<VarDecl>(ND)->isExternC();
602}
603
604/// Determine whether ND is an external-linkage function or variable whose
605/// type has no linkage.
606bool Sema::isExternalWithNoLinkageType(ValueDecl *VD) {
607 // Note: it's not quite enough to check whether VD has UniqueExternalLinkage,
608 // because we also want to catch the case where its type has VisibleNoLinkage,
609 // which does not affect the linkage of VD.
610 return getLangOpts().CPlusPlus && VD->hasExternalFormalLinkage() &&
611 !isExternalFormalLinkage(VD->getType()->getLinkage()) &&
612 !isFunctionOrVarDeclExternC(VD);
613}
614
615/// Obtains a sorted list of functions and variables that are undefined but
616/// ODR-used.
617void Sema::getUndefinedButUsed(
618 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> > &Undefined) {
619 for (const auto &UndefinedUse : UndefinedButUsed) {
620 NamedDecl *ND = UndefinedUse.first;
621
622 // Ignore attributes that have become invalid.
623 if (ND->isInvalidDecl()) continue;
624
625 // __attribute__((weakref)) is basically a definition.
626 if (ND->hasAttr<WeakRefAttr>()) continue;
627
628 if (isa<CXXDeductionGuideDecl>(ND))
629 continue;
630
631 if (ND->hasAttr<DLLImportAttr>() || ND->hasAttr<DLLExportAttr>()) {
632 // An exported function will always be emitted when defined, so even if
633 // the function is inline, it doesn't have to be emitted in this TU. An
634 // imported function implies that it has been exported somewhere else.
635 continue;
636 }
637
638 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
639 if (FD->isDefined())
640 continue;
641 if (FD->isExternallyVisible() &&
642 !isExternalWithNoLinkageType(FD) &&
643 !FD->getMostRecentDecl()->isInlined())
644 continue;
645 } else {
646 auto *VD = cast<VarDecl>(ND);
647 if (VD->hasDefinition() != VarDecl::DeclarationOnly)
648 continue;
649 if (VD->isExternallyVisible() &&
650 !isExternalWithNoLinkageType(VD) &&
651 !VD->getMostRecentDecl()->isInline())
652 continue;
653 }
654
655 Undefined.push_back(std::make_pair(ND, UndefinedUse.second));
656 }
657}
658
659/// checkUndefinedButUsed - Check for undefined objects with internal linkage
660/// or that are inline.
661static void checkUndefinedButUsed(Sema &S) {
662 if (S.UndefinedButUsed.empty()) return;
663
664 // Collect all the still-undefined entities with internal linkage.
665 SmallVector<std::pair<NamedDecl *, SourceLocation>, 16> Undefined;
666 S.getUndefinedButUsed(Undefined);
667 if (Undefined.empty()) return;
668
669 for (auto Undef : Undefined) {
670 ValueDecl *VD = cast<ValueDecl>(Undef.first);
671 SourceLocation UseLoc = Undef.second;
672
673 if (S.isExternalWithNoLinkageType(VD)) {
674 // C++ [basic.link]p8:
675 // A type without linkage shall not be used as the type of a variable
676 // or function with external linkage unless
677 // -- the entity has C language linkage
678 // -- the entity is not odr-used or is defined in the same TU
679 //
680 // As an extension, accept this in cases where the type is externally
681 // visible, since the function or variable actually can be defined in
682 // another translation unit in that case.
683 S.Diag(VD->getLocation(), isExternallyVisible(VD->getType()->getLinkage())
684 ? diag::ext_undefined_internal_type
685 : diag::err_undefined_internal_type)
686 << isa<VarDecl>(VD) << VD;
687 } else if (!VD->isExternallyVisible()) {
688 // FIXME: We can promote this to an error. The function or variable can't
689 // be defined anywhere else, so the program must necessarily violate the
690 // one definition rule.
691 S.Diag(VD->getLocation(), diag::warn_undefined_internal)
692 << isa<VarDecl>(VD) << VD;
693 } else if (auto *FD = dyn_cast<FunctionDecl>(VD)) {
694 (void)FD;
695 assert(FD->getMostRecentDecl()->isInlined() &&(static_cast <bool> (FD->getMostRecentDecl()->isInlined
() && "used object requires definition but isn't inline or internal?"
) ? void (0) : __assert_fail ("FD->getMostRecentDecl()->isInlined() && \"used object requires definition but isn't inline or internal?\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 696, __extension__ __PRETTY_FUNCTION__))
696 "used object requires definition but isn't inline or internal?")(static_cast <bool> (FD->getMostRecentDecl()->isInlined
() && "used object requires definition but isn't inline or internal?"
) ? void (0) : __assert_fail ("FD->getMostRecentDecl()->isInlined() && \"used object requires definition but isn't inline or internal?\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 696, __extension__ __PRETTY_FUNCTION__))
;
697 // FIXME: This is ill-formed; we should reject.
698 S.Diag(VD->getLocation(), diag::warn_undefined_inline) << VD;
699 } else {
700 assert(cast<VarDecl>(VD)->getMostRecentDecl()->isInline() &&(static_cast <bool> (cast<VarDecl>(VD)->getMostRecentDecl
()->isInline() && "used var requires definition but isn't inline or internal?"
) ? void (0) : __assert_fail ("cast<VarDecl>(VD)->getMostRecentDecl()->isInline() && \"used var requires definition but isn't inline or internal?\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 701, __extension__ __PRETTY_FUNCTION__))
701 "used var requires definition but isn't inline or internal?")(static_cast <bool> (cast<VarDecl>(VD)->getMostRecentDecl
()->isInline() && "used var requires definition but isn't inline or internal?"
) ? void (0) : __assert_fail ("cast<VarDecl>(VD)->getMostRecentDecl()->isInline() && \"used var requires definition but isn't inline or internal?\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 701, __extension__ __PRETTY_FUNCTION__))
;
702 S.Diag(VD->getLocation(), diag::err_undefined_inline_var) << VD;
703 }
704 if (UseLoc.isValid())
705 S.Diag(UseLoc, diag::note_used_here);
706 }
707
708 S.UndefinedButUsed.clear();
709}
710
711void Sema::LoadExternalWeakUndeclaredIdentifiers() {
712 if (!ExternalSource)
713 return;
714
715 SmallVector<std::pair<IdentifierInfo *, WeakInfo>, 4> WeakIDs;
716 ExternalSource->ReadWeakUndeclaredIdentifiers(WeakIDs);
717 for (auto &WeakID : WeakIDs)
718 WeakUndeclaredIdentifiers.insert(WeakID);
719}
720
721
722typedef llvm::DenseMap<const CXXRecordDecl*, bool> RecordCompleteMap;
723
724/// \brief Returns true, if all methods and nested classes of the given
725/// CXXRecordDecl are defined in this translation unit.
726///
727/// Should only be called from ActOnEndOfTranslationUnit so that all
728/// definitions are actually read.
729static bool MethodsAndNestedClassesComplete(const CXXRecordDecl *RD,
730 RecordCompleteMap &MNCComplete) {
731 RecordCompleteMap::iterator Cache = MNCComplete.find(RD);
732 if (Cache != MNCComplete.end())
733 return Cache->second;
734 if (!RD->isCompleteDefinition())
735 return false;
736 bool Complete = true;
737 for (DeclContext::decl_iterator I = RD->decls_begin(),
738 E = RD->decls_end();
739 I != E && Complete; ++I) {
740 if (const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(*I))
741 Complete = M->isDefined() || M->isDefaulted() ||
742 (M->isPure() && !isa<CXXDestructorDecl>(M));
743 else if (const FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(*I))
744 // If the template function is marked as late template parsed at this
745 // point, it has not been instantiated and therefore we have not
746 // performed semantic analysis on it yet, so we cannot know if the type
747 // can be considered complete.
748 Complete = !F->getTemplatedDecl()->isLateTemplateParsed() &&
749 F->getTemplatedDecl()->isDefined();
750 else if (const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) {
751 if (R->isInjectedClassName())
752 continue;
753 if (R->hasDefinition())
754 Complete = MethodsAndNestedClassesComplete(R->getDefinition(),
755 MNCComplete);
756 else
757 Complete = false;
758 }
759 }
760 MNCComplete[RD] = Complete;
761 return Complete;
762}
763
764/// \brief Returns true, if the given CXXRecordDecl is fully defined in this
765/// translation unit, i.e. all methods are defined or pure virtual and all
766/// friends, friend functions and nested classes are fully defined in this
767/// translation unit.
768///
769/// Should only be called from ActOnEndOfTranslationUnit so that all
770/// definitions are actually read.
771static bool IsRecordFullyDefined(const CXXRecordDecl *RD,
772 RecordCompleteMap &RecordsComplete,
773 RecordCompleteMap &MNCComplete) {
774 RecordCompleteMap::iterator Cache = RecordsComplete.find(RD);
775 if (Cache != RecordsComplete.end())
776 return Cache->second;
777 bool Complete = MethodsAndNestedClassesComplete(RD, MNCComplete);
778 for (CXXRecordDecl::friend_iterator I = RD->friend_begin(),
779 E = RD->friend_end();
780 I != E && Complete; ++I) {
781 // Check if friend classes and methods are complete.
782 if (TypeSourceInfo *TSI = (*I)->getFriendType()) {
783 // Friend classes are available as the TypeSourceInfo of the FriendDecl.
784 if (CXXRecordDecl *FriendD = TSI->getType()->getAsCXXRecordDecl())
785 Complete = MethodsAndNestedClassesComplete(FriendD, MNCComplete);
786 else
787 Complete = false;
788 } else {
789 // Friend functions are available through the NamedDecl of FriendDecl.
790 if (const FunctionDecl *FD =
791 dyn_cast<FunctionDecl>((*I)->getFriendDecl()))
792 Complete = FD->isDefined();
793 else
794 // This is a template friend, give up.
795 Complete = false;
796 }
797 }
798 RecordsComplete[RD] = Complete;
799 return Complete;
800}
801
802void Sema::emitAndClearUnusedLocalTypedefWarnings() {
803 if (ExternalSource)
804 ExternalSource->ReadUnusedLocalTypedefNameCandidates(
805 UnusedLocalTypedefNameCandidates);
806 for (const TypedefNameDecl *TD : UnusedLocalTypedefNameCandidates) {
807 if (TD->isReferenced())
808 continue;
809 Diag(TD->getLocation(), diag::warn_unused_local_typedef)
810 << isa<TypeAliasDecl>(TD) << TD->getDeclName();
811 }
812 UnusedLocalTypedefNameCandidates.clear();
813}
814
815/// This is called before the very first declaration in the translation unit
816/// is parsed. Note that the ASTContext may have already injected some
817/// declarations.
818void Sema::ActOnStartOfTranslationUnit() {
819 if (getLangOpts().ModulesTS) {
820 SourceLocation StartOfTU =
821 SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
822
823 // We start in the global module; all those declarations are implicitly
824 // module-private (though they do not have module linkage).
825 auto &Map = PP.getHeaderSearchInfo().getModuleMap();
826 auto *GlobalModule = Map.createGlobalModuleForInterfaceUnit(StartOfTU);
827 assert(GlobalModule && "module creation should not fail")(static_cast <bool> (GlobalModule && "module creation should not fail"
) ? void (0) : __assert_fail ("GlobalModule && \"module creation should not fail\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 827, __extension__ __PRETTY_FUNCTION__))
;
828
829 // Enter the scope of the global module.
830 ModuleScopes.push_back({});
831 ModuleScopes.back().Module = GlobalModule;
832 VisibleModules.setVisible(GlobalModule, StartOfTU);
833
834 // All declarations created from now on are owned by the global module.
835 auto *TU = Context.getTranslationUnitDecl();
836 TU->setModuleOwnershipKind(Decl::ModuleOwnershipKind::Visible);
837 TU->setLocalOwningModule(GlobalModule);
838 }
839}
840
841/// ActOnEndOfTranslationUnit - This is called at the very end of the
842/// translation unit when EOF is reached and all but the top-level scope is
843/// popped.
844void Sema::ActOnEndOfTranslationUnit() {
845 assert(DelayedDiagnostics.getCurrentPool() == nullptr(static_cast <bool> (DelayedDiagnostics.getCurrentPool(
) == nullptr && "reached end of translation unit with a pool attached?"
) ? void (0) : __assert_fail ("DelayedDiagnostics.getCurrentPool() == nullptr && \"reached end of translation unit with a pool attached?\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 846, __extension__ __PRETTY_FUNCTION__))
846 && "reached end of translation unit with a pool attached?")(static_cast <bool> (DelayedDiagnostics.getCurrentPool(
) == nullptr && "reached end of translation unit with a pool attached?"
) ? void (0) : __assert_fail ("DelayedDiagnostics.getCurrentPool() == nullptr && \"reached end of translation unit with a pool attached?\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 846, __extension__ __PRETTY_FUNCTION__))
;
847
848 // If code completion is enabled, don't perform any end-of-translation-unit
849 // work.
850 if (PP.isCodeCompletionEnabled())
851 return;
852
853 // Transfer late parsed template instantiations over to the pending template
854 // instantiation list. During normal compliation, the late template parser
855 // will be installed and instantiating these templates will succeed.
856 //
857 // If we are building a TU prefix for serialization, it is also safe to
858 // transfer these over, even though they are not parsed. The end of the TU
859 // should be outside of any eager template instantiation scope, so when this
860 // AST is deserialized, these templates will not be parsed until the end of
861 // the combined TU.
862 PendingInstantiations.insert(PendingInstantiations.end(),
863 LateParsedInstantiations.begin(),
864 LateParsedInstantiations.end());
865 LateParsedInstantiations.clear();
866
867 // Complete translation units and modules define vtables and perform implicit
868 // instantiations. PCH files do not.
869 if (TUKind != TU_Prefix) {
870 DiagnoseUseOfUnimplementedSelectors();
871
872 // If DefinedUsedVTables ends up marking any virtual member functions it
873 // might lead to more pending template instantiations, which we then need
874 // to instantiate.
875 DefineUsedVTables();
876
877 // C++: Perform implicit template instantiations.
878 //
879 // FIXME: When we perform these implicit instantiations, we do not
880 // carefully keep track of the point of instantiation (C++ [temp.point]).
881 // This means that name lookup that occurs within the template
882 // instantiation will always happen at the end of the translation unit,
883 // so it will find some names that are not required to be found. This is
884 // valid, but we could do better by diagnosing if an instantiation uses a
885 // name that was not visible at its first point of instantiation.
886 if (ExternalSource) {
887 // Load pending instantiations from the external source.
888 SmallVector<PendingImplicitInstantiation, 4> Pending;
889 ExternalSource->ReadPendingInstantiations(Pending);
890 for (auto PII : Pending)
891 if (auto Func = dyn_cast<FunctionDecl>(PII.first))
892 Func->setInstantiationIsPending(true);
893 PendingInstantiations.insert(PendingInstantiations.begin(),
894 Pending.begin(), Pending.end());
895 }
896
897 PerformPendingInstantiations();
898
899 assert(LateParsedInstantiations.empty() &&(static_cast <bool> (LateParsedInstantiations.empty() &&
"end of TU template instantiation should not create more " "late-parsed templates"
) ? void (0) : __assert_fail ("LateParsedInstantiations.empty() && \"end of TU template instantiation should not create more \" \"late-parsed templates\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 901, __extension__ __PRETTY_FUNCTION__))
900 "end of TU template instantiation should not create more "(static_cast <bool> (LateParsedInstantiations.empty() &&
"end of TU template instantiation should not create more " "late-parsed templates"
) ? void (0) : __assert_fail ("LateParsedInstantiations.empty() && \"end of TU template instantiation should not create more \" \"late-parsed templates\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 901, __extension__ __PRETTY_FUNCTION__))
901 "late-parsed templates")(static_cast <bool> (LateParsedInstantiations.empty() &&
"end of TU template instantiation should not create more " "late-parsed templates"
) ? void (0) : __assert_fail ("LateParsedInstantiations.empty() && \"end of TU template instantiation should not create more \" \"late-parsed templates\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 901, __extension__ __PRETTY_FUNCTION__))
;
902
903 if (LateTemplateParserCleanup)
904 LateTemplateParserCleanup(OpaqueParser);
905
906 CheckDelayedMemberExceptionSpecs();
907 }
908
909 DiagnoseUnterminatedPragmaPack();
910 DiagnoseUnterminatedPragmaAttribute();
911
912 // All delayed member exception specs should be checked or we end up accepting
913 // incompatible declarations.
914 // FIXME: This is wrong for TUKind == TU_Prefix. In that case, we need to
915 // write out the lists to the AST file (if any).
916 assert(DelayedDefaultedMemberExceptionSpecs.empty())(static_cast <bool> (DelayedDefaultedMemberExceptionSpecs
.empty()) ? void (0) : __assert_fail ("DelayedDefaultedMemberExceptionSpecs.empty()"
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 916, __extension__ __PRETTY_FUNCTION__))
;
917 assert(DelayedExceptionSpecChecks.empty())(static_cast <bool> (DelayedExceptionSpecChecks.empty()
) ? void (0) : __assert_fail ("DelayedExceptionSpecChecks.empty()"
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 917, __extension__ __PRETTY_FUNCTION__))
;
918
919 // All dllexport classes should have been processed already.
920 assert(DelayedDllExportClasses.empty())(static_cast <bool> (DelayedDllExportClasses.empty()) ?
void (0) : __assert_fail ("DelayedDllExportClasses.empty()",
"/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 920, __extension__ __PRETTY_FUNCTION__))
;
921
922 // Remove file scoped decls that turned out to be used.
923 UnusedFileScopedDecls.erase(
924 std::remove_if(UnusedFileScopedDecls.begin(nullptr, true),
925 UnusedFileScopedDecls.end(),
926 [this](const DeclaratorDecl *DD) {
927 return ShouldRemoveFromUnused(this, DD);
928 }),
929 UnusedFileScopedDecls.end());
930
931 if (TUKind == TU_Prefix) {
932 // Translation unit prefixes don't need any of the checking below.
933 if (!PP.isIncrementalProcessingEnabled())
934 TUScope = nullptr;
935 return;
936 }
937
938 // Check for #pragma weak identifiers that were never declared
939 LoadExternalWeakUndeclaredIdentifiers();
940 for (auto WeakID : WeakUndeclaredIdentifiers) {
941 if (WeakID.second.getUsed())
942 continue;
943
944 Decl *PrevDecl = LookupSingleName(TUScope, WeakID.first, SourceLocation(),
945 LookupOrdinaryName);
946 if (PrevDecl != nullptr &&
947 !(isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl)))
948 Diag(WeakID.second.getLocation(), diag::warn_attribute_wrong_decl_type)
949 << "'weak'" << ExpectedVariableOrFunction;
950 else
951 Diag(WeakID.second.getLocation(), diag::warn_weak_identifier_undeclared)
952 << WeakID.first;
953 }
954
955 if (LangOpts.CPlusPlus11 &&
956 !Diags.isIgnored(diag::warn_delegating_ctor_cycle, SourceLocation()))
957 CheckDelegatingCtorCycles();
958
959 if (!Diags.hasErrorOccurred()) {
960 if (ExternalSource)
961 ExternalSource->ReadUndefinedButUsed(UndefinedButUsed);
962 checkUndefinedButUsed(*this);
963 }
964
965 if (TUKind == TU_Module) {
966 // If we are building a module interface unit, we need to have seen the
967 // module declaration by now.
968 if (getLangOpts().getCompilingModule() ==
969 LangOptions::CMK_ModuleInterface &&
970 ModuleScopes.back().Module->Kind != Module::ModuleInterfaceUnit) {
971 // FIXME: Make a better guess as to where to put the module declaration.
972 Diag(getSourceManager().getLocForStartOfFile(
973 getSourceManager().getMainFileID()),
974 diag::err_module_declaration_missing);
975 }
976
977 // If we are building a module, resolve all of the exported declarations
978 // now.
979 if (Module *CurrentModule = PP.getCurrentModule()) {
980 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
981
982 SmallVector<Module *, 2> Stack;
983 Stack.push_back(CurrentModule);
984 while (!Stack.empty()) {
985 Module *Mod = Stack.pop_back_val();
986
987 // Resolve the exported declarations and conflicts.
988 // FIXME: Actually complain, once we figure out how to teach the
989 // diagnostic client to deal with complaints in the module map at this
990 // point.
991 ModMap.resolveExports(Mod, /*Complain=*/false);
992 ModMap.resolveUses(Mod, /*Complain=*/false);
993 ModMap.resolveConflicts(Mod, /*Complain=*/false);
994
995 // Queue the submodules, so their exports will also be resolved.
996 Stack.append(Mod->submodule_begin(), Mod->submodule_end());
997 }
998 }
999
1000 // Warnings emitted in ActOnEndOfTranslationUnit() should be emitted for
1001 // modules when they are built, not every time they are used.
1002 emitAndClearUnusedLocalTypedefWarnings();
1003
1004 // Modules don't need any of the checking below.
1005 if (!PP.isIncrementalProcessingEnabled())
1006 TUScope = nullptr;
1007 return;
1008 }
1009
1010 // C99 6.9.2p2:
1011 // A declaration of an identifier for an object that has file
1012 // scope without an initializer, and without a storage-class
1013 // specifier or with the storage-class specifier static,
1014 // constitutes a tentative definition. If a translation unit
1015 // contains one or more tentative definitions for an identifier,
1016 // and the translation unit contains no external definition for
1017 // that identifier, then the behavior is exactly as if the
1018 // translation unit contains a file scope declaration of that
1019 // identifier, with the composite type as of the end of the
1020 // translation unit, with an initializer equal to 0.
1021 llvm::SmallSet<VarDecl *, 32> Seen;
1022 for (TentativeDefinitionsType::iterator
1023 T = TentativeDefinitions.begin(ExternalSource),
1024 TEnd = TentativeDefinitions.end();
1025 T != TEnd; ++T)
1026 {
1027 VarDecl *VD = (*T)->getActingDefinition();
1028
1029 // If the tentative definition was completed, getActingDefinition() returns
1030 // null. If we've already seen this variable before, insert()'s second
1031 // return value is false.
1032 if (!VD || VD->isInvalidDecl() || !Seen.insert(VD).second)
1033 continue;
1034
1035 if (const IncompleteArrayType *ArrayT
1036 = Context.getAsIncompleteArrayType(VD->getType())) {
1037 // Set the length of the array to 1 (C99 6.9.2p5).
1038 Diag(VD->getLocation(), diag::warn_tentative_incomplete_array);
1039 llvm::APInt One(Context.getTypeSize(Context.getSizeType()), true);
1040 QualType T = Context.getConstantArrayType(ArrayT->getElementType(),
1041 One, ArrayType::Normal, 0);
1042 VD->setType(T);
1043 } else if (RequireCompleteType(VD->getLocation(), VD->getType(),
1044 diag::err_tentative_def_incomplete_type))
1045 VD->setInvalidDecl();
1046
1047 // No initialization is performed for a tentative definition.
1048 CheckCompleteVariableDeclaration(VD);
1049
1050 // Notify the consumer that we've completed a tentative definition.
1051 if (!VD->isInvalidDecl())
1052 Consumer.CompleteTentativeDefinition(VD);
1053
1054 }
1055
1056 // If there were errors, disable 'unused' warnings since they will mostly be
1057 // noise.
1058 if (!Diags.hasErrorOccurred()) {
1059 // Output warning for unused file scoped decls.
1060 for (UnusedFileScopedDeclsType::iterator
1061 I = UnusedFileScopedDecls.begin(ExternalSource),
1062 E = UnusedFileScopedDecls.end(); I != E; ++I) {
1063 if (ShouldRemoveFromUnused(this, *I))
1064 continue;
1065
1066 if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) {
1067 const FunctionDecl *DiagD;
1068 if (!FD->hasBody(DiagD))
1069 DiagD = FD;
1070 if (DiagD->isDeleted())
1071 continue; // Deleted functions are supposed to be unused.
1072 if (DiagD->isReferenced()) {
1073 if (isa<CXXMethodDecl>(DiagD))
1074 Diag(DiagD->getLocation(), diag::warn_unneeded_member_function)
1075 << DiagD->getDeclName();
1076 else {
1077 if (FD->getStorageClass() == SC_Static &&
1078 !FD->isInlineSpecified() &&
1079 !SourceMgr.isInMainFile(
1080 SourceMgr.getExpansionLoc(FD->getLocation())))
1081 Diag(DiagD->getLocation(),
1082 diag::warn_unneeded_static_internal_decl)
1083 << DiagD->getDeclName();
1084 else
1085 Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
1086 << /*function*/0 << DiagD->getDeclName();
1087 }
1088 } else {
1089 if (FD->getDescribedFunctionTemplate())
1090 Diag(DiagD->getLocation(), diag::warn_unused_template)
1091 << /*function*/0 << DiagD->getDeclName();
1092 else
1093 Diag(DiagD->getLocation(),
1094 isa<CXXMethodDecl>(DiagD) ? diag::warn_unused_member_function
1095 : diag::warn_unused_function)
1096 << DiagD->getDeclName();
1097 }
1098 } else {
1099 const VarDecl *DiagD = cast<VarDecl>(*I)->getDefinition();
1100 if (!DiagD)
1101 DiagD = cast<VarDecl>(*I);
1102 if (DiagD->isReferenced()) {
1103 Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
1104 << /*variable*/1 << DiagD->getDeclName();
1105 } else if (DiagD->getType().isConstQualified()) {
1106 const SourceManager &SM = SourceMgr;
1107 if (SM.getMainFileID() != SM.getFileID(DiagD->getLocation()) ||
1108 !PP.getLangOpts().IsHeaderFile)
1109 Diag(DiagD->getLocation(), diag::warn_unused_const_variable)
1110 << DiagD->getDeclName();
1111 } else {
1112 if (DiagD->getDescribedVarTemplate())
1113 Diag(DiagD->getLocation(), diag::warn_unused_template)
1114 << /*variable*/1 << DiagD->getDeclName();
1115 else
1116 Diag(DiagD->getLocation(), diag::warn_unused_variable)
1117 << DiagD->getDeclName();
1118 }
1119 }
1120 }
1121
1122 emitAndClearUnusedLocalTypedefWarnings();
1123 }
1124
1125 if (!Diags.isIgnored(diag::warn_unused_private_field, SourceLocation())) {
1126 RecordCompleteMap RecordsComplete;
1127 RecordCompleteMap MNCComplete;
1128 for (NamedDeclSetType::iterator I = UnusedPrivateFields.begin(),
1129 E = UnusedPrivateFields.end(); I != E; ++I) {
1130 const NamedDecl *D = *I;
1131 const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D->getDeclContext());
1132 if (RD && !RD->isUnion() &&
1133 IsRecordFullyDefined(RD, RecordsComplete, MNCComplete)) {
1134 Diag(D->getLocation(), diag::warn_unused_private_field)
1135 << D->getDeclName();
1136 }
1137 }
1138 }
1139
1140 if (!Diags.isIgnored(diag::warn_mismatched_delete_new, SourceLocation())) {
1141 if (ExternalSource)
1142 ExternalSource->ReadMismatchingDeleteExpressions(DeleteExprs);
1143 for (const auto &DeletedFieldInfo : DeleteExprs) {
1144 for (const auto &DeleteExprLoc : DeletedFieldInfo.second) {
1145 AnalyzeDeleteExprMismatch(DeletedFieldInfo.first, DeleteExprLoc.first,
1146 DeleteExprLoc.second);
1147 }
1148 }
1149 }
1150
1151 // Check we've noticed that we're no longer parsing the initializer for every
1152 // variable. If we miss cases, then at best we have a performance issue and
1153 // at worst a rejects-valid bug.
1154 assert(ParsingInitForAutoVars.empty() &&(static_cast <bool> (ParsingInitForAutoVars.empty() &&
"Didn't unmark var as having its initializer parsed") ? void
(0) : __assert_fail ("ParsingInitForAutoVars.empty() && \"Didn't unmark var as having its initializer parsed\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 1155, __extension__ __PRETTY_FUNCTION__))
1155 "Didn't unmark var as having its initializer parsed")(static_cast <bool> (ParsingInitForAutoVars.empty() &&
"Didn't unmark var as having its initializer parsed") ? void
(0) : __assert_fail ("ParsingInitForAutoVars.empty() && \"Didn't unmark var as having its initializer parsed\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 1155, __extension__ __PRETTY_FUNCTION__))
;
1156
1157 if (!PP.isIncrementalProcessingEnabled())
1158 TUScope = nullptr;
1159}
1160
1161
1162//===----------------------------------------------------------------------===//
1163// Helper functions.
1164//===----------------------------------------------------------------------===//
1165
1166DeclContext *Sema::getFunctionLevelDeclContext() {
1167 DeclContext *DC = CurContext;
1168
1169 while (true) {
1170 if (isa<BlockDecl>(DC) || isa<EnumDecl>(DC) || isa<CapturedDecl>(DC)) {
1171 DC = DC->getParent();
1172 } else if (isa<CXXMethodDecl>(DC) &&
1173 cast<CXXMethodDecl>(DC)->getOverloadedOperator() == OO_Call &&
1174 cast<CXXRecordDecl>(DC->getParent())->isLambda()) {
1175 DC = DC->getParent()->getParent();
1176 }
1177 else break;
1178 }
1179
1180 return DC;
1181}
1182
1183/// getCurFunctionDecl - If inside of a function body, this returns a pointer
1184/// to the function decl for the function being parsed. If we're currently
1185/// in a 'block', this returns the containing context.
1186FunctionDecl *Sema::getCurFunctionDecl() {
1187 DeclContext *DC = getFunctionLevelDeclContext();
1188 return dyn_cast<FunctionDecl>(DC);
1189}
1190
1191ObjCMethodDecl *Sema::getCurMethodDecl() {
1192 DeclContext *DC = getFunctionLevelDeclContext();
1193 while (isa<RecordDecl>(DC))
1194 DC = DC->getParent();
1195 return dyn_cast<ObjCMethodDecl>(DC);
1196}
1197
1198NamedDecl *Sema::getCurFunctionOrMethodDecl() {
1199 DeclContext *DC = getFunctionLevelDeclContext();
1200 if (isa<ObjCMethodDecl>(DC) || isa<FunctionDecl>(DC))
1201 return cast<NamedDecl>(DC);
1202 return nullptr;
1203}
1204
1205void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
1206 // FIXME: It doesn't make sense to me that DiagID is an incoming argument here
1207 // and yet we also use the current diag ID on the DiagnosticsEngine. This has
1208 // been made more painfully obvious by the refactor that introduced this
1209 // function, but it is possible that the incoming argument can be
1210 // eliminated. If it truly cannot be (for example, there is some reentrancy
1211 // issue I am not seeing yet), then there should at least be a clarifying
1212 // comment somewhere.
1213 if (Optional<TemplateDeductionInfo*> Info = isSFINAEContext()) {
1214 switch (DiagnosticIDs::getDiagnosticSFINAEResponse(
1215 Diags.getCurrentDiagID())) {
1216 case DiagnosticIDs::SFINAE_Report:
1217 // We'll report the diagnostic below.
1218 break;
1219
1220 case DiagnosticIDs::SFINAE_SubstitutionFailure:
1221 // Count this failure so that we know that template argument deduction
1222 // has failed.
1223 ++NumSFINAEErrors;
1224
1225 // Make a copy of this suppressed diagnostic and store it with the
1226 // template-deduction information.
1227 if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
1228 Diagnostic DiagInfo(&Diags);
1229 (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
1230 PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
1231 }
1232
1233 Diags.setLastDiagnosticIgnored();
1234 Diags.Clear();
1235 return;
1236
1237 case DiagnosticIDs::SFINAE_AccessControl: {
1238 // Per C++ Core Issue 1170, access control is part of SFINAE.
1239 // Additionally, the AccessCheckingSFINAE flag can be used to temporarily
1240 // make access control a part of SFINAE for the purposes of checking
1241 // type traits.
1242 if (!AccessCheckingSFINAE && !getLangOpts().CPlusPlus11)
1243 break;
1244
1245 SourceLocation Loc = Diags.getCurrentDiagLoc();
1246
1247 // Suppress this diagnostic.
1248 ++NumSFINAEErrors;
1249
1250 // Make a copy of this suppressed diagnostic and store it with the
1251 // template-deduction information.
1252 if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
1253 Diagnostic DiagInfo(&Diags);
1254 (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
1255 PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
1256 }
1257
1258 Diags.setLastDiagnosticIgnored();
1259 Diags.Clear();
1260
1261 // Now the diagnostic state is clear, produce a C++98 compatibility
1262 // warning.
1263 Diag(Loc, diag::warn_cxx98_compat_sfinae_access_control);
1264
1265 // The last diagnostic which Sema produced was ignored. Suppress any
1266 // notes attached to it.
1267 Diags.setLastDiagnosticIgnored();
1268 return;
1269 }
1270
1271 case DiagnosticIDs::SFINAE_Suppress:
1272 // Make a copy of this suppressed diagnostic and store it with the
1273 // template-deduction information;
1274 if (*Info) {
1275 Diagnostic DiagInfo(&Diags);
1276 (*Info)->addSuppressedDiagnostic(DiagInfo.getLocation(),
1277 PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
1278 }
1279
1280 // Suppress this diagnostic.
1281 Diags.setLastDiagnosticIgnored();
1282 Diags.Clear();
1283 return;
1284 }
1285 }
1286
1287 // Set up the context's printing policy based on our current state.
1288 Context.setPrintingPolicy(getPrintingPolicy());
1289
1290 // Emit the diagnostic.
1291 if (!Diags.EmitCurrentDiagnostic())
1292 return;
1293
1294 // If this is not a note, and we're in a template instantiation
1295 // that is different from the last template instantiation where
1296 // we emitted an error, print a template instantiation
1297 // backtrace.
1298 if (!DiagnosticIDs::isBuiltinNote(DiagID))
1299 PrintContextStack();
1300}
1301
1302Sema::SemaDiagnosticBuilder
1303Sema::Diag(SourceLocation Loc, const PartialDiagnostic& PD) {
1304 SemaDiagnosticBuilder Builder(Diag(Loc, PD.getDiagID()));
1305 PD.Emit(Builder);
1306
1307 return Builder;
1308}
1309
1310/// \brief Looks through the macro-expansion chain for the given
1311/// location, looking for a macro expansion with the given name.
1312/// If one is found, returns true and sets the location to that
1313/// expansion loc.
1314bool Sema::findMacroSpelling(SourceLocation &locref, StringRef name) {
1315 SourceLocation loc = locref;
1316 if (!loc.isMacroID()) return false;
1317
1318 // There's no good way right now to look at the intermediate
1319 // expansions, so just jump to the expansion location.
1320 loc = getSourceManager().getExpansionLoc(loc);
1321
1322 // If that's written with the name, stop here.
1323 SmallVector<char, 16> buffer;
1324 if (getPreprocessor().getSpelling(loc, buffer) == name) {
1325 locref = loc;
1326 return true;
1327 }
1328 return false;
1329}
1330
1331/// \brief Determines the active Scope associated with the given declaration
1332/// context.
1333///
1334/// This routine maps a declaration context to the active Scope object that
1335/// represents that declaration context in the parser. It is typically used
1336/// from "scope-less" code (e.g., template instantiation, lazy creation of
1337/// declarations) that injects a name for name-lookup purposes and, therefore,
1338/// must update the Scope.
1339///
1340/// \returns The scope corresponding to the given declaraion context, or NULL
1341/// if no such scope is open.
1342Scope *Sema::getScopeForContext(DeclContext *Ctx) {
1343
1344 if (!Ctx)
1345 return nullptr;
1346
1347 Ctx = Ctx->getPrimaryContext();
1348 for (Scope *S = getCurScope(); S; S = S->getParent()) {
1349 // Ignore scopes that cannot have declarations. This is important for
1350 // out-of-line definitions of static class members.
1351 if (S->getFlags() & (Scope::DeclScope | Scope::TemplateParamScope))
1352 if (DeclContext *Entity = S->getEntity())
1353 if (Ctx == Entity->getPrimaryContext())
1354 return S;
1355 }
1356
1357 return nullptr;
1358}
1359
1360/// \brief Enter a new function scope
1361void Sema::PushFunctionScope() {
1362 if (FunctionScopes.empty()) {
1363 // Use PreallocatedFunctionScope to avoid allocating memory when possible.
1364 PreallocatedFunctionScope->Clear();
1365 FunctionScopes.push_back(PreallocatedFunctionScope.get());
1366 } else {
1367 FunctionScopes.push_back(new FunctionScopeInfo(getDiagnostics()));
1368 }
1369 if (LangOpts.OpenMP)
1370 pushOpenMPFunctionRegion();
1371}
1372
1373void Sema::PushBlockScope(Scope *BlockScope, BlockDecl *Block) {
1374 FunctionScopes.push_back(new BlockScopeInfo(getDiagnostics(),
1375 BlockScope, Block));
1376}
1377
1378LambdaScopeInfo *Sema::PushLambdaScope() {
1379 LambdaScopeInfo *const LSI = new LambdaScopeInfo(getDiagnostics());
1380 FunctionScopes.push_back(LSI);
1381 return LSI;
1382}
1383
1384void Sema::RecordParsingTemplateParameterDepth(unsigned Depth) {
1385 if (LambdaScopeInfo *const LSI = getCurLambda()) {
1386 LSI->AutoTemplateParameterDepth = Depth;
1387 return;
1388 }
1389 llvm_unreachable(::llvm::llvm_unreachable_internal("Remove assertion if intentionally called in a non-lambda context."
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 1390)
1390 "Remove assertion if intentionally called in a non-lambda context.")::llvm::llvm_unreachable_internal("Remove assertion if intentionally called in a non-lambda context."
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 1390)
;
1391}
1392
1393void Sema::PopFunctionScopeInfo(const AnalysisBasedWarnings::Policy *WP,
1394 const Decl *D, const BlockExpr *blkExpr) {
1395 assert(!FunctionScopes.empty() && "mismatched push/pop!")(static_cast <bool> (!FunctionScopes.empty() &&
"mismatched push/pop!") ? void (0) : __assert_fail ("!FunctionScopes.empty() && \"mismatched push/pop!\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 1395, __extension__ __PRETTY_FUNCTION__))
;
1396 FunctionScopeInfo *Scope = FunctionScopes.pop_back_val();
1397
1398 if (LangOpts.OpenMP)
1399 popOpenMPFunctionRegion(Scope);
1400
1401 // Issue any analysis-based warnings.
1402 if (WP && D)
1403 AnalysisWarnings.IssueWarnings(*WP, Scope, D, blkExpr);
1404 else
1405 for (const auto &PUD : Scope->PossiblyUnreachableDiags)
1406 Diag(PUD.Loc, PUD.PD);
1407
1408 // Delete the scope unless its our preallocated scope.
1409 if (Scope != PreallocatedFunctionScope.get())
1410 delete Scope;
1411}
1412
1413void Sema::PushCompoundScope(bool IsStmtExpr) {
1414 getCurFunction()->CompoundScopes.push_back(CompoundScopeInfo(IsStmtExpr));
1415}
1416
1417void Sema::PopCompoundScope() {
1418 FunctionScopeInfo *CurFunction = getCurFunction();
1419 assert(!CurFunction->CompoundScopes.empty() && "mismatched push/pop")(static_cast <bool> (!CurFunction->CompoundScopes.empty
() && "mismatched push/pop") ? void (0) : __assert_fail
("!CurFunction->CompoundScopes.empty() && \"mismatched push/pop\""
, "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 1419, __extension__ __PRETTY_FUNCTION__))
;
1420
1421 CurFunction->CompoundScopes.pop_back();
1422}
1423
1424/// \brief Determine whether any errors occurred within this function/method/
1425/// block.
1426bool Sema::hasAnyUnrecoverableErrorsInThisFunction() const {
1427 return getCurFunction()->ErrorTrap.hasUnrecoverableErrorOccurred();
1428}
1429
1430void Sema::setFunctionHasBranchIntoScope() {
1431 if (!FunctionScopes.empty())
1432 FunctionScopes.back()->setHasBranchIntoScope();
1433}
1434
1435void Sema::setFunctionHasBranchProtectedScope() {
1436 if (!FunctionScopes.empty())
1437 FunctionScopes.back()->setHasBranchProtectedScope();
1438}
1439
1440void Sema::setFunctionHasIndirectGoto() {
1441 if (!FunctionScopes.empty())
1442 FunctionScopes.back()->setHasIndirectGoto();
1443}
1444
1445BlockScopeInfo *Sema::getCurBlock() {
1446 if (FunctionScopes.empty())
1447 return nullptr;
1448
1449 auto CurBSI = dyn_cast<BlockScopeInfo>(FunctionScopes.back());
1450 if (CurBSI && CurBSI->TheDecl &&
1451 !CurBSI->TheDecl->Encloses(CurContext)) {
1452 // We have switched contexts due to template instantiation.
1453 assert(!CodeSynthesisContexts.empty())(static_cast <bool> (!CodeSynthesisContexts.empty()) ? void
(0) : __assert_fail ("!CodeSynthesisContexts.empty()", "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 1453, __extension__ __PRETTY_FUNCTION__))
;
1454 return nullptr;
1455 }
1456
1457 return CurBSI;
1458}
1459
1460FunctionScopeInfo *Sema::getEnclosingFunction() const {
1461 if (FunctionScopes.empty())
1462 return nullptr;
1463
1464 for (int e = FunctionScopes.size() - 1; e >= 0; --e) {
1465 if (isa<sema::BlockScopeInfo>(FunctionScopes[e]))
1466 continue;
1467 return FunctionScopes[e];
1468 }
1469 return nullptr;
1470}
1471
1472LambdaScopeInfo *Sema::getCurLambda(bool IgnoreNonLambdaCapturingScope) {
1473 if (FunctionScopes.empty())
1474 return nullptr;
1475
1476 auto I = FunctionScopes.rbegin();
1477 if (IgnoreNonLambdaCapturingScope) {
1478 auto E = FunctionScopes.rend();
1479 while (I != E && isa<CapturingScopeInfo>(*I) && !isa<LambdaScopeInfo>(*I))
1480 ++I;
1481 if (I == E)
1482 return nullptr;
1483 }
1484 auto *CurLSI = dyn_cast<LambdaScopeInfo>(*I);
1485 if (CurLSI && CurLSI->Lambda &&
1486 !CurLSI->Lambda->Encloses(CurContext)) {
1487 // We have switched contexts due to template instantiation.
1488 assert(!CodeSynthesisContexts.empty())(static_cast <bool> (!CodeSynthesisContexts.empty()) ? void
(0) : __assert_fail ("!CodeSynthesisContexts.empty()", "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 1488, __extension__ __PRETTY_FUNCTION__))
;
1489 return nullptr;
1490 }
1491
1492 return CurLSI;
1493}
1494// We have a generic lambda if we parsed auto parameters, or we have
1495// an associated template parameter list.
1496LambdaScopeInfo *Sema::getCurGenericLambda() {
1497 if (LambdaScopeInfo *LSI = getCurLambda()) {
1498 return (LSI->AutoTemplateParams.size() ||
1499 LSI->GLTemplateParameterList) ? LSI : nullptr;
1500 }
1501 return nullptr;
1502}
1503
1504
1505void Sema::ActOnComment(SourceRange Comment) {
1506 if (!LangOpts.RetainCommentsFromSystemHeaders &&
1507 SourceMgr.isInSystemHeader(Comment.getBegin()))
1508 return;
1509 RawComment RC(SourceMgr, Comment, LangOpts.CommentOpts, false);
1510 if (RC.isAlmostTrailingComment()) {
1511 SourceRange MagicMarkerRange(Comment.getBegin(),
1512 Comment.getBegin().getLocWithOffset(3));
1513 StringRef MagicMarkerText;
1514 switch (RC.getKind()) {
1515 case RawComment::RCK_OrdinaryBCPL:
1516 MagicMarkerText = "///<";
1517 break;
1518 case RawComment::RCK_OrdinaryC:
1519 MagicMarkerText = "/**<";
1520 break;
1521 default:
1522 llvm_unreachable("if this is an almost Doxygen comment, "::llvm::llvm_unreachable_internal("if this is an almost Doxygen comment, "
"it should be ordinary", "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 1523)
1523 "it should be ordinary")::llvm::llvm_unreachable_internal("if this is an almost Doxygen comment, "
"it should be ordinary", "/build/llvm-toolchain-snapshot-7~svn329677/tools/clang/lib/Sema/Sema.cpp"
, 1523)
;
1524 }
1525 Diag(Comment.getBegin(), diag::warn_not_a_doxygen_trailing_member_comment) <<
1526 FixItHint::CreateReplacement(MagicMarkerRange, MagicMarkerText);
1527 }
1528 Context.addComment(RC);
1529}
1530
1531// Pin this vtable to this file.
1532ExternalSemaSource::~ExternalSemaSource() {}
1533
1534void ExternalSemaSource::ReadMethodPool(Selector Sel) { }
1535void ExternalSemaSource::updateOutOfDateSelector(Selector Sel) { }
1536
1537void ExternalSemaSource::ReadKnownNamespaces(
1538 SmallVectorImpl<NamespaceDecl *> &Namespaces) {
1539}
1540
1541void ExternalSemaSource::ReadUndefinedButUsed(
1542 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {}
1543
1544void ExternalSemaSource::ReadMismatchingDeleteExpressions(llvm::MapVector<
1545 FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &) {}
1546
1547/// \brief Figure out if an expression could be turned into a call.
1548///
1549/// Use this when trying to recover from an error where the programmer may have
1550/// written just the name of a function instead of actually calling it.
1551///
1552/// \param E - The expression to examine.
1553/// \param ZeroArgCallReturnTy - If the expression can be turned into a call
1554/// with no arguments, this parameter is set to the type returned by such a
1555/// call; otherwise, it is set to an empty QualType.
1556/// \param OverloadSet - If the expression is an overloaded function
1557/// name, this parameter is populated with the decls of the various overloads.
1558bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
1559 UnresolvedSetImpl &OverloadSet) {
1560 ZeroArgCallReturnTy = QualType();
1561 OverloadSet.clear();
1562
1563 const OverloadExpr *Overloads = nullptr;
1564 bool IsMemExpr = false;
1565 if (E.getType() == Context.OverloadTy) {
1566 OverloadExpr::FindResult FR = OverloadExpr::find(const_cast<Expr*>(&E));
1567
1568 // Ignore overloads that are pointer-to-member constants.
1569 if (FR.HasFormOfMemberPointer)
1570 return false;
1571
1572 Overloads = FR.Expression;
1573 } else if (E.getType() == Context.BoundMemberTy) {
1574 Overloads = dyn_cast<UnresolvedMemberExpr>(E.IgnoreParens());
1575 IsMemExpr = true;
1576 }
1577
1578 bool Ambiguous = false;
1579
1580 if (Overloads) {
1581 for (OverloadExpr::decls_iterator it = Overloads->decls_begin(),
1582 DeclsEnd = Overloads->decls_end(); it != DeclsEnd; ++it) {
1583 OverloadSet.addDecl(*it);
1584
1585 // Check whether the function is a non-template, non-member which takes no
1586 // arguments.
1587 if (IsMemExpr)
1588 continue;
1589 if (const FunctionDecl *OverloadDecl
1590 = dyn_cast<FunctionDecl>((*it)->getUnderlyingDecl())) {
1591 if (OverloadDecl->getMinRequiredArguments() == 0) {
1592 if (!ZeroArgCallReturnTy.isNull() && !Ambiguous) {
1593 ZeroArgCallReturnTy = QualType();
1594 Ambiguous = true;
1595 } else
1596 ZeroArgCallReturnTy = OverloadDecl->getReturnType();
1597 }
1598 }
1599 }
1600
1601 // If it's not a member, use better machinery to try to resolve the call
1602 if (!IsMemExpr)
1603 return !ZeroArgCallReturnTy.isNull();
1604 }
1605
1606 // Attempt to call the member with no arguments - this will correctly handle
1607 // member templates with defaults/deduction of template arguments, overloads
1608 // with default arguments, etc.
1609 if (IsMemExpr && !E.isTypeDependent()) {
1610 bool Suppress = getDiagnostics().getSuppressAllDiagnostics();
1611 getDiagnostics().setSuppressAllDiagnostics(true);
1612 ExprResult R = BuildCallToMemberFunction(nullptr, &E, SourceLocation(),
1613 None, SourceLocation());
1614 getDiagnostics().setSuppressAllDiagnostics(Suppress);
1615 if (R.isUsable()) {
1616 ZeroArgCallReturnTy = R.get()->getType();
1617 return true;
1618 }
1619 return false;
1620 }
1621
1622 if (const DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E.IgnoreParens())) {
1623 if (const FunctionDecl *Fun = dyn_cast<FunctionDecl>(DeclRef->getDecl())) {
1624 if (Fun->getMinRequiredArguments() == 0)
1625 ZeroArgCallReturnTy = Fun->getReturnType();
1626 return true;
1627 }
1628 }
1629
1630 // We don't have an expression that's convenient to get a FunctionDecl from,
1631 // but we can at least check if the type is "function of 0 arguments".
1632 QualType ExprTy = E.getType();
1633 const FunctionType *FunTy = nullptr;
1634 QualType PointeeTy = ExprTy->getPointeeType();
1635 if (!PointeeTy.isNull())
1636 FunTy = PointeeTy->getAs<FunctionType>();
1637 if (!FunTy)
1638 FunTy = ExprTy->getAs<FunctionType>();
1639
1640 if (const FunctionProtoType *FPT =
1641 dyn_cast_or_null<FunctionProtoType>(FunTy)) {
1642 if (FPT->getNumParams() == 0)
1643 ZeroArgCallReturnTy = FunTy->getReturnType();
1644 return true;
1645 }
1646 return false;
1647}
1648
1649/// \brief Give notes for a set of overloads.
1650///
1651/// A companion to tryExprAsCall. In cases when the name that the programmer
1652/// wrote was an overloaded function, we may be able to make some guesses about
1653/// plausible overloads based on their return types; such guesses can be handed
1654/// off to this method to be emitted as notes.
1655///
1656/// \param Overloads - The overloads to note.
1657/// \param FinalNoteLoc - If we've suppressed printing some overloads due to
1658/// -fshow-overloads=best, this is the location to attach to the note about too
1659/// many candidates. Typically this will be the location of the original
1660/// ill-formed expression.
1661static void noteOverloads(Sema &S, const UnresolvedSetImpl &Overloads,
1662 const SourceLocation FinalNoteLoc) {
1663 int ShownOverloads = 0;
1664 int SuppressedOverloads = 0;
1665 for (UnresolvedSetImpl::iterator It = Overloads.begin(),
1666 DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) {
1667 // FIXME: Magic number for max shown overloads stolen from
1668 // OverloadCandidateSet::NoteCandidates.
1669 if (ShownOverloads >= 4 && S.Diags.getShowOverloads() == Ovl_Best) {
1670 ++SuppressedOverloads;
1671 continue;
1672 }
1673
1674 NamedDecl *Fn = (*It)->getUnderlyingDecl();
1675 // Don't print overloads for non-default multiversioned functions.
1676 if (const auto *FD = Fn->getAsFunction()) {
1677 if (FD->isMultiVersion() &&
1678 !FD->getAttr<TargetAttr>()->isDefaultVersion())
1679 continue;
1680 }
1681 S.Diag(Fn->getLocation(), diag::note_possible_target_of_call);
1682 ++ShownOverloads;
1683 }
1684
1685 if (SuppressedOverloads)
1686 S.Diag(FinalNoteLoc, diag::note_ovl_too_many_candidates)
1687 << SuppressedOverloads;
1688}
1689
1690static void notePlausibleOverloads(Sema &S, SourceLocation Loc,
1691 const UnresolvedSetImpl &Overloads,
1692 bool (*IsPlausibleResult)(QualType)) {
1693 if (!IsPlausibleResult)
1694 return noteOverloads(S, Overloads, Loc);
1695
1696 UnresolvedSet<2> PlausibleOverloads;
1697 for (OverloadExpr::decls_iterator It = Overloads.begin(),
1698 DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) {
1699 const FunctionDecl *OverloadDecl = cast<FunctionDecl>(*It);
1700 QualType OverloadResultTy = OverloadDecl->getReturnType();
1701 if (IsPlausibleResult(OverloadResultTy))
1702 PlausibleOverloads.addDecl(It.getDecl());
1703 }
1704 noteOverloads(S, PlausibleOverloads, Loc);
1705}
1706
1707/// Determine whether the given expression can be called by just
1708/// putting parentheses after it. Notably, expressions with unary
1709/// operators can't be because the unary operator will start parsing
1710/// outside the call.
1711static bool IsCallableWithAppend(Expr *E) {
1712 E = E->IgnoreImplicit();
1713 return (!isa<CStyleCastExpr>(E) &&
1714 !isa<UnaryOperator>(E) &&
1715 !isa<BinaryOperator>(E) &&
1716 !isa<CXXOperatorCallExpr>(E));
1717}
1718
1719bool Sema::tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD,
1720 bool ForceComplain,
1721 bool (*IsPlausibleResult)(QualType)) {
1722 SourceLocation Loc = E.get()->getExprLoc();
1723 SourceRange Range = E.get()->getSourceRange();
1724
1725 QualType ZeroArgCallTy;
1726 UnresolvedSet<4> Overloads;
1727 if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
1728 !ZeroArgCallTy.isNull() &&
1729 (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
1730 // At this point, we know E is potentially callable with 0
1731 // arguments and that it returns something of a reasonable type,
1732 // so we can emit a fixit and carry on pretending that E was
1733 // actually a CallExpr.
1734 SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd());
1735 Diag(Loc, PD)
1736 << /*zero-arg*/ 1 << Range
1737 << (IsCallableWithAppend(E.get())
1738 ? FixItHint::CreateInsertion(ParenInsertionLoc, "()")
1739 : FixItHint());
1740 notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
1741
1742 // FIXME: Try this before emitting the fixit, and suppress diagnostics
1743 // while doing so.
1744 E = ActOnCallExpr(nullptr, E.get(), Range.getEnd(), None,
1745 Range.getEnd().getLocWithOffset(1));
1746 return true;
1747 }
1748
1749 if (!ForceComplain) return false;
1750
1751 Diag(Loc, PD) << /*not zero-arg*/ 0 << Range;
1752 notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
1753 E = ExprError();
1754 return true;
1755}
1756
1757IdentifierInfo *Sema::getSuperIdentifier() const {
1758 if (!Ident_super)
1759 Ident_super = &Context.Idents.get("super");
1760 return Ident_super;
1761}
1762
1763IdentifierInfo *Sema::getFloat128Identifier() const {
1764 if (!Ident___float128)
1765 Ident___float128 = &Context.Idents.get("__float128");
1766 return Ident___float128;
1767}
1768
1769void Sema::PushCapturedRegionScope(Scope *S, CapturedDecl *CD, RecordDecl *RD,
1770 CapturedRegionKind K) {
1771 CapturingScopeInfo *CSI = new CapturedRegionScopeInfo(
1772 getDiagnostics(), S, CD, RD, CD->getContextParam(), K,
1773 (getLangOpts().OpenMP && K == CR_OpenMP) ? getOpenMPNestingLevel() : 0);
1774 CSI->ReturnType = Context.VoidTy;
1775 FunctionScopes.push_back(CSI);
1776}
1777
1778CapturedRegionScopeInfo *Sema::getCurCapturedRegion() {
1779 if (FunctionScopes.empty())
1780 return nullptr;
1781
1782 return dyn_cast<CapturedRegionScopeInfo>(FunctionScopes.back());
1783}
1784
1785const llvm::MapVector<FieldDecl *, Sema::DeleteLocs> &
1786Sema::getMismatchingDeleteExpressions() const {
1787 return DeleteExprs;
1788}
1789
1790void Sema::setOpenCLExtensionForType(QualType T, llvm::StringRef ExtStr) {
1791 if (ExtStr.empty())
1792 return;
1793 llvm::SmallVector<StringRef, 1> Exts;
1794 ExtStr.split(Exts, " ", /* limit */ -1, /* keep empty */ false);
1795 auto CanT = T.getCanonicalType().getTypePtr();
1796 for (auto &I : Exts)
1797 OpenCLTypeExtMap[CanT].insert(I.str());
1798}
1799
1800void Sema::setOpenCLExtensionForDecl(Decl *FD, StringRef ExtStr) {
1801 llvm::SmallVector<StringRef, 1> Exts;
1802 ExtStr.split(Exts, " ", /* limit */ -1, /* keep empty */ false);
1803 if (Exts.empty())
1804 return;
1805 for (auto &I : Exts)
1806 OpenCLDeclExtMap[FD].insert(I.str());
1807}
1808
1809void Sema::setCurrentOpenCLExtensionForType(QualType T) {
1810 if (CurrOpenCLExtension.empty())
1811 return;
1812 setOpenCLExtensionForType(T, CurrOpenCLExtension);
1813}
1814
1815void Sema::setCurrentOpenCLExtensionForDecl(Decl *D) {
1816 if (CurrOpenCLExtension.empty())
1817 return;
1818 setOpenCLExtensionForDecl(D, CurrOpenCLExtension);
1819}
1820
1821bool Sema::isOpenCLDisabledDecl(Decl *FD) {
1822 auto Loc = OpenCLDeclExtMap.find(FD);
1823 if (Loc == OpenCLDeclExtMap.end())
1824 return false;
1825 for (auto &I : Loc->second) {
1826 if (!getOpenCLOptions().isEnabled(I))
1827 return true;
1828 }
1829 return false;
1830}
1831
1832template <typename T, typename DiagLocT, typename DiagInfoT, typename MapT>
1833bool Sema::checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc,
1834 DiagInfoT DiagInfo, MapT &Map,
1835 unsigned Selector,
1836 SourceRange SrcRange) {
1837 auto Loc = Map.find(D);
1838 if (Loc == Map.end())
1839 return false;
1840 bool Disabled = false;
1841 for (auto &I : Loc->second) {
1842 if (I != CurrOpenCLExtension && !getOpenCLOptions().isEnabled(I)) {
1843 Diag(DiagLoc, diag::err_opencl_requires_extension) << Selector << DiagInfo
1844 << I << SrcRange;
1845 Disabled = true;
1846 }
1847 }
1848 return Disabled;
1849}
1850
1851bool Sema::checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType QT) {
1852 // Check extensions for declared types.
1853 Decl *Decl = nullptr;
1854 if (auto TypedefT = dyn_cast<TypedefType>(QT.getTypePtr()))
1855 Decl = TypedefT->getDecl();
1856 if (auto TagT = dyn_cast<TagType>(QT.getCanonicalType().getTypePtr()))
1857 Decl = TagT->getDecl();
1858 auto Loc = DS.getTypeSpecTypeLoc();
1859 if (checkOpenCLDisabledTypeOrDecl(Decl, Loc, QT, OpenCLDeclExtMap))
1860 return true;
1861
1862 // Check extensions for builtin types.
1863 return checkOpenCLDisabledTypeOrDecl(QT.getCanonicalType().getTypePtr(), Loc,
1864 QT, OpenCLTypeExtMap);
1865}
1866
1867bool Sema::checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E) {
1868 IdentifierInfo *FnName = D.getIdentifier();
1869 return checkOpenCLDisabledTypeOrDecl(&D, E.getLocStart(), FnName,
1870 OpenCLDeclExtMap, 1, D.getSourceRange());
1871}

/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc

1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Attribute classes' definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9#ifndef LLVM_CLANG_ATTR_CLASSES_INC
10#define LLVM_CLANG_ATTR_CLASSES_INC
11
12class AMDGPUFlatWorkGroupSizeAttr : public InheritableAttr {
13unsigned min;
14
15unsigned max;
16
17public:
18 static AMDGPUFlatWorkGroupSizeAttr *CreateImplicit(ASTContext &Ctx, unsigned Min, unsigned Max, SourceRange Loc = SourceRange()) {
19 auto *A = new (Ctx) AMDGPUFlatWorkGroupSizeAttr(Loc, Ctx, Min, Max, 0);
20 A->setImplicit(true);
21 return A;
22 }
23
24 AMDGPUFlatWorkGroupSizeAttr(SourceRange R, ASTContext &Ctx
25 , unsigned Min
26 , unsigned Max
27 , unsigned SI
28 )
29 : InheritableAttr(attr::AMDGPUFlatWorkGroupSize, R, SI, false, false)
30 , min(Min)
31 , max(Max)
32 {
33 }
34
35 AMDGPUFlatWorkGroupSizeAttr *clone(ASTContext &C) const;
36 void printPretty(raw_ostream &OS,
37 const PrintingPolicy &Policy) const;
38 const char *getSpelling() const;
39 unsigned getMin() const {
40 return min;
41 }
42
43 unsigned getMax() const {
44 return max;
45 }
46
47
48
49 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUFlatWorkGroupSize; }
50};
51
52class AMDGPUNumSGPRAttr : public InheritableAttr {
53unsigned numSGPR;
54
55public:
56 static AMDGPUNumSGPRAttr *CreateImplicit(ASTContext &Ctx, unsigned NumSGPR, SourceRange Loc = SourceRange()) {
57 auto *A = new (Ctx) AMDGPUNumSGPRAttr(Loc, Ctx, NumSGPR, 0);
58 A->setImplicit(true);
59 return A;
60 }
61
62 AMDGPUNumSGPRAttr(SourceRange R, ASTContext &Ctx
63 , unsigned NumSGPR
64 , unsigned SI
65 )
66 : InheritableAttr(attr::AMDGPUNumSGPR, R, SI, false, false)
67 , numSGPR(NumSGPR)
68 {
69 }
70
71 AMDGPUNumSGPRAttr *clone(ASTContext &C) const;
72 void printPretty(raw_ostream &OS,
73 const PrintingPolicy &Policy) const;
74 const char *getSpelling() const;
75 unsigned getNumSGPR() const {
76 return numSGPR;
77 }
78
79
80
81 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUNumSGPR; }
82};
83
84class AMDGPUNumVGPRAttr : public InheritableAttr {
85unsigned numVGPR;
86
87public:
88 static AMDGPUNumVGPRAttr *CreateImplicit(ASTContext &Ctx, unsigned NumVGPR, SourceRange Loc = SourceRange()) {
89 auto *A = new (Ctx) AMDGPUNumVGPRAttr(Loc, Ctx, NumVGPR, 0);
90 A->setImplicit(true);
91 return A;
92 }
93
94 AMDGPUNumVGPRAttr(SourceRange R, ASTContext &Ctx
95 , unsigned NumVGPR
96 , unsigned SI
97 )
98 : InheritableAttr(attr::AMDGPUNumVGPR, R, SI, false, false)
99 , numVGPR(NumVGPR)
100 {
101 }
102
103 AMDGPUNumVGPRAttr *clone(ASTContext &C) const;
104 void printPretty(raw_ostream &OS,
105 const PrintingPolicy &Policy) const;
106 const char *getSpelling() const;
107 unsigned getNumVGPR() const {
108 return numVGPR;
109 }
110
111
112
113 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUNumVGPR; }
114};
115
116class AMDGPUWavesPerEUAttr : public InheritableAttr {
117unsigned min;
118
119unsigned max;
120
121public:
122 static AMDGPUWavesPerEUAttr *CreateImplicit(ASTContext &Ctx, unsigned Min, unsigned Max, SourceRange Loc = SourceRange()) {
123 auto *A = new (Ctx) AMDGPUWavesPerEUAttr(Loc, Ctx, Min, Max, 0);
124 A->setImplicit(true);
125 return A;
126 }
127
128 AMDGPUWavesPerEUAttr(SourceRange R, ASTContext &Ctx
129 , unsigned Min
130 , unsigned Max
131 , unsigned SI
132 )
133 : InheritableAttr(attr::AMDGPUWavesPerEU, R, SI, false, false)
134 , min(Min)
135 , max(Max)
136 {
137 }
138
139 AMDGPUWavesPerEUAttr(SourceRange R, ASTContext &Ctx
140 , unsigned Min
141 , unsigned SI
142 )
143 : InheritableAttr(attr::AMDGPUWavesPerEU, R, SI, false, false)
144 , min(Min)
145 , max()
146 {
147 }
148
149 AMDGPUWavesPerEUAttr *clone(ASTContext &C) const;
150 void printPretty(raw_ostream &OS,
151 const PrintingPolicy &Policy) const;
152 const char *getSpelling() const;
153 unsigned getMin() const {
154 return min;
155 }
156
157 unsigned getMax() const {
158 return max;
159 }
160
161
162
163 static bool classof(const Attr *A) { return A->getKind() == attr::AMDGPUWavesPerEU; }
164};
165
166class ARMInterruptAttr : public InheritableAttr {
167public:
168 enum InterruptType {
169 IRQ,
170 FIQ,
171 SWI,
172 ABORT,
173 UNDEF,
174 Generic
175 };
176private:
177 InterruptType interrupt;
178
179public:
180 static ARMInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) {
181 auto *A = new (Ctx) ARMInterruptAttr(Loc, Ctx, Interrupt, 0);
182 A->setImplicit(true);
183 return A;
184 }
185
186 ARMInterruptAttr(SourceRange R, ASTContext &Ctx
187 , InterruptType Interrupt
188 , unsigned SI
189 )
190 : InheritableAttr(attr::ARMInterrupt, R, SI, false, false)
191 , interrupt(Interrupt)
192 {
193 }
194
195 ARMInterruptAttr(SourceRange R, ASTContext &Ctx
196 , unsigned SI
197 )
198 : InheritableAttr(attr::ARMInterrupt, R, SI, false, false)
199 , interrupt(InterruptType(0))
200 {
201 }
202
203 ARMInterruptAttr *clone(ASTContext &C) const;
204 void printPretty(raw_ostream &OS,
205 const PrintingPolicy &Policy) const;
206 const char *getSpelling() const;
207 InterruptType getInterrupt() const {
208 return interrupt;
209 }
210
211 static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) {
212 Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val)
213 .Case("IRQ", ARMInterruptAttr::IRQ)
214 .Case("FIQ", ARMInterruptAttr::FIQ)
215 .Case("SWI", ARMInterruptAttr::SWI)
216 .Case("ABORT", ARMInterruptAttr::ABORT)
217 .Case("UNDEF", ARMInterruptAttr::UNDEF)
218 .Case("", ARMInterruptAttr::Generic)
219 .Default(Optional<InterruptType>());
220 if (R) {
221 Out = *R;
222 return true;
223 }
224 return false;
225 }
226
227 static const char *ConvertInterruptTypeToStr(InterruptType Val) {
228 switch(Val) {
229 case ARMInterruptAttr::IRQ: return "IRQ";
230 case ARMInterruptAttr::FIQ: return "FIQ";
231 case ARMInterruptAttr::SWI: return "SWI";
232 case ARMInterruptAttr::ABORT: return "ABORT";
233 case ARMInterruptAttr::UNDEF: return "UNDEF";
234 case ARMInterruptAttr::Generic: return "";
235 }
236 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 236)
;
237 }
238
239
240 static bool classof(const Attr *A) { return A->getKind() == attr::ARMInterrupt; }
241};
242
243class AVRInterruptAttr : public InheritableAttr {
244public:
245 static AVRInterruptAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
246 auto *A = new (Ctx) AVRInterruptAttr(Loc, Ctx, 0);
247 A->setImplicit(true);
248 return A;
249 }
250
251 AVRInterruptAttr(SourceRange R, ASTContext &Ctx
252 , unsigned SI
253 )
254 : InheritableAttr(attr::AVRInterrupt, R, SI, false, false)
255 {
256 }
257
258 AVRInterruptAttr *clone(ASTContext &C) const;
259 void printPretty(raw_ostream &OS,
260 const PrintingPolicy &Policy) const;
261 const char *getSpelling() const;
262
263
264 static bool classof(const Attr *A) { return A->getKind() == attr::AVRInterrupt; }
265};
266
267class AVRSignalAttr : public InheritableAttr {
268public:
269 static AVRSignalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
270 auto *A = new (Ctx) AVRSignalAttr(Loc, Ctx, 0);
271 A->setImplicit(true);
272 return A;
273 }
274
275 AVRSignalAttr(SourceRange R, ASTContext &Ctx
276 , unsigned SI
277 )
278 : InheritableAttr(attr::AVRSignal, R, SI, false, false)
279 {
280 }
281
282 AVRSignalAttr *clone(ASTContext &C) const;
283 void printPretty(raw_ostream &OS,
284 const PrintingPolicy &Policy) const;
285 const char *getSpelling() const;
286
287
288 static bool classof(const Attr *A) { return A->getKind() == attr::AVRSignal; }
289};
290
291class AbiTagAttr : public Attr {
292 unsigned tags_Size;
293 StringRef *tags_;
294
295public:
296 static AbiTagAttr *CreateImplicit(ASTContext &Ctx, StringRef *Tags, unsigned TagsSize, SourceRange Loc = SourceRange()) {
297 auto *A = new (Ctx) AbiTagAttr(Loc, Ctx, Tags, TagsSize, 0);
298 A->setImplicit(true);
299 return A;
300 }
301
302 AbiTagAttr(SourceRange R, ASTContext &Ctx
303 , StringRef *Tags, unsigned TagsSize
304 , unsigned SI
305 )
306 : Attr(attr::AbiTag, R, SI, false)
307 , tags_Size(TagsSize), tags_(new (Ctx, 16) StringRef[tags_Size])
308 {
309 for (size_t I = 0, E = tags_Size; I != E;
310 ++I) {
311 StringRef Ref = Tags[I];
312 if (!Ref.empty()) {
313 char *Mem = new (Ctx, 1) char[Ref.size()];
314 std::memcpy(Mem, Ref.data(), Ref.size());
315 tags_[I] = StringRef(Mem, Ref.size());
316 }
317 }
318 }
319
320 AbiTagAttr(SourceRange R, ASTContext &Ctx
321 , unsigned SI
322 )
323 : Attr(attr::AbiTag, R, SI, false)
324 , tags_Size(0), tags_(nullptr)
325 {
326 }
327
328 AbiTagAttr *clone(ASTContext &C) const;
329 void printPretty(raw_ostream &OS,
330 const PrintingPolicy &Policy) const;
331 const char *getSpelling() const;
332 typedef StringRef* tags_iterator;
333 tags_iterator tags_begin() const { return tags_; }
334 tags_iterator tags_end() const { return tags_ + tags_Size; }
335 unsigned tags_size() const { return tags_Size; }
336 llvm::iterator_range<tags_iterator> tags() const { return llvm::make_range(tags_begin(), tags_end()); }
337
338
339
340
341 static bool classof(const Attr *A) { return A->getKind() == attr::AbiTag; }
342};
343
344class AcquireCapabilityAttr : public InheritableAttr {
345 unsigned args_Size;
346 Expr * *args_;
347
348public:
349 enum Spelling {
350 GNU_acquire_capability = 0,
351 CXX11_clang_acquire_capability = 1,
352 GNU_acquire_shared_capability = 2,
353 CXX11_clang_acquire_shared_capability = 3,
354 GNU_exclusive_lock_function = 4,
355 GNU_shared_lock_function = 5
356 };
357
358 static AcquireCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
359 auto *A = new (Ctx) AcquireCapabilityAttr(Loc, Ctx, Args, ArgsSize, S);
360 A->setImplicit(true);
361 return A;
362 }
363
364 AcquireCapabilityAttr(SourceRange R, ASTContext &Ctx
365 , Expr * *Args, unsigned ArgsSize
366 , unsigned SI
367 )
368 : InheritableAttr(attr::AcquireCapability, R, SI, true, true)
369 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
370 {
371 std::copy(Args, Args + args_Size, args_);
372 }
373
374 AcquireCapabilityAttr(SourceRange R, ASTContext &Ctx
375 , unsigned SI
376 )
377 : InheritableAttr(attr::AcquireCapability, R, SI, true, true)
378 , args_Size(0), args_(nullptr)
379 {
380 }
381
382 AcquireCapabilityAttr *clone(ASTContext &C) const;
383 void printPretty(raw_ostream &OS,
384 const PrintingPolicy &Policy) const;
385 const char *getSpelling() const;
386 Spelling getSemanticSpelling() const {
387 switch (SpellingListIndex) {
388 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 388)
;
389 case 0: return GNU_acquire_capability;
390 case 1: return CXX11_clang_acquire_capability;
391 case 2: return GNU_acquire_shared_capability;
392 case 3: return CXX11_clang_acquire_shared_capability;
393 case 4: return GNU_exclusive_lock_function;
394 case 5: return GNU_shared_lock_function;
395 }
396 }
397 bool isShared() const { return SpellingListIndex == 2 ||
398 SpellingListIndex == 3 ||
399 SpellingListIndex == 5; }
400 typedef Expr ** args_iterator;
401 args_iterator args_begin() const { return args_; }
402 args_iterator args_end() const { return args_ + args_Size; }
403 unsigned args_size() const { return args_Size; }
404 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
405
406
407
408
409 static bool classof(const Attr *A) { return A->getKind() == attr::AcquireCapability; }
410};
411
412class AcquiredAfterAttr : public InheritableAttr {
413 unsigned args_Size;
414 Expr * *args_;
415
416public:
417 static AcquiredAfterAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
418 auto *A = new (Ctx) AcquiredAfterAttr(Loc, Ctx, Args, ArgsSize, 0);
419 A->setImplicit(true);
420 return A;
421 }
422
423 AcquiredAfterAttr(SourceRange R, ASTContext &Ctx
424 , Expr * *Args, unsigned ArgsSize
425 , unsigned SI
426 )
427 : InheritableAttr(attr::AcquiredAfter, R, SI, true, true)
428 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
429 {
430 std::copy(Args, Args + args_Size, args_);
431 }
432
433 AcquiredAfterAttr(SourceRange R, ASTContext &Ctx
434 , unsigned SI
435 )
436 : InheritableAttr(attr::AcquiredAfter, R, SI, true, true)
437 , args_Size(0), args_(nullptr)
438 {
439 }
440
441 AcquiredAfterAttr *clone(ASTContext &C) const;
442 void printPretty(raw_ostream &OS,
443 const PrintingPolicy &Policy) const;
444 const char *getSpelling() const;
445 typedef Expr ** args_iterator;
446 args_iterator args_begin() const { return args_; }
447 args_iterator args_end() const { return args_ + args_Size; }
448 unsigned args_size() const { return args_Size; }
449 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
450
451
452
453
454 static bool classof(const Attr *A) { return A->getKind() == attr::AcquiredAfter; }
455};
456
457class AcquiredBeforeAttr : public InheritableAttr {
458 unsigned args_Size;
459 Expr * *args_;
460
461public:
462 static AcquiredBeforeAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
463 auto *A = new (Ctx) AcquiredBeforeAttr(Loc, Ctx, Args, ArgsSize, 0);
464 A->setImplicit(true);
465 return A;
466 }
467
468 AcquiredBeforeAttr(SourceRange R, ASTContext &Ctx
469 , Expr * *Args, unsigned ArgsSize
470 , unsigned SI
471 )
472 : InheritableAttr(attr::AcquiredBefore, R, SI, true, true)
473 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
474 {
475 std::copy(Args, Args + args_Size, args_);
476 }
477
478 AcquiredBeforeAttr(SourceRange R, ASTContext &Ctx
479 , unsigned SI
480 )
481 : InheritableAttr(attr::AcquiredBefore, R, SI, true, true)
482 , args_Size(0), args_(nullptr)
483 {
484 }
485
486 AcquiredBeforeAttr *clone(ASTContext &C) const;
487 void printPretty(raw_ostream &OS,
488 const PrintingPolicy &Policy) const;
489 const char *getSpelling() const;
490 typedef Expr ** args_iterator;
491 args_iterator args_begin() const { return args_; }
492 args_iterator args_end() const { return args_ + args_Size; }
493 unsigned args_size() const { return args_Size; }
494 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
495
496
497
498
499 static bool classof(const Attr *A) { return A->getKind() == attr::AcquiredBefore; }
500};
501
502class AliasAttr : public Attr {
503unsigned aliaseeLength;
504char *aliasee;
505
506public:
507 static AliasAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Aliasee, SourceRange Loc = SourceRange()) {
508 auto *A = new (Ctx) AliasAttr(Loc, Ctx, Aliasee, 0);
509 A->setImplicit(true);
510 return A;
511 }
512
513 AliasAttr(SourceRange R, ASTContext &Ctx
514 , llvm::StringRef Aliasee
515 , unsigned SI
516 )
517 : Attr(attr::Alias, R, SI, false)
518 , aliaseeLength(Aliasee.size()),aliasee(new (Ctx, 1) char[aliaseeLength])
519 {
520 if (!Aliasee.empty())
521 std::memcpy(aliasee, Aliasee.data(), aliaseeLength);
522 }
523
524 AliasAttr *clone(ASTContext &C) const;
525 void printPretty(raw_ostream &OS,
526 const PrintingPolicy &Policy) const;
527 const char *getSpelling() const;
528 llvm::StringRef getAliasee() const {
529 return llvm::StringRef(aliasee, aliaseeLength);
530 }
531 unsigned getAliaseeLength() const {
532 return aliaseeLength;
533 }
534 void setAliasee(ASTContext &C, llvm::StringRef S) {
535 aliaseeLength = S.size();
536 this->aliasee = new (C, 1) char [aliaseeLength];
537 if (!S.empty())
538 std::memcpy(this->aliasee, S.data(), aliaseeLength);
539 }
540
541
542
543 static bool classof(const Attr *A) { return A->getKind() == attr::Alias; }
544};
545
546class AlignMac68kAttr : public InheritableAttr {
547public:
548 static AlignMac68kAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
549 auto *A = new (Ctx) AlignMac68kAttr(Loc, Ctx, 0);
550 A->setImplicit(true);
551 return A;
552 }
553
554 AlignMac68kAttr(SourceRange R, ASTContext &Ctx
555 , unsigned SI
556 )
557 : InheritableAttr(attr::AlignMac68k, R, SI, false, false)
558 {
559 }
560
561 AlignMac68kAttr *clone(ASTContext &C) const;
562 void printPretty(raw_ostream &OS,
563 const PrintingPolicy &Policy) const;
564 const char *getSpelling() const;
565
566
567 static bool classof(const Attr *A) { return A->getKind() == attr::AlignMac68k; }
568};
569
570class AlignValueAttr : public Attr {
571Expr * alignment;
572
573public:
574 static AlignValueAttr *CreateImplicit(ASTContext &Ctx, Expr * Alignment, SourceRange Loc = SourceRange()) {
575 auto *A = new (Ctx) AlignValueAttr(Loc, Ctx, Alignment, 0);
576 A->setImplicit(true);
577 return A;
578 }
579
580 AlignValueAttr(SourceRange R, ASTContext &Ctx
581 , Expr * Alignment
582 , unsigned SI
583 )
584 : Attr(attr::AlignValue, R, SI, false)
585 , alignment(Alignment)
586 {
587 }
588
589 AlignValueAttr *clone(ASTContext &C) const;
590 void printPretty(raw_ostream &OS,
591 const PrintingPolicy &Policy) const;
592 const char *getSpelling() const;
593 Expr * getAlignment() const {
594 return alignment;
595 }
596
597
598
599 static bool classof(const Attr *A) { return A->getKind() == attr::AlignValue; }
600};
601
602class AlignedAttr : public InheritableAttr {
603bool isalignmentExpr;
604union {
605Expr *alignmentExpr;
606TypeSourceInfo *alignmentType;
607};
608
609public:
610 enum Spelling {
611 GNU_aligned = 0,
612 CXX11_gnu_aligned = 1,
613 Declspec_align = 2,
614 Keyword_alignas = 3,
615 Keyword_Alignas = 4
616 };
617
618 static AlignedAttr *CreateImplicit(ASTContext &Ctx, Spelling S, bool IsAlignmentExpr, void *Alignment, SourceRange Loc = SourceRange()) {
619 auto *A = new (Ctx) AlignedAttr(Loc, Ctx, IsAlignmentExpr, Alignment, S);
620 A->setImplicit(true);
621 return A;
622 }
623
624 AlignedAttr(SourceRange R, ASTContext &Ctx
625 , bool IsAlignmentExpr, void *Alignment
626 , unsigned SI
627 )
628 : InheritableAttr(attr::Aligned, R, SI, false, false)
629 , isalignmentExpr(IsAlignmentExpr)
630 {
631 if (isalignmentExpr)
632 alignmentExpr = reinterpret_cast<Expr *>(Alignment);
633 else
634 alignmentType = reinterpret_cast<TypeSourceInfo *>(Alignment);
635 }
636
637 AlignedAttr(SourceRange R, ASTContext &Ctx
638 , unsigned SI
639 )
640 : InheritableAttr(attr::Aligned, R, SI, false, false)
641 , isalignmentExpr(false)
642 {
643 }
644
645 AlignedAttr *clone(ASTContext &C) const;
646 void printPretty(raw_ostream &OS,
647 const PrintingPolicy &Policy) const;
648 const char *getSpelling() const;
649 Spelling getSemanticSpelling() const {
650 switch (SpellingListIndex) {
651 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 651)
;
652 case 0: return GNU_aligned;
653 case 1: return CXX11_gnu_aligned;
654 case 2: return Declspec_align;
655 case 3: return Keyword_alignas;
656 case 4: return Keyword_Alignas;
657 }
658 }
659 bool isGNU() const { return SpellingListIndex == 0 ||
660 SpellingListIndex == 1; }
661 bool isC11() const { return SpellingListIndex == 4; }
662 bool isAlignas() const { return SpellingListIndex == 3 ||
663 SpellingListIndex == 4; }
664 bool isDeclspec() const { return SpellingListIndex == 2; }
665 bool isAlignmentDependent() const;
666 unsigned getAlignment(ASTContext &Ctx) const;
667 bool isAlignmentExpr() const {
668 return isalignmentExpr;
669 }
670 Expr *getAlignmentExpr() const {
671 assert(isalignmentExpr)(static_cast <bool> (isalignmentExpr) ? void (0) : __assert_fail
("isalignmentExpr", "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 671, __extension__ __PRETTY_FUNCTION__))
;
672 return alignmentExpr;
673 }
674 TypeSourceInfo *getAlignmentType() const {
675 assert(!isalignmentExpr)(static_cast <bool> (!isalignmentExpr) ? void (0) : __assert_fail
("!isalignmentExpr", "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 675, __extension__ __PRETTY_FUNCTION__))
;
676 return alignmentType;
677 }
678
679
680
681 static bool classof(const Attr *A) { return A->getKind() == attr::Aligned; }
682};
683
684class AllocAlignAttr : public InheritableAttr {
685ParamIdx paramIndex;
686
687public:
688 static AllocAlignAttr *CreateImplicit(ASTContext &Ctx, ParamIdx ParamIndex, SourceRange Loc = SourceRange()) {
689 auto *A = new (Ctx) AllocAlignAttr(Loc, Ctx, ParamIndex, 0);
690 A->setImplicit(true);
691 return A;
692 }
693
694 AllocAlignAttr(SourceRange R, ASTContext &Ctx
695 , ParamIdx ParamIndex
696 , unsigned SI
697 )
698 : InheritableAttr(attr::AllocAlign, R, SI, false, false)
699 , paramIndex(ParamIndex)
700 {
701 }
702
703 AllocAlignAttr *clone(ASTContext &C) const;
704 void printPretty(raw_ostream &OS,
705 const PrintingPolicy &Policy) const;
706 const char *getSpelling() const;
707 ParamIdx getParamIndex() const {
708 return paramIndex;
709 }
710
711
712
713 static bool classof(const Attr *A) { return A->getKind() == attr::AllocAlign; }
714};
715
716class AllocSizeAttr : public InheritableAttr {
717ParamIdx elemSizeParam;
718
719ParamIdx numElemsParam;
720
721public:
722 static AllocSizeAttr *CreateImplicit(ASTContext &Ctx, ParamIdx ElemSizeParam, ParamIdx NumElemsParam, SourceRange Loc = SourceRange()) {
723 auto *A = new (Ctx) AllocSizeAttr(Loc, Ctx, ElemSizeParam, NumElemsParam, 0);
724 A->setImplicit(true);
725 return A;
726 }
727
728 AllocSizeAttr(SourceRange R, ASTContext &Ctx
729 , ParamIdx ElemSizeParam
730 , ParamIdx NumElemsParam
731 , unsigned SI
732 )
733 : InheritableAttr(attr::AllocSize, R, SI, false, false)
734 , elemSizeParam(ElemSizeParam)
735 , numElemsParam(NumElemsParam)
736 {
737 }
738
739 AllocSizeAttr(SourceRange R, ASTContext &Ctx
740 , ParamIdx ElemSizeParam
741 , unsigned SI
742 )
743 : InheritableAttr(attr::AllocSize, R, SI, false, false)
744 , elemSizeParam(ElemSizeParam)
745 , numElemsParam()
746 {
747 }
748
749 AllocSizeAttr *clone(ASTContext &C) const;
750 void printPretty(raw_ostream &OS,
751 const PrintingPolicy &Policy) const;
752 const char *getSpelling() const;
753 ParamIdx getElemSizeParam() const {
754 return elemSizeParam;
755 }
756
757 ParamIdx getNumElemsParam() const {
758 return numElemsParam;
759 }
760
761
762
763 static bool classof(const Attr *A) { return A->getKind() == attr::AllocSize; }
764};
765
766class AlwaysInlineAttr : public InheritableAttr {
767public:
768 enum Spelling {
769 GNU_always_inline = 0,
770 CXX11_gnu_always_inline = 1,
771 Keyword_forceinline = 2
772 };
773
774 static AlwaysInlineAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
775 auto *A = new (Ctx) AlwaysInlineAttr(Loc, Ctx, S);
776 A->setImplicit(true);
777 return A;
778 }
779
780 AlwaysInlineAttr(SourceRange R, ASTContext &Ctx
781 , unsigned SI
782 )
783 : InheritableAttr(attr::AlwaysInline, R, SI, false, false)
784 {
785 }
786
787 AlwaysInlineAttr *clone(ASTContext &C) const;
788 void printPretty(raw_ostream &OS,
789 const PrintingPolicy &Policy) const;
790 const char *getSpelling() const;
791 Spelling getSemanticSpelling() const {
792 switch (SpellingListIndex) {
793 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 793)
;
794 case 0: return GNU_always_inline;
795 case 1: return CXX11_gnu_always_inline;
796 case 2: return Keyword_forceinline;
797 }
798 }
799
800
801 static bool classof(const Attr *A) { return A->getKind() == attr::AlwaysInline; }
802};
803
804class AnalyzerNoReturnAttr : public InheritableAttr {
805public:
806 static AnalyzerNoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
807 auto *A = new (Ctx) AnalyzerNoReturnAttr(Loc, Ctx, 0);
808 A->setImplicit(true);
809 return A;
810 }
811
812 AnalyzerNoReturnAttr(SourceRange R, ASTContext &Ctx
813 , unsigned SI
814 )
815 : InheritableAttr(attr::AnalyzerNoReturn, R, SI, false, false)
816 {
817 }
818
819 AnalyzerNoReturnAttr *clone(ASTContext &C) const;
820 void printPretty(raw_ostream &OS,
821 const PrintingPolicy &Policy) const;
822 const char *getSpelling() const;
823
824
825 static bool classof(const Attr *A) { return A->getKind() == attr::AnalyzerNoReturn; }
826};
827
828class AnnotateAttr : public InheritableParamAttr {
829unsigned annotationLength;
830char *annotation;
831
832public:
833 static AnnotateAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Annotation, SourceRange Loc = SourceRange()) {
834 auto *A = new (Ctx) AnnotateAttr(Loc, Ctx, Annotation, 0);
835 A->setImplicit(true);
836 return A;
837 }
838
839 AnnotateAttr(SourceRange R, ASTContext &Ctx
840 , llvm::StringRef Annotation
841 , unsigned SI
842 )
843 : InheritableParamAttr(attr::Annotate, R, SI, false, false)
844 , annotationLength(Annotation.size()),annotation(new (Ctx, 1) char[annotationLength])
845 {
846 if (!Annotation.empty())
847 std::memcpy(annotation, Annotation.data(), annotationLength);
848 }
849
850 AnnotateAttr *clone(ASTContext &C) const;
851 void printPretty(raw_ostream &OS,
852 const PrintingPolicy &Policy) const;
853 const char *getSpelling() const;
854 llvm::StringRef getAnnotation() const {
855 return llvm::StringRef(annotation, annotationLength);
856 }
857 unsigned getAnnotationLength() const {
858 return annotationLength;
859 }
860 void setAnnotation(ASTContext &C, llvm::StringRef S) {
861 annotationLength = S.size();
862 this->annotation = new (C, 1) char [annotationLength];
863 if (!S.empty())
864 std::memcpy(this->annotation, S.data(), annotationLength);
865 }
866
867
868
869 static bool classof(const Attr *A) { return A->getKind() == attr::Annotate; }
870};
871
872class AnyX86InterruptAttr : public InheritableAttr {
873public:
874 static AnyX86InterruptAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
875 auto *A = new (Ctx) AnyX86InterruptAttr(Loc, Ctx, 0);
876 A->setImplicit(true);
877 return A;
878 }
879
880 AnyX86InterruptAttr(SourceRange R, ASTContext &Ctx
881 , unsigned SI
882 )
883 : InheritableAttr(attr::AnyX86Interrupt, R, SI, false, false)
884 {
885 }
886
887 AnyX86InterruptAttr *clone(ASTContext &C) const;
888 void printPretty(raw_ostream &OS,
889 const PrintingPolicy &Policy) const;
890 const char *getSpelling() const;
891
892
893 static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86Interrupt; }
894};
895
896class AnyX86NoCallerSavedRegistersAttr : public InheritableAttr {
897public:
898 static AnyX86NoCallerSavedRegistersAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
899 auto *A = new (Ctx) AnyX86NoCallerSavedRegistersAttr(Loc, Ctx, 0);
900 A->setImplicit(true);
901 return A;
902 }
903
904 AnyX86NoCallerSavedRegistersAttr(SourceRange R, ASTContext &Ctx
905 , unsigned SI
906 )
907 : InheritableAttr(attr::AnyX86NoCallerSavedRegisters, R, SI, false, false)
908 {
909 }
910
911 AnyX86NoCallerSavedRegistersAttr *clone(ASTContext &C) const;
912 void printPretty(raw_ostream &OS,
913 const PrintingPolicy &Policy) const;
914 const char *getSpelling() const;
915
916
917 static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86NoCallerSavedRegisters; }
918};
919
920class AnyX86NoCfCheckAttr : public InheritableAttr {
921public:
922 static AnyX86NoCfCheckAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
923 auto *A = new (Ctx) AnyX86NoCfCheckAttr(Loc, Ctx, 0);
924 A->setImplicit(true);
925 return A;
926 }
927
928 AnyX86NoCfCheckAttr(SourceRange R, ASTContext &Ctx
929 , unsigned SI
930 )
931 : InheritableAttr(attr::AnyX86NoCfCheck, R, SI, false, false)
932 {
933 }
934
935 AnyX86NoCfCheckAttr *clone(ASTContext &C) const;
936 void printPretty(raw_ostream &OS,
937 const PrintingPolicy &Policy) const;
938 const char *getSpelling() const;
939
940
941 static bool classof(const Attr *A) { return A->getKind() == attr::AnyX86NoCfCheck; }
942};
943
944class ArcWeakrefUnavailableAttr : public InheritableAttr {
945public:
946 static ArcWeakrefUnavailableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
947 auto *A = new (Ctx) ArcWeakrefUnavailableAttr(Loc, Ctx, 0);
948 A->setImplicit(true);
949 return A;
950 }
951
952 ArcWeakrefUnavailableAttr(SourceRange R, ASTContext &Ctx
953 , unsigned SI
954 )
955 : InheritableAttr(attr::ArcWeakrefUnavailable, R, SI, false, false)
956 {
957 }
958
959 ArcWeakrefUnavailableAttr *clone(ASTContext &C) const;
960 void printPretty(raw_ostream &OS,
961 const PrintingPolicy &Policy) const;
962 const char *getSpelling() const;
963
964
965 static bool classof(const Attr *A) { return A->getKind() == attr::ArcWeakrefUnavailable; }
966};
967
968class ArgumentWithTypeTagAttr : public InheritableAttr {
969IdentifierInfo * argumentKind;
970
971ParamIdx argumentIdx;
972
973ParamIdx typeTagIdx;
974
975bool isPointer;
976
977public:
978 enum Spelling {
979 GNU_argument_with_type_tag = 0,
980 CXX11_clang_argument_with_type_tag = 1,
981 C2x_clang_argument_with_type_tag = 2,
982 GNU_pointer_with_type_tag = 3,
983 CXX11_clang_pointer_with_type_tag = 4,
984 C2x_clang_pointer_with_type_tag = 5
985 };
986
987 static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, ParamIdx ArgumentIdx, ParamIdx TypeTagIdx, bool IsPointer, SourceRange Loc = SourceRange()) {
988 auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, IsPointer, S);
989 A->setImplicit(true);
990 return A;
991 }
992
993 static ArgumentWithTypeTagAttr *CreateImplicit(ASTContext &Ctx, Spelling S, IdentifierInfo * ArgumentKind, ParamIdx ArgumentIdx, ParamIdx TypeTagIdx, SourceRange Loc = SourceRange()) {
994 auto *A = new (Ctx) ArgumentWithTypeTagAttr(Loc, Ctx, ArgumentKind, ArgumentIdx, TypeTagIdx, S);
995 A->setImplicit(true);
996 return A;
997 }
998
999 ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx
1000 , IdentifierInfo * ArgumentKind
1001 , ParamIdx ArgumentIdx
1002 , ParamIdx TypeTagIdx
1003 , bool IsPointer
1004 , unsigned SI
1005 )
1006 : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false)
1007 , argumentKind(ArgumentKind)
1008 , argumentIdx(ArgumentIdx)
1009 , typeTagIdx(TypeTagIdx)
1010 , isPointer(IsPointer)
1011 {
1012 }
1013
1014 ArgumentWithTypeTagAttr(SourceRange R, ASTContext &Ctx
1015 , IdentifierInfo * ArgumentKind
1016 , ParamIdx ArgumentIdx
1017 , ParamIdx TypeTagIdx
1018 , unsigned SI
1019 )
1020 : InheritableAttr(attr::ArgumentWithTypeTag, R, SI, false, false)
1021 , argumentKind(ArgumentKind)
1022 , argumentIdx(ArgumentIdx)
1023 , typeTagIdx(TypeTagIdx)
1024 , isPointer()
1025 {
1026 }
1027
1028 ArgumentWithTypeTagAttr *clone(ASTContext &C) const;
1029 void printPretty(raw_ostream &OS,
1030 const PrintingPolicy &Policy) const;
1031 const char *getSpelling() const;
1032 Spelling getSemanticSpelling() const {
1033 switch (SpellingListIndex) {
1034 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 1034)
;
1035 case 0: return GNU_argument_with_type_tag;
1036 case 1: return CXX11_clang_argument_with_type_tag;
1037 case 2: return C2x_clang_argument_with_type_tag;
1038 case 3: return GNU_pointer_with_type_tag;
1039 case 4: return CXX11_clang_pointer_with_type_tag;
1040 case 5: return C2x_clang_pointer_with_type_tag;
1041 }
1042 }
1043 IdentifierInfo * getArgumentKind() const {
1044 return argumentKind;
1045 }
1046
1047 ParamIdx getArgumentIdx() const {
1048 return argumentIdx;
1049 }
1050
1051 ParamIdx getTypeTagIdx() const {
1052 return typeTagIdx;
1053 }
1054
1055 bool getIsPointer() const {
1056 return isPointer;
1057 }
1058
1059
1060
1061 static bool classof(const Attr *A) { return A->getKind() == attr::ArgumentWithTypeTag; }
1062};
1063
1064class ArtificialAttr : public InheritableAttr {
1065public:
1066 static ArtificialAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1067 auto *A = new (Ctx) ArtificialAttr(Loc, Ctx, 0);
1068 A->setImplicit(true);
1069 return A;
1070 }
1071
1072 ArtificialAttr(SourceRange R, ASTContext &Ctx
1073 , unsigned SI
1074 )
1075 : InheritableAttr(attr::Artificial, R, SI, false, false)
1076 {
1077 }
1078
1079 ArtificialAttr *clone(ASTContext &C) const;
1080 void printPretty(raw_ostream &OS,
1081 const PrintingPolicy &Policy) const;
1082 const char *getSpelling() const;
1083
1084
1085 static bool classof(const Attr *A) { return A->getKind() == attr::Artificial; }
1086};
1087
1088class AsmLabelAttr : public InheritableAttr {
1089unsigned labelLength;
1090char *label;
1091
1092public:
1093 static AsmLabelAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Label, SourceRange Loc = SourceRange()) {
1094 auto *A = new (Ctx) AsmLabelAttr(Loc, Ctx, Label, 0);
1095 A->setImplicit(true);
1096 return A;
1097 }
1098
1099 AsmLabelAttr(SourceRange R, ASTContext &Ctx
1100 , llvm::StringRef Label
1101 , unsigned SI
1102 )
1103 : InheritableAttr(attr::AsmLabel, R, SI, false, false)
1104 , labelLength(Label.size()),label(new (Ctx, 1) char[labelLength])
1105 {
1106 if (!Label.empty())
1107 std::memcpy(label, Label.data(), labelLength);
1108 }
1109
1110 AsmLabelAttr *clone(ASTContext &C) const;
1111 void printPretty(raw_ostream &OS,
1112 const PrintingPolicy &Policy) const;
1113 const char *getSpelling() const;
1114 llvm::StringRef getLabel() const {
1115 return llvm::StringRef(label, labelLength);
1116 }
1117 unsigned getLabelLength() const {
1118 return labelLength;
1119 }
1120 void setLabel(ASTContext &C, llvm::StringRef S) {
1121 labelLength = S.size();
1122 this->label = new (C, 1) char [labelLength];
1123 if (!S.empty())
1124 std::memcpy(this->label, S.data(), labelLength);
1125 }
1126
1127
1128
1129 static bool classof(const Attr *A) { return A->getKind() == attr::AsmLabel; }
1130};
1131
1132class AssertCapabilityAttr : public InheritableAttr {
1133 unsigned args_Size;
1134 Expr * *args_;
1135
1136public:
1137 enum Spelling {
1138 GNU_assert_capability = 0,
1139 CXX11_clang_assert_capability = 1,
1140 GNU_assert_shared_capability = 2,
1141 CXX11_clang_assert_shared_capability = 3
1142 };
1143
1144 static AssertCapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1145 auto *A = new (Ctx) AssertCapabilityAttr(Loc, Ctx, Args, ArgsSize, S);
1146 A->setImplicit(true);
1147 return A;
1148 }
1149
1150 AssertCapabilityAttr(SourceRange R, ASTContext &Ctx
1151 , Expr * *Args, unsigned ArgsSize
1152 , unsigned SI
1153 )
1154 : InheritableAttr(attr::AssertCapability, R, SI, true, true)
1155 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1156 {
1157 std::copy(Args, Args + args_Size, args_);
1158 }
1159
1160 AssertCapabilityAttr(SourceRange R, ASTContext &Ctx
1161 , unsigned SI
1162 )
1163 : InheritableAttr(attr::AssertCapability, R, SI, true, true)
1164 , args_Size(0), args_(nullptr)
1165 {
1166 }
1167
1168 AssertCapabilityAttr *clone(ASTContext &C) const;
1169 void printPretty(raw_ostream &OS,
1170 const PrintingPolicy &Policy) const;
1171 const char *getSpelling() const;
1172 Spelling getSemanticSpelling() const {
1173 switch (SpellingListIndex) {
1174 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 1174)
;
1175 case 0: return GNU_assert_capability;
1176 case 1: return CXX11_clang_assert_capability;
1177 case 2: return GNU_assert_shared_capability;
1178 case 3: return CXX11_clang_assert_shared_capability;
1179 }
1180 }
1181 bool isShared() const { return SpellingListIndex == 2 ||
1182 SpellingListIndex == 3; }
1183 typedef Expr ** args_iterator;
1184 args_iterator args_begin() const { return args_; }
1185 args_iterator args_end() const { return args_ + args_Size; }
1186 unsigned args_size() const { return args_Size; }
1187 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1188
1189
1190
1191
1192 static bool classof(const Attr *A) { return A->getKind() == attr::AssertCapability; }
1193};
1194
1195class AssertExclusiveLockAttr : public InheritableAttr {
1196 unsigned args_Size;
1197 Expr * *args_;
1198
1199public:
1200 static AssertExclusiveLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1201 auto *A = new (Ctx) AssertExclusiveLockAttr(Loc, Ctx, Args, ArgsSize, 0);
1202 A->setImplicit(true);
1203 return A;
1204 }
1205
1206 AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx
1207 , Expr * *Args, unsigned ArgsSize
1208 , unsigned SI
1209 )
1210 : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true)
1211 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1212 {
1213 std::copy(Args, Args + args_Size, args_);
1214 }
1215
1216 AssertExclusiveLockAttr(SourceRange R, ASTContext &Ctx
1217 , unsigned SI
1218 )
1219 : InheritableAttr(attr::AssertExclusiveLock, R, SI, true, true)
1220 , args_Size(0), args_(nullptr)
1221 {
1222 }
1223
1224 AssertExclusiveLockAttr *clone(ASTContext &C) const;
1225 void printPretty(raw_ostream &OS,
1226 const PrintingPolicy &Policy) const;
1227 const char *getSpelling() const;
1228 typedef Expr ** args_iterator;
1229 args_iterator args_begin() const { return args_; }
1230 args_iterator args_end() const { return args_ + args_Size; }
1231 unsigned args_size() const { return args_Size; }
1232 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1233
1234
1235
1236
1237 static bool classof(const Attr *A) { return A->getKind() == attr::AssertExclusiveLock; }
1238};
1239
1240class AssertSharedLockAttr : public InheritableAttr {
1241 unsigned args_Size;
1242 Expr * *args_;
1243
1244public:
1245 static AssertSharedLockAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
1246 auto *A = new (Ctx) AssertSharedLockAttr(Loc, Ctx, Args, ArgsSize, 0);
1247 A->setImplicit(true);
1248 return A;
1249 }
1250
1251 AssertSharedLockAttr(SourceRange R, ASTContext &Ctx
1252 , Expr * *Args, unsigned ArgsSize
1253 , unsigned SI
1254 )
1255 : InheritableAttr(attr::AssertSharedLock, R, SI, true, true)
1256 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
1257 {
1258 std::copy(Args, Args + args_Size, args_);
1259 }
1260
1261 AssertSharedLockAttr(SourceRange R, ASTContext &Ctx
1262 , unsigned SI
1263 )
1264 : InheritableAttr(attr::AssertSharedLock, R, SI, true, true)
1265 , args_Size(0), args_(nullptr)
1266 {
1267 }
1268
1269 AssertSharedLockAttr *clone(ASTContext &C) const;
1270 void printPretty(raw_ostream &OS,
1271 const PrintingPolicy &Policy) const;
1272 const char *getSpelling() const;
1273 typedef Expr ** args_iterator;
1274 args_iterator args_begin() const { return args_; }
1275 args_iterator args_end() const { return args_ + args_Size; }
1276 unsigned args_size() const { return args_Size; }
1277 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
1278
1279
1280
1281
1282 static bool classof(const Attr *A) { return A->getKind() == attr::AssertSharedLock; }
1283};
1284
1285class AssumeAlignedAttr : public InheritableAttr {
1286Expr * alignment;
1287
1288Expr * offset;
1289
1290public:
1291 static AssumeAlignedAttr *CreateImplicit(ASTContext &Ctx, Expr * Alignment, Expr * Offset, SourceRange Loc = SourceRange()) {
1292 auto *A = new (Ctx) AssumeAlignedAttr(Loc, Ctx, Alignment, Offset, 0);
1293 A->setImplicit(true);
1294 return A;
1295 }
1296
1297 AssumeAlignedAttr(SourceRange R, ASTContext &Ctx
1298 , Expr * Alignment
1299 , Expr * Offset
1300 , unsigned SI
1301 )
1302 : InheritableAttr(attr::AssumeAligned, R, SI, false, false)
1303 , alignment(Alignment)
1304 , offset(Offset)
1305 {
1306 }
1307
1308 AssumeAlignedAttr(SourceRange R, ASTContext &Ctx
1309 , Expr * Alignment
1310 , unsigned SI
1311 )
1312 : InheritableAttr(attr::AssumeAligned, R, SI, false, false)
1313 , alignment(Alignment)
1314 , offset()
1315 {
1316 }
1317
1318 AssumeAlignedAttr *clone(ASTContext &C) const;
1319 void printPretty(raw_ostream &OS,
1320 const PrintingPolicy &Policy) const;
1321 const char *getSpelling() const;
1322 Expr * getAlignment() const {
1323 return alignment;
1324 }
1325
1326 Expr * getOffset() const {
1327 return offset;
1328 }
1329
1330
1331
1332 static bool classof(const Attr *A) { return A->getKind() == attr::AssumeAligned; }
1333};
1334
1335class AvailabilityAttr : public InheritableAttr {
1336IdentifierInfo * platform;
1337
1338VersionTuple introduced;
1339
1340
1341VersionTuple deprecated;
1342
1343
1344VersionTuple obsoleted;
1345
1346
1347bool unavailable;
1348
1349unsigned messageLength;
1350char *message;
1351
1352bool strict;
1353
1354unsigned replacementLength;
1355char *replacement;
1356
1357public:
1358 static AvailabilityAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool Unavailable, llvm::StringRef Message, bool Strict, llvm::StringRef Replacement, SourceRange Loc = SourceRange()) {
1359 auto *A = new (Ctx) AvailabilityAttr(Loc, Ctx, Platform, Introduced, Deprecated, Obsoleted, Unavailable, Message, Strict, Replacement, 0);
1360 A->setImplicit(true);
1361 return A;
1362 }
1363
1364 AvailabilityAttr(SourceRange R, ASTContext &Ctx
1365 , IdentifierInfo * Platform
1366 , VersionTuple Introduced
1367 , VersionTuple Deprecated
1368 , VersionTuple Obsoleted
1369 , bool Unavailable
1370 , llvm::StringRef Message
1371 , bool Strict
1372 , llvm::StringRef Replacement
1373 , unsigned SI
1374 )
1375 : InheritableAttr(attr::Availability, R, SI, false, true)
1376 , platform(Platform)
1377 , introduced(Introduced)
1378 , deprecated(Deprecated)
1379 , obsoleted(Obsoleted)
1380 , unavailable(Unavailable)
1381 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
1382 , strict(Strict)
1383 , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength])
1384 {
1385 if (!Message.empty())
1386 std::memcpy(message, Message.data(), messageLength);
1387 if (!Replacement.empty())
1388 std::memcpy(replacement, Replacement.data(), replacementLength);
1389 }
1390
1391 AvailabilityAttr *clone(ASTContext &C) const;
1392 void printPretty(raw_ostream &OS,
1393 const PrintingPolicy &Policy) const;
1394 const char *getSpelling() const;
1395 IdentifierInfo * getPlatform() const {
1396 return platform;
1397 }
1398
1399 VersionTuple getIntroduced() const {
1400 return introduced;
1401 }
1402 void setIntroduced(ASTContext &C, VersionTuple V) {
1403 introduced = V;
1404 }
1405
1406 VersionTuple getDeprecated() const {
1407 return deprecated;
1408 }
1409 void setDeprecated(ASTContext &C, VersionTuple V) {
1410 deprecated = V;
1411 }
1412
1413 VersionTuple getObsoleted() const {
1414 return obsoleted;
1415 }
1416 void setObsoleted(ASTContext &C, VersionTuple V) {
1417 obsoleted = V;
1418 }
1419
1420 bool getUnavailable() const {
1421 return unavailable;
1422 }
1423
1424 llvm::StringRef getMessage() const {
1425 return llvm::StringRef(message, messageLength);
1426 }
1427 unsigned getMessageLength() const {
1428 return messageLength;
1429 }
1430 void setMessage(ASTContext &C, llvm::StringRef S) {
1431 messageLength = S.size();
1432 this->message = new (C, 1) char [messageLength];
1433 if (!S.empty())
1434 std::memcpy(this->message, S.data(), messageLength);
1435 }
1436
1437 bool getStrict() const {
1438 return strict;
1439 }
1440
1441 llvm::StringRef getReplacement() const {
1442 return llvm::StringRef(replacement, replacementLength);
1443 }
1444 unsigned getReplacementLength() const {
1445 return replacementLength;
1446 }
1447 void setReplacement(ASTContext &C, llvm::StringRef S) {
1448 replacementLength = S.size();
1449 this->replacement = new (C, 1) char [replacementLength];
1450 if (!S.empty())
1451 std::memcpy(this->replacement, S.data(), replacementLength);
1452 }
1453
1454static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
1455 return llvm::StringSwitch<llvm::StringRef>(Platform)
1456 .Case("android", "Android")
1457 .Case("ios", "iOS")
1458 .Case("macos", "macOS")
1459 .Case("tvos", "tvOS")
1460 .Case("watchos", "watchOS")
1461 .Case("ios_app_extension", "iOS (App Extension)")
1462 .Case("macos_app_extension", "macOS (App Extension)")
1463 .Case("tvos_app_extension", "tvOS (App Extension)")
1464 .Case("watchos_app_extension", "watchOS (App Extension)")
1465 .Default(llvm::StringRef());
1466}
1467static llvm::StringRef getPlatformNameSourceSpelling(llvm::StringRef Platform) {
1468 return llvm::StringSwitch<llvm::StringRef>(Platform)
1469 .Case("ios", "iOS")
1470 .Case("macos", "macOS")
1471 .Case("tvos", "tvOS")
1472 .Case("watchos", "watchOS")
1473 .Case("ios_app_extension", "iOSApplicationExtension")
1474 .Case("macos_app_extension", "macOSApplicationExtension")
1475 .Case("tvos_app_extension", "tvOSApplicationExtension")
1476 .Case("watchos_app_extension", "watchOSApplicationExtension")
1477 .Default(Platform);
1478}
1479static llvm::StringRef canonicalizePlatformName(llvm::StringRef Platform) {
1480 return llvm::StringSwitch<llvm::StringRef>(Platform)
1481 .Case("iOS", "ios")
1482 .Case("macOS", "macos")
1483 .Case("tvOS", "tvos")
1484 .Case("watchOS", "watchos")
1485 .Case("iOSApplicationExtension", "ios_app_extension")
1486 .Case("macOSApplicationExtension", "macos_app_extension")
1487 .Case("tvOSApplicationExtension", "tvos_app_extension")
1488 .Case("watchOSApplicationExtension", "watchos_app_extension")
1489 .Default(Platform);
1490}
1491
1492 static bool classof(const Attr *A) { return A->getKind() == attr::Availability; }
1493};
1494
1495class BlocksAttr : public InheritableAttr {
1496public:
1497 enum BlockType {
1498 ByRef
1499 };
1500private:
1501 BlockType type;
1502
1503public:
1504 static BlocksAttr *CreateImplicit(ASTContext &Ctx, BlockType Type, SourceRange Loc = SourceRange()) {
1505 auto *A = new (Ctx) BlocksAttr(Loc, Ctx, Type, 0);
1506 A->setImplicit(true);
1507 return A;
1508 }
1509
1510 BlocksAttr(SourceRange R, ASTContext &Ctx
1511 , BlockType Type
1512 , unsigned SI
1513 )
1514 : InheritableAttr(attr::Blocks, R, SI, false, false)
1515 , type(Type)
1516 {
1517 }
1518
1519 BlocksAttr *clone(ASTContext &C) const;
1520 void printPretty(raw_ostream &OS,
1521 const PrintingPolicy &Policy) const;
1522 const char *getSpelling() const;
1523 BlockType getType() const {
1524 return type;
1525 }
1526
1527 static bool ConvertStrToBlockType(StringRef Val, BlockType &Out) {
1528 Optional<BlockType> R = llvm::StringSwitch<Optional<BlockType>>(Val)
1529 .Case("byref", BlocksAttr::ByRef)
1530 .Default(Optional<BlockType>());
1531 if (R) {
1532 Out = *R;
1533 return true;
1534 }
1535 return false;
1536 }
1537
1538 static const char *ConvertBlockTypeToStr(BlockType Val) {
1539 switch(Val) {
1540 case BlocksAttr::ByRef: return "byref";
1541 }
1542 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 1542)
;
1543 }
1544
1545
1546 static bool classof(const Attr *A) { return A->getKind() == attr::Blocks; }
1547};
1548
1549class C11NoReturnAttr : public InheritableAttr {
1550public:
1551 static C11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1552 auto *A = new (Ctx) C11NoReturnAttr(Loc, Ctx, 0);
1553 A->setImplicit(true);
1554 return A;
1555 }
1556
1557 C11NoReturnAttr(SourceRange R, ASTContext &Ctx
1558 , unsigned SI
1559 )
1560 : InheritableAttr(attr::C11NoReturn, R, SI, false, false)
1561 {
1562 }
1563
1564 C11NoReturnAttr *clone(ASTContext &C) const;
1565 void printPretty(raw_ostream &OS,
1566 const PrintingPolicy &Policy) const;
1567 const char *getSpelling() const;
1568
1569
1570 static bool classof(const Attr *A) { return A->getKind() == attr::C11NoReturn; }
1571};
1572
1573class CDeclAttr : public InheritableAttr {
1574public:
1575 static CDeclAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1576 auto *A = new (Ctx) CDeclAttr(Loc, Ctx, 0);
1577 A->setImplicit(true);
1578 return A;
1579 }
1580
1581 CDeclAttr(SourceRange R, ASTContext &Ctx
1582 , unsigned SI
1583 )
1584 : InheritableAttr(attr::CDecl, R, SI, false, false)
1585 {
1586 }
1587
1588 CDeclAttr *clone(ASTContext &C) const;
1589 void printPretty(raw_ostream &OS,
1590 const PrintingPolicy &Policy) const;
1591 const char *getSpelling() const;
1592
1593
1594 static bool classof(const Attr *A) { return A->getKind() == attr::CDecl; }
1595};
1596
1597class CFAuditedTransferAttr : public InheritableAttr {
1598public:
1599 static CFAuditedTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1600 auto *A = new (Ctx) CFAuditedTransferAttr(Loc, Ctx, 0);
1601 A->setImplicit(true);
1602 return A;
1603 }
1604
1605 CFAuditedTransferAttr(SourceRange R, ASTContext &Ctx
1606 , unsigned SI
1607 )
1608 : InheritableAttr(attr::CFAuditedTransfer, R, SI, false, false)
1609 {
1610 }
1611
1612 CFAuditedTransferAttr *clone(ASTContext &C) const;
1613 void printPretty(raw_ostream &OS,
1614 const PrintingPolicy &Policy) const;
1615 const char *getSpelling() const;
1616
1617
1618 static bool classof(const Attr *A) { return A->getKind() == attr::CFAuditedTransfer; }
1619};
1620
1621class CFConsumedAttr : public InheritableParamAttr {
1622public:
1623 static CFConsumedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1624 auto *A = new (Ctx) CFConsumedAttr(Loc, Ctx, 0);
1625 A->setImplicit(true);
1626 return A;
1627 }
1628
1629 CFConsumedAttr(SourceRange R, ASTContext &Ctx
1630 , unsigned SI
1631 )
1632 : InheritableParamAttr(attr::CFConsumed, R, SI, false, false)
1633 {
1634 }
1635
1636 CFConsumedAttr *clone(ASTContext &C) const;
1637 void printPretty(raw_ostream &OS,
1638 const PrintingPolicy &Policy) const;
1639 const char *getSpelling() const;
1640
1641
1642 static bool classof(const Attr *A) { return A->getKind() == attr::CFConsumed; }
1643};
1644
1645class CFReturnsNotRetainedAttr : public InheritableAttr {
1646public:
1647 static CFReturnsNotRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1648 auto *A = new (Ctx) CFReturnsNotRetainedAttr(Loc, Ctx, 0);
1649 A->setImplicit(true);
1650 return A;
1651 }
1652
1653 CFReturnsNotRetainedAttr(SourceRange R, ASTContext &Ctx
1654 , unsigned SI
1655 )
1656 : InheritableAttr(attr::CFReturnsNotRetained, R, SI, false, false)
1657 {
1658 }
1659
1660 CFReturnsNotRetainedAttr *clone(ASTContext &C) const;
1661 void printPretty(raw_ostream &OS,
1662 const PrintingPolicy &Policy) const;
1663 const char *getSpelling() const;
1664
1665
1666 static bool classof(const Attr *A) { return A->getKind() == attr::CFReturnsNotRetained; }
1667};
1668
1669class CFReturnsRetainedAttr : public InheritableAttr {
1670public:
1671 static CFReturnsRetainedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1672 auto *A = new (Ctx) CFReturnsRetainedAttr(Loc, Ctx, 0);
1673 A->setImplicit(true);
1674 return A;
1675 }
1676
1677 CFReturnsRetainedAttr(SourceRange R, ASTContext &Ctx
1678 , unsigned SI
1679 )
1680 : InheritableAttr(attr::CFReturnsRetained, R, SI, false, false)
1681 {
1682 }
1683
1684 CFReturnsRetainedAttr *clone(ASTContext &C) const;
1685 void printPretty(raw_ostream &OS,
1686 const PrintingPolicy &Policy) const;
1687 const char *getSpelling() const;
1688
1689
1690 static bool classof(const Attr *A) { return A->getKind() == attr::CFReturnsRetained; }
1691};
1692
1693class CFUnknownTransferAttr : public InheritableAttr {
1694public:
1695 static CFUnknownTransferAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1696 auto *A = new (Ctx) CFUnknownTransferAttr(Loc, Ctx, 0);
1697 A->setImplicit(true);
1698 return A;
1699 }
1700
1701 CFUnknownTransferAttr(SourceRange R, ASTContext &Ctx
1702 , unsigned SI
1703 )
1704 : InheritableAttr(attr::CFUnknownTransfer, R, SI, false, false)
1705 {
1706 }
1707
1708 CFUnknownTransferAttr *clone(ASTContext &C) const;
1709 void printPretty(raw_ostream &OS,
1710 const PrintingPolicy &Policy) const;
1711 const char *getSpelling() const;
1712
1713
1714 static bool classof(const Attr *A) { return A->getKind() == attr::CFUnknownTransfer; }
1715};
1716
1717class CUDAConstantAttr : public InheritableAttr {
1718public:
1719 static CUDAConstantAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1720 auto *A = new (Ctx) CUDAConstantAttr(Loc, Ctx, 0);
1721 A->setImplicit(true);
1722 return A;
1723 }
1724
1725 CUDAConstantAttr(SourceRange R, ASTContext &Ctx
1726 , unsigned SI
1727 )
1728 : InheritableAttr(attr::CUDAConstant, R, SI, false, false)
1729 {
1730 }
1731
1732 CUDAConstantAttr *clone(ASTContext &C) const;
1733 void printPretty(raw_ostream &OS,
1734 const PrintingPolicy &Policy) const;
1735 const char *getSpelling() const;
1736
1737
1738 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAConstant; }
1739};
1740
1741class CUDADeviceAttr : public InheritableAttr {
1742public:
1743 static CUDADeviceAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1744 auto *A = new (Ctx) CUDADeviceAttr(Loc, Ctx, 0);
1745 A->setImplicit(true);
1746 return A;
1747 }
1748
1749 CUDADeviceAttr(SourceRange R, ASTContext &Ctx
1750 , unsigned SI
1751 )
1752 : InheritableAttr(attr::CUDADevice, R, SI, false, false)
1753 {
1754 }
1755
1756 CUDADeviceAttr *clone(ASTContext &C) const;
1757 void printPretty(raw_ostream &OS,
1758 const PrintingPolicy &Policy) const;
1759 const char *getSpelling() const;
1760
1761
1762 static bool classof(const Attr *A) { return A->getKind() == attr::CUDADevice; }
1763};
1764
1765class CUDAGlobalAttr : public InheritableAttr {
1766public:
1767 static CUDAGlobalAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1768 auto *A = new (Ctx) CUDAGlobalAttr(Loc, Ctx, 0);
1769 A->setImplicit(true);
1770 return A;
1771 }
1772
1773 CUDAGlobalAttr(SourceRange R, ASTContext &Ctx
1774 , unsigned SI
1775 )
1776 : InheritableAttr(attr::CUDAGlobal, R, SI, false, false)
1777 {
1778 }
1779
1780 CUDAGlobalAttr *clone(ASTContext &C) const;
1781 void printPretty(raw_ostream &OS,
1782 const PrintingPolicy &Policy) const;
1783 const char *getSpelling() const;
1784
1785
1786 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAGlobal; }
1787};
1788
1789class CUDAHostAttr : public InheritableAttr {
1790public:
1791 static CUDAHostAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1792 auto *A = new (Ctx) CUDAHostAttr(Loc, Ctx, 0);
1793 A->setImplicit(true);
1794 return A;
1795 }
1796
1797 CUDAHostAttr(SourceRange R, ASTContext &Ctx
1798 , unsigned SI
1799 )
1800 : InheritableAttr(attr::CUDAHost, R, SI, false, false)
1801 {
1802 }
1803
1804 CUDAHostAttr *clone(ASTContext &C) const;
1805 void printPretty(raw_ostream &OS,
1806 const PrintingPolicy &Policy) const;
1807 const char *getSpelling() const;
1808
1809
1810 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAHost; }
1811};
1812
1813class CUDAInvalidTargetAttr : public InheritableAttr {
1814public:
1815 static CUDAInvalidTargetAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1816 auto *A = new (Ctx) CUDAInvalidTargetAttr(Loc, Ctx, 0);
1817 A->setImplicit(true);
1818 return A;
1819 }
1820
1821 CUDAInvalidTargetAttr(SourceRange R, ASTContext &Ctx
1822 , unsigned SI
1823 )
1824 : InheritableAttr(attr::CUDAInvalidTarget, R, SI, false, false)
1825 {
1826 }
1827
1828 CUDAInvalidTargetAttr *clone(ASTContext &C) const;
1829 void printPretty(raw_ostream &OS,
1830 const PrintingPolicy &Policy) const;
1831 const char *getSpelling() const;
1832
1833
1834 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAInvalidTarget; }
1835};
1836
1837class CUDALaunchBoundsAttr : public InheritableAttr {
1838Expr * maxThreads;
1839
1840Expr * minBlocks;
1841
1842public:
1843 static CUDALaunchBoundsAttr *CreateImplicit(ASTContext &Ctx, Expr * MaxThreads, Expr * MinBlocks, SourceRange Loc = SourceRange()) {
1844 auto *A = new (Ctx) CUDALaunchBoundsAttr(Loc, Ctx, MaxThreads, MinBlocks, 0);
1845 A->setImplicit(true);
1846 return A;
1847 }
1848
1849 CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx
1850 , Expr * MaxThreads
1851 , Expr * MinBlocks
1852 , unsigned SI
1853 )
1854 : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false)
1855 , maxThreads(MaxThreads)
1856 , minBlocks(MinBlocks)
1857 {
1858 }
1859
1860 CUDALaunchBoundsAttr(SourceRange R, ASTContext &Ctx
1861 , Expr * MaxThreads
1862 , unsigned SI
1863 )
1864 : InheritableAttr(attr::CUDALaunchBounds, R, SI, false, false)
1865 , maxThreads(MaxThreads)
1866 , minBlocks()
1867 {
1868 }
1869
1870 CUDALaunchBoundsAttr *clone(ASTContext &C) const;
1871 void printPretty(raw_ostream &OS,
1872 const PrintingPolicy &Policy) const;
1873 const char *getSpelling() const;
1874 Expr * getMaxThreads() const {
1875 return maxThreads;
1876 }
1877
1878 Expr * getMinBlocks() const {
1879 return minBlocks;
1880 }
1881
1882
1883
1884 static bool classof(const Attr *A) { return A->getKind() == attr::CUDALaunchBounds; }
1885};
1886
1887class CUDASharedAttr : public InheritableAttr {
1888public:
1889 static CUDASharedAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1890 auto *A = new (Ctx) CUDASharedAttr(Loc, Ctx, 0);
1891 A->setImplicit(true);
1892 return A;
1893 }
1894
1895 CUDASharedAttr(SourceRange R, ASTContext &Ctx
1896 , unsigned SI
1897 )
1898 : InheritableAttr(attr::CUDAShared, R, SI, false, false)
1899 {
1900 }
1901
1902 CUDASharedAttr *clone(ASTContext &C) const;
1903 void printPretty(raw_ostream &OS,
1904 const PrintingPolicy &Policy) const;
1905 const char *getSpelling() const;
1906
1907
1908 static bool classof(const Attr *A) { return A->getKind() == attr::CUDAShared; }
1909};
1910
1911class CXX11NoReturnAttr : public InheritableAttr {
1912public:
1913 static CXX11NoReturnAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
1914 auto *A = new (Ctx) CXX11NoReturnAttr(Loc, Ctx, 0);
1915 A->setImplicit(true);
1916 return A;
1917 }
1918
1919 CXX11NoReturnAttr(SourceRange R, ASTContext &Ctx
1920 , unsigned SI
1921 )
1922 : InheritableAttr(attr::CXX11NoReturn, R, SI, false, false)
1923 {
1924 }
1925
1926 CXX11NoReturnAttr *clone(ASTContext &C) const;
1927 void printPretty(raw_ostream &OS,
1928 const PrintingPolicy &Policy) const;
1929 const char *getSpelling() const;
1930
1931
1932 static bool classof(const Attr *A) { return A->getKind() == attr::CXX11NoReturn; }
1933};
1934
1935class CallableWhenAttr : public InheritableAttr {
1936public:
1937 enum ConsumedState {
1938 Unknown,
1939 Consumed,
1940 Unconsumed
1941 };
1942private:
1943 unsigned callableStates_Size;
1944 ConsumedState *callableStates_;
1945
1946public:
1947 static CallableWhenAttr *CreateImplicit(ASTContext &Ctx, ConsumedState *CallableStates, unsigned CallableStatesSize, SourceRange Loc = SourceRange()) {
1948 auto *A = new (Ctx) CallableWhenAttr(Loc, Ctx, CallableStates, CallableStatesSize, 0);
1949 A->setImplicit(true);
1950 return A;
1951 }
1952
1953 CallableWhenAttr(SourceRange R, ASTContext &Ctx
1954 , ConsumedState *CallableStates, unsigned CallableStatesSize
1955 , unsigned SI
1956 )
1957 : InheritableAttr(attr::CallableWhen, R, SI, false, false)
1958 , callableStates_Size(CallableStatesSize), callableStates_(new (Ctx, 16) ConsumedState[callableStates_Size])
1959 {
1960 std::copy(CallableStates, CallableStates + callableStates_Size, callableStates_);
1961 }
1962
1963 CallableWhenAttr(SourceRange R, ASTContext &Ctx
1964 , unsigned SI
1965 )
1966 : InheritableAttr(attr::CallableWhen, R, SI, false, false)
1967 , callableStates_Size(0), callableStates_(nullptr)
1968 {
1969 }
1970
1971 CallableWhenAttr *clone(ASTContext &C) const;
1972 void printPretty(raw_ostream &OS,
1973 const PrintingPolicy &Policy) const;
1974 const char *getSpelling() const;
1975 typedef ConsumedState* callableStates_iterator;
1976 callableStates_iterator callableStates_begin() const { return callableStates_; }
1977 callableStates_iterator callableStates_end() const { return callableStates_ + callableStates_Size; }
1978 unsigned callableStates_size() const { return callableStates_Size; }
1979 llvm::iterator_range<callableStates_iterator> callableStates() const { return llvm::make_range(callableStates_begin(), callableStates_end()); }
1980
1981
1982 static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
1983 Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
1984 .Case("unknown", CallableWhenAttr::Unknown)
1985 .Case("consumed", CallableWhenAttr::Consumed)
1986 .Case("unconsumed", CallableWhenAttr::Unconsumed)
1987 .Default(Optional<ConsumedState>());
1988 if (R) {
1989 Out = *R;
1990 return true;
1991 }
1992 return false;
1993 }
1994
1995 static const char *ConvertConsumedStateToStr(ConsumedState Val) {
1996 switch(Val) {
1997 case CallableWhenAttr::Unknown: return "unknown";
1998 case CallableWhenAttr::Consumed: return "consumed";
1999 case CallableWhenAttr::Unconsumed: return "unconsumed";
2000 }
2001 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 2001)
;
2002 }
2003
2004
2005 static bool classof(const Attr *A) { return A->getKind() == attr::CallableWhen; }
2006};
2007
2008class CapabilityAttr : public InheritableAttr {
2009unsigned nameLength;
2010char *name;
2011
2012public:
2013 enum Spelling {
2014 GNU_capability = 0,
2015 CXX11_clang_capability = 1,
2016 GNU_shared_capability = 2,
2017 CXX11_clang_shared_capability = 3
2018 };
2019
2020 static CapabilityAttr *CreateImplicit(ASTContext &Ctx, Spelling S, llvm::StringRef Name, SourceRange Loc = SourceRange()) {
2021 auto *A = new (Ctx) CapabilityAttr(Loc, Ctx, Name, S);
2022 A->setImplicit(true);
2023 return A;
2024 }
2025
2026 CapabilityAttr(SourceRange R, ASTContext &Ctx
2027 , llvm::StringRef Name
2028 , unsigned SI
2029 )
2030 : InheritableAttr(attr::Capability, R, SI, false, false)
2031 , nameLength(Name.size()),name(new (Ctx, 1) char[nameLength])
2032 {
2033 if (!Name.empty())
2034 std::memcpy(name, Name.data(), nameLength);
2035 }
2036
2037 CapabilityAttr *clone(ASTContext &C) const;
2038 void printPretty(raw_ostream &OS,
2039 const PrintingPolicy &Policy) const;
2040 const char *getSpelling() const;
2041 Spelling getSemanticSpelling() const {
2042 switch (SpellingListIndex) {
2043 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 2043)
;
2044 case 0: return GNU_capability;
2045 case 1: return CXX11_clang_capability;
2046 case 2: return GNU_shared_capability;
2047 case 3: return CXX11_clang_shared_capability;
2048 }
2049 }
2050 bool isShared() const { return SpellingListIndex == 2 ||
2051 SpellingListIndex == 3; }
2052 llvm::StringRef getName() const {
2053 return llvm::StringRef(name, nameLength);
2054 }
2055 unsigned getNameLength() const {
2056 return nameLength;
2057 }
2058 void setName(ASTContext &C, llvm::StringRef S) {
2059 nameLength = S.size();
2060 this->name = new (C, 1) char [nameLength];
2061 if (!S.empty())
2062 std::memcpy(this->name, S.data(), nameLength);
2063 }
2064
2065
2066 bool isMutex() const { return getName().equals_lower("mutex"); }
2067 bool isRole() const { return getName().equals_lower("role"); }
2068
2069
2070 static bool classof(const Attr *A) { return A->getKind() == attr::Capability; }
2071};
2072
2073class CapturedRecordAttr : public InheritableAttr {
2074public:
2075 static CapturedRecordAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2076 auto *A = new (Ctx) CapturedRecordAttr(Loc, Ctx, 0);
2077 A->setImplicit(true);
2078 return A;
2079 }
2080
2081 CapturedRecordAttr(SourceRange R, ASTContext &Ctx
2082 , unsigned SI
2083 )
2084 : InheritableAttr(attr::CapturedRecord, R, SI, false, false)
2085 {
2086 }
2087
2088 CapturedRecordAttr *clone(ASTContext &C) const;
2089 void printPretty(raw_ostream &OS,
2090 const PrintingPolicy &Policy) const;
2091 const char *getSpelling() const;
2092
2093
2094 static bool classof(const Attr *A) { return A->getKind() == attr::CapturedRecord; }
2095};
2096
2097class CarriesDependencyAttr : public InheritableParamAttr {
2098public:
2099 static CarriesDependencyAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2100 auto *A = new (Ctx) CarriesDependencyAttr(Loc, Ctx, 0);
2101 A->setImplicit(true);
2102 return A;
2103 }
2104
2105 CarriesDependencyAttr(SourceRange R, ASTContext &Ctx
2106 , unsigned SI
2107 )
2108 : InheritableParamAttr(attr::CarriesDependency, R, SI, false, false)
2109 {
2110 }
2111
2112 CarriesDependencyAttr *clone(ASTContext &C) const;
2113 void printPretty(raw_ostream &OS,
2114 const PrintingPolicy &Policy) const;
2115 const char *getSpelling() const;
2116
2117
2118 static bool classof(const Attr *A) { return A->getKind() == attr::CarriesDependency; }
2119};
2120
2121class CleanupAttr : public InheritableAttr {
2122FunctionDecl * functionDecl;
2123
2124public:
2125 static CleanupAttr *CreateImplicit(ASTContext &Ctx, FunctionDecl * FunctionDecl, SourceRange Loc = SourceRange()) {
2126 auto *A = new (Ctx) CleanupAttr(Loc, Ctx, FunctionDecl, 0);
2127 A->setImplicit(true);
2128 return A;
2129 }
2130
2131 CleanupAttr(SourceRange R, ASTContext &Ctx
2132 , FunctionDecl * FunctionDecl
2133 , unsigned SI
2134 )
2135 : InheritableAttr(attr::Cleanup, R, SI, false, false)
2136 , functionDecl(FunctionDecl)
2137 {
2138 }
2139
2140 CleanupAttr *clone(ASTContext &C) const;
2141 void printPretty(raw_ostream &OS,
2142 const PrintingPolicy &Policy) const;
2143 const char *getSpelling() const;
2144 FunctionDecl * getFunctionDecl() const {
2145 return functionDecl;
2146 }
2147
2148
2149
2150 static bool classof(const Attr *A) { return A->getKind() == attr::Cleanup; }
2151};
2152
2153class ColdAttr : public InheritableAttr {
2154public:
2155 static ColdAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2156 auto *A = new (Ctx) ColdAttr(Loc, Ctx, 0);
2157 A->setImplicit(true);
2158 return A;
2159 }
2160
2161 ColdAttr(SourceRange R, ASTContext &Ctx
2162 , unsigned SI
2163 )
2164 : InheritableAttr(attr::Cold, R, SI, false, false)
2165 {
2166 }
2167
2168 ColdAttr *clone(ASTContext &C) const;
2169 void printPretty(raw_ostream &OS,
2170 const PrintingPolicy &Policy) const;
2171 const char *getSpelling() const;
2172
2173
2174 static bool classof(const Attr *A) { return A->getKind() == attr::Cold; }
2175};
2176
2177class CommonAttr : public InheritableAttr {
2178public:
2179 static CommonAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2180 auto *A = new (Ctx) CommonAttr(Loc, Ctx, 0);
2181 A->setImplicit(true);
2182 return A;
2183 }
2184
2185 CommonAttr(SourceRange R, ASTContext &Ctx
2186 , unsigned SI
2187 )
2188 : InheritableAttr(attr::Common, R, SI, false, false)
2189 {
2190 }
2191
2192 CommonAttr *clone(ASTContext &C) const;
2193 void printPretty(raw_ostream &OS,
2194 const PrintingPolicy &Policy) const;
2195 const char *getSpelling() const;
2196
2197
2198 static bool classof(const Attr *A) { return A->getKind() == attr::Common; }
2199};
2200
2201class ConstAttr : public InheritableAttr {
2202public:
2203 static ConstAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2204 auto *A = new (Ctx) ConstAttr(Loc, Ctx, 0);
2205 A->setImplicit(true);
2206 return A;
2207 }
2208
2209 ConstAttr(SourceRange R, ASTContext &Ctx
2210 , unsigned SI
2211 )
2212 : InheritableAttr(attr::Const, R, SI, false, false)
2213 {
2214 }
2215
2216 ConstAttr *clone(ASTContext &C) const;
2217 void printPretty(raw_ostream &OS,
2218 const PrintingPolicy &Policy) const;
2219 const char *getSpelling() const;
2220
2221
2222 static bool classof(const Attr *A) { return A->getKind() == attr::Const; }
2223};
2224
2225class ConstructorAttr : public InheritableAttr {
2226int priority;
2227
2228public:
2229 static ConstructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) {
2230 auto *A = new (Ctx) ConstructorAttr(Loc, Ctx, Priority, 0);
2231 A->setImplicit(true);
2232 return A;
2233 }
2234
2235 ConstructorAttr(SourceRange R, ASTContext &Ctx
2236 , int Priority
2237 , unsigned SI
2238 )
2239 : InheritableAttr(attr::Constructor, R, SI, false, false)
2240 , priority(Priority)
2241 {
2242 }
2243
2244 ConstructorAttr(SourceRange R, ASTContext &Ctx
2245 , unsigned SI
2246 )
2247 : InheritableAttr(attr::Constructor, R, SI, false, false)
2248 , priority()
2249 {
2250 }
2251
2252 ConstructorAttr *clone(ASTContext &C) const;
2253 void printPretty(raw_ostream &OS,
2254 const PrintingPolicy &Policy) const;
2255 const char *getSpelling() const;
2256 int getPriority() const {
2257 return priority;
2258 }
2259
2260 static const int DefaultPriority = 65535;
2261
2262
2263
2264 static bool classof(const Attr *A) { return A->getKind() == attr::Constructor; }
2265};
2266
2267class ConsumableAttr : public InheritableAttr {
2268public:
2269 enum ConsumedState {
2270 Unknown,
2271 Consumed,
2272 Unconsumed
2273 };
2274private:
2275 ConsumedState defaultState;
2276
2277public:
2278 static ConsumableAttr *CreateImplicit(ASTContext &Ctx, ConsumedState DefaultState, SourceRange Loc = SourceRange()) {
2279 auto *A = new (Ctx) ConsumableAttr(Loc, Ctx, DefaultState, 0);
2280 A->setImplicit(true);
2281 return A;
2282 }
2283
2284 ConsumableAttr(SourceRange R, ASTContext &Ctx
2285 , ConsumedState DefaultState
2286 , unsigned SI
2287 )
2288 : InheritableAttr(attr::Consumable, R, SI, false, false)
2289 , defaultState(DefaultState)
2290 {
2291 }
2292
2293 ConsumableAttr *clone(ASTContext &C) const;
2294 void printPretty(raw_ostream &OS,
2295 const PrintingPolicy &Policy) const;
2296 const char *getSpelling() const;
2297 ConsumedState getDefaultState() const {
2298 return defaultState;
2299 }
2300
2301 static bool ConvertStrToConsumedState(StringRef Val, ConsumedState &Out) {
2302 Optional<ConsumedState> R = llvm::StringSwitch<Optional<ConsumedState>>(Val)
2303 .Case("unknown", ConsumableAttr::Unknown)
2304 .Case("consumed", ConsumableAttr::Consumed)
2305 .Case("unconsumed", ConsumableAttr::Unconsumed)
2306 .Default(Optional<ConsumedState>());
2307 if (R) {
2308 Out = *R;
2309 return true;
2310 }
2311 return false;
2312 }
2313
2314 static const char *ConvertConsumedStateToStr(ConsumedState Val) {
2315 switch(Val) {
2316 case ConsumableAttr::Unknown: return "unknown";
2317 case ConsumableAttr::Consumed: return "consumed";
2318 case ConsumableAttr::Unconsumed: return "unconsumed";
2319 }
2320 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 2320)
;
2321 }
2322
2323
2324 static bool classof(const Attr *A) { return A->getKind() == attr::Consumable; }
2325};
2326
2327class ConsumableAutoCastAttr : public InheritableAttr {
2328public:
2329 static ConsumableAutoCastAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2330 auto *A = new (Ctx) ConsumableAutoCastAttr(Loc, Ctx, 0);
2331 A->setImplicit(true);
2332 return A;
2333 }
2334
2335 ConsumableAutoCastAttr(SourceRange R, ASTContext &Ctx
2336 , unsigned SI
2337 )
2338 : InheritableAttr(attr::ConsumableAutoCast, R, SI, false, false)
2339 {
2340 }
2341
2342 ConsumableAutoCastAttr *clone(ASTContext &C) const;
2343 void printPretty(raw_ostream &OS,
2344 const PrintingPolicy &Policy) const;
2345 const char *getSpelling() const;
2346
2347
2348 static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableAutoCast; }
2349};
2350
2351class ConsumableSetOnReadAttr : public InheritableAttr {
2352public:
2353 static ConsumableSetOnReadAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2354 auto *A = new (Ctx) ConsumableSetOnReadAttr(Loc, Ctx, 0);
2355 A->setImplicit(true);
2356 return A;
2357 }
2358
2359 ConsumableSetOnReadAttr(SourceRange R, ASTContext &Ctx
2360 , unsigned SI
2361 )
2362 : InheritableAttr(attr::ConsumableSetOnRead, R, SI, false, false)
2363 {
2364 }
2365
2366 ConsumableSetOnReadAttr *clone(ASTContext &C) const;
2367 void printPretty(raw_ostream &OS,
2368 const PrintingPolicy &Policy) const;
2369 const char *getSpelling() const;
2370
2371
2372 static bool classof(const Attr *A) { return A->getKind() == attr::ConsumableSetOnRead; }
2373};
2374
2375class ConvergentAttr : public InheritableAttr {
2376public:
2377 static ConvergentAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2378 auto *A = new (Ctx) ConvergentAttr(Loc, Ctx, 0);
2379 A->setImplicit(true);
2380 return A;
2381 }
2382
2383 ConvergentAttr(SourceRange R, ASTContext &Ctx
2384 , unsigned SI
2385 )
2386 : InheritableAttr(attr::Convergent, R, SI, false, false)
2387 {
2388 }
2389
2390 ConvergentAttr *clone(ASTContext &C) const;
2391 void printPretty(raw_ostream &OS,
2392 const PrintingPolicy &Policy) const;
2393 const char *getSpelling() const;
2394
2395
2396 static bool classof(const Attr *A) { return A->getKind() == attr::Convergent; }
2397};
2398
2399class DLLExportAttr : public InheritableAttr {
2400public:
2401 static DLLExportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2402 auto *A = new (Ctx) DLLExportAttr(Loc, Ctx, 0);
2403 A->setImplicit(true);
2404 return A;
2405 }
2406
2407 DLLExportAttr(SourceRange R, ASTContext &Ctx
2408 , unsigned SI
2409 )
2410 : InheritableAttr(attr::DLLExport, R, SI, false, false)
2411 {
2412 }
2413
2414 DLLExportAttr *clone(ASTContext &C) const;
2415 void printPretty(raw_ostream &OS,
2416 const PrintingPolicy &Policy) const;
2417 const char *getSpelling() const;
2418
2419
2420 static bool classof(const Attr *A) { return A->getKind() == attr::DLLExport; }
2421};
2422
2423class DLLImportAttr : public InheritableAttr {
2424public:
2425 static DLLImportAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2426 auto *A = new (Ctx) DLLImportAttr(Loc, Ctx, 0);
2427 A->setImplicit(true);
2428 return A;
2429 }
2430
2431 DLLImportAttr(SourceRange R, ASTContext &Ctx
2432 , unsigned SI
2433 )
2434 : InheritableAttr(attr::DLLImport, R, SI, false, false)
2435 {
2436 }
2437
2438 DLLImportAttr *clone(ASTContext &C) const;
2439 void printPretty(raw_ostream &OS,
2440 const PrintingPolicy &Policy) const;
2441 const char *getSpelling() const;
2442
2443
2444 static bool classof(const Attr *A) { return A->getKind() == attr::DLLImport; }
2445};
2446
2447class DeprecatedAttr : public InheritableAttr {
2448unsigned messageLength;
2449char *message;
2450
2451unsigned replacementLength;
2452char *replacement;
2453
2454public:
2455 static DeprecatedAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Message, llvm::StringRef Replacement, SourceRange Loc = SourceRange()) {
2456 auto *A = new (Ctx) DeprecatedAttr(Loc, Ctx, Message, Replacement, 0);
2457 A->setImplicit(true);
2458 return A;
2459 }
2460
2461 DeprecatedAttr(SourceRange R, ASTContext &Ctx
2462 , llvm::StringRef Message
2463 , llvm::StringRef Replacement
2464 , unsigned SI
2465 )
2466 : InheritableAttr(attr::Deprecated, R, SI, false, false)
2467 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2468 , replacementLength(Replacement.size()),replacement(new (Ctx, 1) char[replacementLength])
2469 {
2470 if (!Message.empty())
2471 std::memcpy(message, Message.data(), messageLength);
2472 if (!Replacement.empty())
2473 std::memcpy(replacement, Replacement.data(), replacementLength);
2474 }
2475
2476 DeprecatedAttr(SourceRange R, ASTContext &Ctx
2477 , unsigned SI
2478 )
2479 : InheritableAttr(attr::Deprecated, R, SI, false, false)
2480 , messageLength(0),message(nullptr)
2481 , replacementLength(0),replacement(nullptr)
2482 {
2483 }
2484
2485 DeprecatedAttr *clone(ASTContext &C) const;
2486 void printPretty(raw_ostream &OS,
2487 const PrintingPolicy &Policy) const;
2488 const char *getSpelling() const;
2489 llvm::StringRef getMessage() const {
2490 return llvm::StringRef(message, messageLength);
2491 }
2492 unsigned getMessageLength() const {
2493 return messageLength;
2494 }
2495 void setMessage(ASTContext &C, llvm::StringRef S) {
2496 messageLength = S.size();
2497 this->message = new (C, 1) char [messageLength];
2498 if (!S.empty())
2499 std::memcpy(this->message, S.data(), messageLength);
2500 }
2501
2502 llvm::StringRef getReplacement() const {
2503 return llvm::StringRef(replacement, replacementLength);
2504 }
2505 unsigned getReplacementLength() const {
2506 return replacementLength;
2507 }
2508 void setReplacement(ASTContext &C, llvm::StringRef S) {
2509 replacementLength = S.size();
2510 this->replacement = new (C, 1) char [replacementLength];
2511 if (!S.empty())
2512 std::memcpy(this->replacement, S.data(), replacementLength);
2513 }
2514
2515
2516
2517 static bool classof(const Attr *A) { return A->getKind() == attr::Deprecated; }
2518};
2519
2520class DestructorAttr : public InheritableAttr {
2521int priority;
2522
2523public:
2524 static DestructorAttr *CreateImplicit(ASTContext &Ctx, int Priority, SourceRange Loc = SourceRange()) {
2525 auto *A = new (Ctx) DestructorAttr(Loc, Ctx, Priority, 0);
2526 A->setImplicit(true);
2527 return A;
2528 }
2529
2530 DestructorAttr(SourceRange R, ASTContext &Ctx
2531 , int Priority
2532 , unsigned SI
2533 )
2534 : InheritableAttr(attr::Destructor, R, SI, false, false)
2535 , priority(Priority)
2536 {
2537 }
2538
2539 DestructorAttr(SourceRange R, ASTContext &Ctx
2540 , unsigned SI
2541 )
2542 : InheritableAttr(attr::Destructor, R, SI, false, false)
2543 , priority()
2544 {
2545 }
2546
2547 DestructorAttr *clone(ASTContext &C) const;
2548 void printPretty(raw_ostream &OS,
2549 const PrintingPolicy &Policy) const;
2550 const char *getSpelling() const;
2551 int getPriority() const {
2552 return priority;
2553 }
2554
2555 static const int DefaultPriority = 65535;
2556
2557
2558
2559 static bool classof(const Attr *A) { return A->getKind() == attr::Destructor; }
2560};
2561
2562class DiagnoseIfAttr : public InheritableAttr {
2563Expr * cond;
2564
2565unsigned messageLength;
2566char *message;
2567
2568public:
2569 enum DiagnosticType {
2570 DT_Error,
2571 DT_Warning
2572 };
2573private:
2574 DiagnosticType diagnosticType;
2575
2576bool argDependent;
2577
2578NamedDecl * parent;
2579
2580public:
2581 static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, bool ArgDependent, NamedDecl * Parent, SourceRange Loc = SourceRange()) {
2582 auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, ArgDependent, Parent, 0);
2583 A->setImplicit(true);
2584 return A;
2585 }
2586
2587 static DiagnoseIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, DiagnosticType DiagnosticType, SourceRange Loc = SourceRange()) {
2588 auto *A = new (Ctx) DiagnoseIfAttr(Loc, Ctx, Cond, Message, DiagnosticType, 0);
2589 A->setImplicit(true);
2590 return A;
2591 }
2592
2593 DiagnoseIfAttr(SourceRange R, ASTContext &Ctx
2594 , Expr * Cond
2595 , llvm::StringRef Message
2596 , DiagnosticType DiagnosticType
2597 , bool ArgDependent
2598 , NamedDecl * Parent
2599 , unsigned SI
2600 )
2601 : InheritableAttr(attr::DiagnoseIf, R, SI, true, true)
2602 , cond(Cond)
2603 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2604 , diagnosticType(DiagnosticType)
2605 , argDependent(ArgDependent)
2606 , parent(Parent)
2607 {
2608 if (!Message.empty())
2609 std::memcpy(message, Message.data(), messageLength);
2610 }
2611
2612 DiagnoseIfAttr(SourceRange R, ASTContext &Ctx
2613 , Expr * Cond
2614 , llvm::StringRef Message
2615 , DiagnosticType DiagnosticType
2616 , unsigned SI
2617 )
2618 : InheritableAttr(attr::DiagnoseIf, R, SI, true, true)
2619 , cond(Cond)
2620 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2621 , diagnosticType(DiagnosticType)
2622 , argDependent()
2623 , parent()
2624 {
2625 if (!Message.empty())
2626 std::memcpy(message, Message.data(), messageLength);
2627 }
2628
2629 DiagnoseIfAttr *clone(ASTContext &C) const;
2630 void printPretty(raw_ostream &OS,
2631 const PrintingPolicy &Policy) const;
2632 const char *getSpelling() const;
2633 Expr * getCond() const {
2634 return cond;
2635 }
2636
2637 llvm::StringRef getMessage() const {
2638 return llvm::StringRef(message, messageLength);
2639 }
2640 unsigned getMessageLength() const {
2641 return messageLength;
2642 }
2643 void setMessage(ASTContext &C, llvm::StringRef S) {
2644 messageLength = S.size();
2645 this->message = new (C, 1) char [messageLength];
2646 if (!S.empty())
2647 std::memcpy(this->message, S.data(), messageLength);
2648 }
2649
2650 DiagnosticType getDiagnosticType() const {
2651 return diagnosticType;
2652 }
2653
2654 static bool ConvertStrToDiagnosticType(StringRef Val, DiagnosticType &Out) {
2655 Optional<DiagnosticType> R = llvm::StringSwitch<Optional<DiagnosticType>>(Val)
2656 .Case("error", DiagnoseIfAttr::DT_Error)
2657 .Case("warning", DiagnoseIfAttr::DT_Warning)
2658 .Default(Optional<DiagnosticType>());
2659 if (R) {
2660 Out = *R;
2661 return true;
2662 }
2663 return false;
2664 }
2665
2666 static const char *ConvertDiagnosticTypeToStr(DiagnosticType Val) {
2667 switch(Val) {
2668 case DiagnoseIfAttr::DT_Error: return "error";
2669 case DiagnoseIfAttr::DT_Warning: return "warning";
2670 }
2671 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 2671)
;
2672 }
2673 bool getArgDependent() const {
2674 return argDependent;
2675 }
2676
2677 NamedDecl * getParent() const {
2678 return parent;
2679 }
2680
2681
2682 bool isError() const { return diagnosticType == DT_Error; }
2683 bool isWarning() const { return diagnosticType == DT_Warning; }
2684
2685
2686 static bool classof(const Attr *A) { return A->getKind() == attr::DiagnoseIf; }
2687};
2688
2689class DisableTailCallsAttr : public InheritableAttr {
2690public:
2691 static DisableTailCallsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2692 auto *A = new (Ctx) DisableTailCallsAttr(Loc, Ctx, 0);
2693 A->setImplicit(true);
2694 return A;
2695 }
2696
2697 DisableTailCallsAttr(SourceRange R, ASTContext &Ctx
2698 , unsigned SI
2699 )
2700 : InheritableAttr(attr::DisableTailCalls, R, SI, false, false)
2701 {
2702 }
2703
2704 DisableTailCallsAttr *clone(ASTContext &C) const;
2705 void printPretty(raw_ostream &OS,
2706 const PrintingPolicy &Policy) const;
2707 const char *getSpelling() const;
2708
2709
2710 static bool classof(const Attr *A) { return A->getKind() == attr::DisableTailCalls; }
2711};
2712
2713class EmptyBasesAttr : public InheritableAttr {
2714public:
2715 static EmptyBasesAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2716 auto *A = new (Ctx) EmptyBasesAttr(Loc, Ctx, 0);
2717 A->setImplicit(true);
2718 return A;
2719 }
2720
2721 EmptyBasesAttr(SourceRange R, ASTContext &Ctx
2722 , unsigned SI
2723 )
2724 : InheritableAttr(attr::EmptyBases, R, SI, false, false)
2725 {
2726 }
2727
2728 EmptyBasesAttr *clone(ASTContext &C) const;
2729 void printPretty(raw_ostream &OS,
2730 const PrintingPolicy &Policy) const;
2731 const char *getSpelling() const;
2732
2733
2734 static bool classof(const Attr *A) { return A->getKind() == attr::EmptyBases; }
2735};
2736
2737class EnableIfAttr : public InheritableAttr {
2738Expr * cond;
2739
2740unsigned messageLength;
2741char *message;
2742
2743public:
2744 static EnableIfAttr *CreateImplicit(ASTContext &Ctx, Expr * Cond, llvm::StringRef Message, SourceRange Loc = SourceRange()) {
2745 auto *A = new (Ctx) EnableIfAttr(Loc, Ctx, Cond, Message, 0);
2746 A->setImplicit(true);
2747 return A;
2748 }
2749
2750 EnableIfAttr(SourceRange R, ASTContext &Ctx
2751 , Expr * Cond
2752 , llvm::StringRef Message
2753 , unsigned SI
2754 )
2755 : InheritableAttr(attr::EnableIf, R, SI, false, false)
2756 , cond(Cond)
2757 , messageLength(Message.size()),message(new (Ctx, 1) char[messageLength])
2758 {
2759 if (!Message.empty())
2760 std::memcpy(message, Message.data(), messageLength);
2761 }
2762
2763 EnableIfAttr *clone(ASTContext &C) const;
2764 void printPretty(raw_ostream &OS,
2765 const PrintingPolicy &Policy) const;
2766 const char *getSpelling() const;
2767 Expr * getCond() const {
2768 return cond;
2769 }
2770
2771 llvm::StringRef getMessage() const {
2772 return llvm::StringRef(message, messageLength);
2773 }
2774 unsigned getMessageLength() const {
2775 return messageLength;
2776 }
2777 void setMessage(ASTContext &C, llvm::StringRef S) {
2778 messageLength = S.size();
2779 this->message = new (C, 1) char [messageLength];
2780 if (!S.empty())
2781 std::memcpy(this->message, S.data(), messageLength);
2782 }
2783
2784
2785
2786 static bool classof(const Attr *A) { return A->getKind() == attr::EnableIf; }
2787};
2788
2789class EnumExtensibilityAttr : public InheritableAttr {
2790public:
2791 enum Kind {
2792 Closed,
2793 Open
2794 };
2795private:
2796 Kind extensibility;
2797
2798public:
2799 static EnumExtensibilityAttr *CreateImplicit(ASTContext &Ctx, Kind Extensibility, SourceRange Loc = SourceRange()) {
2800 auto *A = new (Ctx) EnumExtensibilityAttr(Loc, Ctx, Extensibility, 0);
2801 A->setImplicit(true);
2802 return A;
2803 }
2804
2805 EnumExtensibilityAttr(SourceRange R, ASTContext &Ctx
2806 , Kind Extensibility
2807 , unsigned SI
2808 )
2809 : InheritableAttr(attr::EnumExtensibility, R, SI, false, false)
2810 , extensibility(Extensibility)
2811 {
2812 }
2813
2814 EnumExtensibilityAttr *clone(ASTContext &C) const;
2815 void printPretty(raw_ostream &OS,
2816 const PrintingPolicy &Policy) const;
2817 const char *getSpelling() const;
2818 Kind getExtensibility() const {
2819 return extensibility;
2820 }
2821
2822 static bool ConvertStrToKind(StringRef Val, Kind &Out) {
2823 Optional<Kind> R = llvm::StringSwitch<Optional<Kind>>(Val)
2824 .Case("closed", EnumExtensibilityAttr::Closed)
2825 .Case("open", EnumExtensibilityAttr::Open)
2826 .Default(Optional<Kind>());
2827 if (R) {
2828 Out = *R;
2829 return true;
2830 }
2831 return false;
2832 }
2833
2834 static const char *ConvertKindToStr(Kind Val) {
2835 switch(Val) {
2836 case EnumExtensibilityAttr::Closed: return "closed";
2837 case EnumExtensibilityAttr::Open: return "open";
2838 }
2839 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 2839)
;
2840 }
2841
2842
2843 static bool classof(const Attr *A) { return A->getKind() == attr::EnumExtensibility; }
2844};
2845
2846class ExclusiveTrylockFunctionAttr : public InheritableAttr {
2847Expr * successValue;
2848
2849 unsigned args_Size;
2850 Expr * *args_;
2851
2852public:
2853 static ExclusiveTrylockFunctionAttr *CreateImplicit(ASTContext &Ctx, Expr * SuccessValue, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
2854 auto *A = new (Ctx) ExclusiveTrylockFunctionAttr(Loc, Ctx, SuccessValue, Args, ArgsSize, 0);
2855 A->setImplicit(true);
2856 return A;
2857 }
2858
2859 ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx
2860 , Expr * SuccessValue
2861 , Expr * *Args, unsigned ArgsSize
2862 , unsigned SI
2863 )
2864 : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true)
2865 , successValue(SuccessValue)
2866 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
2867 {
2868 std::copy(Args, Args + args_Size, args_);
2869 }
2870
2871 ExclusiveTrylockFunctionAttr(SourceRange R, ASTContext &Ctx
2872 , Expr * SuccessValue
2873 , unsigned SI
2874 )
2875 : InheritableAttr(attr::ExclusiveTrylockFunction, R, SI, true, true)
2876 , successValue(SuccessValue)
2877 , args_Size(0), args_(nullptr)
2878 {
2879 }
2880
2881 ExclusiveTrylockFunctionAttr *clone(ASTContext &C) const;
2882 void printPretty(raw_ostream &OS,
2883 const PrintingPolicy &Policy) const;
2884 const char *getSpelling() const;
2885 Expr * getSuccessValue() const {
2886 return successValue;
2887 }
2888
2889 typedef Expr ** args_iterator;
2890 args_iterator args_begin() const { return args_; }
2891 args_iterator args_end() const { return args_ + args_Size; }
2892 unsigned args_size() const { return args_Size; }
2893 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
2894
2895
2896
2897
2898 static bool classof(const Attr *A) { return A->getKind() == attr::ExclusiveTrylockFunction; }
2899};
2900
2901class ExternalSourceSymbolAttr : public InheritableAttr {
2902unsigned languageLength;
2903char *language;
2904
2905unsigned definedInLength;
2906char *definedIn;
2907
2908bool generatedDeclaration;
2909
2910public:
2911 static ExternalSourceSymbolAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Language, llvm::StringRef DefinedIn, bool GeneratedDeclaration, SourceRange Loc = SourceRange()) {
2912 auto *A = new (Ctx) ExternalSourceSymbolAttr(Loc, Ctx, Language, DefinedIn, GeneratedDeclaration, 0);
2913 A->setImplicit(true);
2914 return A;
2915 }
2916
2917 ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx
2918 , llvm::StringRef Language
2919 , llvm::StringRef DefinedIn
2920 , bool GeneratedDeclaration
2921 , unsigned SI
2922 )
2923 : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false)
2924 , languageLength(Language.size()),language(new (Ctx, 1) char[languageLength])
2925 , definedInLength(DefinedIn.size()),definedIn(new (Ctx, 1) char[definedInLength])
2926 , generatedDeclaration(GeneratedDeclaration)
2927 {
2928 if (!Language.empty())
2929 std::memcpy(language, Language.data(), languageLength);
2930 if (!DefinedIn.empty())
2931 std::memcpy(definedIn, DefinedIn.data(), definedInLength);
2932 }
2933
2934 ExternalSourceSymbolAttr(SourceRange R, ASTContext &Ctx
2935 , unsigned SI
2936 )
2937 : InheritableAttr(attr::ExternalSourceSymbol, R, SI, false, false)
2938 , languageLength(0),language(nullptr)
2939 , definedInLength(0),definedIn(nullptr)
2940 , generatedDeclaration()
2941 {
2942 }
2943
2944 ExternalSourceSymbolAttr *clone(ASTContext &C) const;
2945 void printPretty(raw_ostream &OS,
2946 const PrintingPolicy &Policy) const;
2947 const char *getSpelling() const;
2948 llvm::StringRef getLanguage() const {
2949 return llvm::StringRef(language, languageLength);
2950 }
2951 unsigned getLanguageLength() const {
2952 return languageLength;
2953 }
2954 void setLanguage(ASTContext &C, llvm::StringRef S) {
2955 languageLength = S.size();
2956 this->language = new (C, 1) char [languageLength];
2957 if (!S.empty())
2958 std::memcpy(this->language, S.data(), languageLength);
2959 }
2960
2961 llvm::StringRef getDefinedIn() const {
2962 return llvm::StringRef(definedIn, definedInLength);
2963 }
2964 unsigned getDefinedInLength() const {
2965 return definedInLength;
2966 }
2967 void setDefinedIn(ASTContext &C, llvm::StringRef S) {
2968 definedInLength = S.size();
2969 this->definedIn = new (C, 1) char [definedInLength];
2970 if (!S.empty())
2971 std::memcpy(this->definedIn, S.data(), definedInLength);
2972 }
2973
2974 bool getGeneratedDeclaration() const {
2975 return generatedDeclaration;
2976 }
2977
2978
2979
2980 static bool classof(const Attr *A) { return A->getKind() == attr::ExternalSourceSymbol; }
2981};
2982
2983class FallThroughAttr : public StmtAttr {
2984public:
2985 static FallThroughAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
2986 auto *A = new (Ctx) FallThroughAttr(Loc, Ctx, 0);
2987 A->setImplicit(true);
2988 return A;
2989 }
2990
2991 FallThroughAttr(SourceRange R, ASTContext &Ctx
2992 , unsigned SI
2993 )
2994 : StmtAttr(attr::FallThrough, R, SI, false)
2995 {
2996 }
2997
2998 FallThroughAttr *clone(ASTContext &C) const;
2999 void printPretty(raw_ostream &OS,
3000 const PrintingPolicy &Policy) const;
3001 const char *getSpelling() const;
3002
3003
3004 static bool classof(const Attr *A) { return A->getKind() == attr::FallThrough; }
3005};
3006
3007class FastCallAttr : public InheritableAttr {
3008public:
3009 static FastCallAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3010 auto *A = new (Ctx) FastCallAttr(Loc, Ctx, 0);
3011 A->setImplicit(true);
3012 return A;
3013 }
3014
3015 FastCallAttr(SourceRange R, ASTContext &Ctx
3016 , unsigned SI
3017 )
3018 : InheritableAttr(attr::FastCall, R, SI, false, false)
3019 {
3020 }
3021
3022 FastCallAttr *clone(ASTContext &C) const;
3023 void printPretty(raw_ostream &OS,
3024 const PrintingPolicy &Policy) const;
3025 const char *getSpelling() const;
3026
3027
3028 static bool classof(const Attr *A) { return A->getKind() == attr::FastCall; }
3029};
3030
3031class FinalAttr : public InheritableAttr {
3032public:
3033 enum Spelling {
3034 Keyword_final = 0,
3035 Keyword_sealed = 1
3036 };
3037
3038 static FinalAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
3039 auto *A = new (Ctx) FinalAttr(Loc, Ctx, S);
3040 A->setImplicit(true);
3041 return A;
3042 }
3043
3044 FinalAttr(SourceRange R, ASTContext &Ctx
3045 , unsigned SI
3046 )
3047 : InheritableAttr(attr::Final, R, SI, false, false)
3048 {
3049 }
3050
3051 FinalAttr *clone(ASTContext &C) const;
3052 void printPretty(raw_ostream &OS,
3053 const PrintingPolicy &Policy) const;
3054 const char *getSpelling() const;
3055 Spelling getSemanticSpelling() const {
3056 switch (SpellingListIndex) {
3057 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 3057)
;
3058 case 0: return Keyword_final;
3059 case 1: return Keyword_sealed;
3060 }
3061 }
3062 bool isSpelledAsSealed() const { return SpellingListIndex == 1; }
3063
3064
3065 static bool classof(const Attr *A) { return A->getKind() == attr::Final; }
3066};
3067
3068class FlagEnumAttr : public InheritableAttr {
3069public:
3070 static FlagEnumAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3071 auto *A = new (Ctx) FlagEnumAttr(Loc, Ctx, 0);
3072 A->setImplicit(true);
3073 return A;
3074 }
3075
3076 FlagEnumAttr(SourceRange R, ASTContext &Ctx
3077 , unsigned SI
3078 )
3079 : InheritableAttr(attr::FlagEnum, R, SI, false, false)
3080 {
3081 }
3082
3083 FlagEnumAttr *clone(ASTContext &C) const;
3084 void printPretty(raw_ostream &OS,
3085 const PrintingPolicy &Policy) const;
3086 const char *getSpelling() const;
3087
3088
3089 static bool classof(const Attr *A) { return A->getKind() == attr::FlagEnum; }
3090};
3091
3092class FlattenAttr : public InheritableAttr {
3093public:
3094 static FlattenAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3095 auto *A = new (Ctx) FlattenAttr(Loc, Ctx, 0);
3096 A->setImplicit(true);
3097 return A;
3098 }
3099
3100 FlattenAttr(SourceRange R, ASTContext &Ctx
3101 , unsigned SI
3102 )
3103 : InheritableAttr(attr::Flatten, R, SI, false, false)
3104 {
3105 }
3106
3107 FlattenAttr *clone(ASTContext &C) const;
3108 void printPretty(raw_ostream &OS,
3109 const PrintingPolicy &Policy) const;
3110 const char *getSpelling() const;
3111
3112
3113 static bool classof(const Attr *A) { return A->getKind() == attr::Flatten; }
3114};
3115
3116class FormatAttr : public InheritableAttr {
3117IdentifierInfo * type;
3118
3119int formatIdx;
3120
3121int firstArg;
3122
3123public:
3124 static FormatAttr *CreateImplicit(ASTContext &Ctx, IdentifierInfo * Type, int FormatIdx, int FirstArg, SourceRange Loc = SourceRange()) {
3125 auto *A = new (Ctx) FormatAttr(Loc, Ctx, Type, FormatIdx, FirstArg, 0);
3126 A->setImplicit(true);
3127 return A;
3128 }
3129
3130 FormatAttr(SourceRange R, ASTContext &Ctx
3131 , IdentifierInfo * Type
3132 , int FormatIdx
3133 , int FirstArg
3134 , unsigned SI
3135 )
3136 : InheritableAttr(attr::Format, R, SI, false, false)
3137 , type(Type)
3138 , formatIdx(FormatIdx)
3139 , firstArg(FirstArg)
3140 {
3141 }
3142
3143 FormatAttr *clone(ASTContext &C) const;
3144 void printPretty(raw_ostream &OS,
3145 const PrintingPolicy &Policy) const;
3146 const char *getSpelling() const;
3147 IdentifierInfo * getType() const {
3148 return type;
3149 }
3150
3151 int getFormatIdx() const {
3152 return formatIdx;
3153 }
3154
3155 int getFirstArg() const {
3156 return firstArg;
3157 }
3158
3159
3160
3161 static bool classof(const Attr *A) { return A->getKind() == attr::Format; }
3162};
3163
3164class FormatArgAttr : public InheritableAttr {
3165ParamIdx formatIdx;
3166
3167public:
3168 static FormatArgAttr *CreateImplicit(ASTContext &Ctx, ParamIdx FormatIdx, SourceRange Loc = SourceRange()) {
3169 auto *A = new (Ctx) FormatArgAttr(Loc, Ctx, FormatIdx, 0);
3170 A->setImplicit(true);
3171 return A;
3172 }
3173
3174 FormatArgAttr(SourceRange R, ASTContext &Ctx
3175 , ParamIdx FormatIdx
3176 , unsigned SI
3177 )
3178 : InheritableAttr(attr::FormatArg, R, SI, false, false)
3179 , formatIdx(FormatIdx)
3180 {
3181 }
3182
3183 FormatArgAttr *clone(ASTContext &C) const;
3184 void printPretty(raw_ostream &OS,
3185 const PrintingPolicy &Policy) const;
3186 const char *getSpelling() const;
3187 ParamIdx getFormatIdx() const {
3188 return formatIdx;
3189 }
3190
3191
3192
3193 static bool classof(const Attr *A) { return A->getKind() == attr::FormatArg; }
3194};
3195
3196class GNUInlineAttr : public InheritableAttr {
3197public:
3198 static GNUInlineAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3199 auto *A = new (Ctx) GNUInlineAttr(Loc, Ctx, 0);
3200 A->setImplicit(true);
3201 return A;
3202 }
3203
3204 GNUInlineAttr(SourceRange R, ASTContext &Ctx
3205 , unsigned SI
3206 )
3207 : InheritableAttr(attr::GNUInline, R, SI, false, false)
3208 {
3209 }
3210
3211 GNUInlineAttr *clone(ASTContext &C) const;
3212 void printPretty(raw_ostream &OS,
3213 const PrintingPolicy &Policy) const;
3214 const char *getSpelling() const;
3215
3216
3217 static bool classof(const Attr *A) { return A->getKind() == attr::GNUInline; }
3218};
3219
3220class GuardedByAttr : public InheritableAttr {
3221Expr * arg;
3222
3223public:
3224 static GuardedByAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) {
3225 auto *A = new (Ctx) GuardedByAttr(Loc, Ctx, Arg, 0);
3226 A->setImplicit(true);
3227 return A;
3228 }
3229
3230 GuardedByAttr(SourceRange R, ASTContext &Ctx
3231 , Expr * Arg
3232 , unsigned SI
3233 )
3234 : InheritableAttr(attr::GuardedBy, R, SI, true, true)
3235 , arg(Arg)
3236 {
3237 }
3238
3239 GuardedByAttr *clone(ASTContext &C) const;
3240 void printPretty(raw_ostream &OS,
3241 const PrintingPolicy &Policy) const;
3242 const char *getSpelling() const;
3243 Expr * getArg() const {
3244 return arg;
3245 }
3246
3247
3248
3249 static bool classof(const Attr *A) { return A->getKind() == attr::GuardedBy; }
3250};
3251
3252class GuardedVarAttr : public InheritableAttr {
3253public:
3254 static GuardedVarAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3255 auto *A = new (Ctx) GuardedVarAttr(Loc, Ctx, 0);
3256 A->setImplicit(true);
3257 return A;
3258 }
3259
3260 GuardedVarAttr(SourceRange R, ASTContext &Ctx
3261 , unsigned SI
3262 )
3263 : InheritableAttr(attr::GuardedVar, R, SI, false, false)
3264 {
3265 }
3266
3267 GuardedVarAttr *clone(ASTContext &C) const;
3268 void printPretty(raw_ostream &OS,
3269 const PrintingPolicy &Policy) const;
3270 const char *getSpelling() const;
3271
3272
3273 static bool classof(const Attr *A) { return A->getKind() == attr::GuardedVar; }
3274};
3275
3276class HotAttr : public InheritableAttr {
3277public:
3278 static HotAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3279 auto *A = new (Ctx) HotAttr(Loc, Ctx, 0);
3280 A->setImplicit(true);
3281 return A;
3282 }
3283
3284 HotAttr(SourceRange R, ASTContext &Ctx
3285 , unsigned SI
3286 )
3287 : InheritableAttr(attr::Hot, R, SI, false, false)
3288 {
3289 }
3290
3291 HotAttr *clone(ASTContext &C) const;
3292 void printPretty(raw_ostream &OS,
3293 const PrintingPolicy &Policy) const;
3294 const char *getSpelling() const;
3295
3296
3297 static bool classof(const Attr *A) { return A->getKind() == attr::Hot; }
3298};
3299
3300class IBActionAttr : public InheritableAttr {
3301public:
3302 static IBActionAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3303 auto *A = new (Ctx) IBActionAttr(Loc, Ctx, 0);
3304 A->setImplicit(true);
3305 return A;
3306 }
3307
3308 IBActionAttr(SourceRange R, ASTContext &Ctx
3309 , unsigned SI
3310 )
3311 : InheritableAttr(attr::IBAction, R, SI, false, false)
3312 {
3313 }
3314
3315 IBActionAttr *clone(ASTContext &C) const;
3316 void printPretty(raw_ostream &OS,
3317 const PrintingPolicy &Policy) const;
3318 const char *getSpelling() const;
3319
3320
3321 static bool classof(const Attr *A) { return A->getKind() == attr::IBAction; }
3322};
3323
3324class IBOutletAttr : public InheritableAttr {
3325public:
3326 static IBOutletAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3327 auto *A = new (Ctx) IBOutletAttr(Loc, Ctx, 0);
3328 A->setImplicit(true);
3329 return A;
3330 }
3331
3332 IBOutletAttr(SourceRange R, ASTContext &Ctx
3333 , unsigned SI
3334 )
3335 : InheritableAttr(attr::IBOutlet, R, SI, false, false)
3336 {
3337 }
3338
3339 IBOutletAttr *clone(ASTContext &C) const;
3340 void printPretty(raw_ostream &OS,
3341 const PrintingPolicy &Policy) const;
3342 const char *getSpelling() const;
3343
3344
3345 static bool classof(const Attr *A) { return A->getKind() == attr::IBOutlet; }
3346};
3347
3348class IBOutletCollectionAttr : public InheritableAttr {
3349TypeSourceInfo * interface_;
3350
3351public:
3352 static IBOutletCollectionAttr *CreateImplicit(ASTContext &Ctx, TypeSourceInfo * Interface, SourceRange Loc = SourceRange()) {
3353 auto *A = new (Ctx) IBOutletCollectionAttr(Loc, Ctx, Interface, 0);
3354 A->setImplicit(true);
3355 return A;
3356 }
3357
3358 IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx
3359 , TypeSourceInfo * Interface
3360 , unsigned SI
3361 )
3362 : InheritableAttr(attr::IBOutletCollection, R, SI, false, false)
3363 , interface_(Interface)
3364 {
3365 }
3366
3367 IBOutletCollectionAttr(SourceRange R, ASTContext &Ctx
3368 , unsigned SI
3369 )
3370 : InheritableAttr(attr::IBOutletCollection, R, SI, false, false)
3371 , interface_()
3372 {
3373 }
3374
3375 IBOutletCollectionAttr *clone(ASTContext &C) const;
3376 void printPretty(raw_ostream &OS,
3377 const PrintingPolicy &Policy) const;
3378 const char *getSpelling() const;
3379 QualType getInterface() const {
3380 return interface_->getType();
3381 } TypeSourceInfo * getInterfaceLoc() const {
3382 return interface_;
3383 }
3384
3385
3386
3387 static bool classof(const Attr *A) { return A->getKind() == attr::IBOutletCollection; }
3388};
3389
3390class IFuncAttr : public Attr {
3391unsigned resolverLength;
3392char *resolver;
3393
3394public:
3395 static IFuncAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Resolver, SourceRange Loc = SourceRange()) {
3396 auto *A = new (Ctx) IFuncAttr(Loc, Ctx, Resolver, 0);
3397 A->setImplicit(true);
3398 return A;
3399 }
3400
3401 IFuncAttr(SourceRange R, ASTContext &Ctx
3402 , llvm::StringRef Resolver
3403 , unsigned SI
3404 )
3405 : Attr(attr::IFunc, R, SI, false)
3406 , resolverLength(Resolver.size()),resolver(new (Ctx, 1) char[resolverLength])
3407 {
3408 if (!Resolver.empty())
3409 std::memcpy(resolver, Resolver.data(), resolverLength);
3410 }
3411
3412 IFuncAttr *clone(ASTContext &C) const;
3413 void printPretty(raw_ostream &OS,
3414 const PrintingPolicy &Policy) const;
3415 const char *getSpelling() const;
3416 llvm::StringRef getResolver() const {
3417 return llvm::StringRef(resolver, resolverLength);
3418 }
3419 unsigned getResolverLength() const {
3420 return resolverLength;
3421 }
3422 void setResolver(ASTContext &C, llvm::StringRef S) {
3423 resolverLength = S.size();
3424 this->resolver = new (C, 1) char [resolverLength];
3425 if (!S.empty())
3426 std::memcpy(this->resolver, S.data(), resolverLength);
3427 }
3428
3429
3430
3431 static bool classof(const Attr *A) { return A->getKind() == attr::IFunc; }
3432};
3433
3434class InitPriorityAttr : public InheritableAttr {
3435unsigned priority;
3436
3437public:
3438 static InitPriorityAttr *CreateImplicit(ASTContext &Ctx, unsigned Priority, SourceRange Loc = SourceRange()) {
3439 auto *A = new (Ctx) InitPriorityAttr(Loc, Ctx, Priority, 0);
3440 A->setImplicit(true);
3441 return A;
3442 }
3443
3444 InitPriorityAttr(SourceRange R, ASTContext &Ctx
3445 , unsigned Priority
3446 , unsigned SI
3447 )
3448 : InheritableAttr(attr::InitPriority, R, SI, false, false)
3449 , priority(Priority)
3450 {
3451 }
3452
3453 InitPriorityAttr *clone(ASTContext &C) const;
3454 void printPretty(raw_ostream &OS,
3455 const PrintingPolicy &Policy) const;
3456 const char *getSpelling() const;
3457 unsigned getPriority() const {
3458 return priority;
3459 }
3460
3461
3462
3463 static bool classof(const Attr *A) { return A->getKind() == attr::InitPriority; }
3464};
3465
3466class InitSegAttr : public Attr {
3467unsigned sectionLength;
3468char *section;
3469
3470public:
3471 static InitSegAttr *CreateImplicit(ASTContext &Ctx, llvm::StringRef Section, SourceRange Loc = SourceRange()) {
3472 auto *A = new (Ctx) InitSegAttr(Loc, Ctx, Section, 0);
3473 A->setImplicit(true);
3474 return A;
3475 }
3476
3477 InitSegAttr(SourceRange R, ASTContext &Ctx
3478 , llvm::StringRef Section
3479 , unsigned SI
3480 )
3481 : Attr(attr::InitSeg, R, SI, false)
3482 , sectionLength(Section.size()),section(new (Ctx, 1) char[sectionLength])
3483 {
3484 if (!Section.empty())
3485 std::memcpy(section, Section.data(), sectionLength);
3486 }
3487
3488 InitSegAttr *clone(ASTContext &C) const;
3489 void printPretty(raw_ostream &OS,
3490 const PrintingPolicy &Policy) const;
3491 const char *getSpelling() const;
3492 llvm::StringRef getSection() const {
3493 return llvm::StringRef(section, sectionLength);
3494 }
3495 unsigned getSectionLength() const {
3496 return sectionLength;
3497 }
3498 void setSection(ASTContext &C, llvm::StringRef S) {
3499 sectionLength = S.size();
3500 this->section = new (C, 1) char [sectionLength];
3501 if (!S.empty())
3502 std::memcpy(this->section, S.data(), sectionLength);
3503 }
3504
3505
3506 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3507 OS << " (" << getSection() << ')';
3508 }
3509
3510
3511 static bool classof(const Attr *A) { return A->getKind() == attr::InitSeg; }
3512};
3513
3514class IntelOclBiccAttr : public InheritableAttr {
3515public:
3516 static IntelOclBiccAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3517 auto *A = new (Ctx) IntelOclBiccAttr(Loc, Ctx, 0);
3518 A->setImplicit(true);
3519 return A;
3520 }
3521
3522 IntelOclBiccAttr(SourceRange R, ASTContext &Ctx
3523 , unsigned SI
3524 )
3525 : InheritableAttr(attr::IntelOclBicc, R, SI, false, false)
3526 {
3527 }
3528
3529 IntelOclBiccAttr *clone(ASTContext &C) const;
3530 void printPretty(raw_ostream &OS,
3531 const PrintingPolicy &Policy) const;
3532 const char *getSpelling() const;
3533
3534
3535 static bool classof(const Attr *A) { return A->getKind() == attr::IntelOclBicc; }
3536};
3537
3538class InternalLinkageAttr : public InheritableAttr {
3539public:
3540 static InternalLinkageAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3541 auto *A = new (Ctx) InternalLinkageAttr(Loc, Ctx, 0);
3542 A->setImplicit(true);
3543 return A;
3544 }
3545
3546 InternalLinkageAttr(SourceRange R, ASTContext &Ctx
3547 , unsigned SI
3548 )
3549 : InheritableAttr(attr::InternalLinkage, R, SI, false, false)
3550 {
3551 }
3552
3553 InternalLinkageAttr *clone(ASTContext &C) const;
3554 void printPretty(raw_ostream &OS,
3555 const PrintingPolicy &Policy) const;
3556 const char *getSpelling() const;
3557
3558
3559 static bool classof(const Attr *A) { return A->getKind() == attr::InternalLinkage; }
3560};
3561
3562class LTOVisibilityPublicAttr : public InheritableAttr {
3563public:
3564 static LTOVisibilityPublicAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3565 auto *A = new (Ctx) LTOVisibilityPublicAttr(Loc, Ctx, 0);
3566 A->setImplicit(true);
3567 return A;
3568 }
3569
3570 LTOVisibilityPublicAttr(SourceRange R, ASTContext &Ctx
3571 , unsigned SI
3572 )
3573 : InheritableAttr(attr::LTOVisibilityPublic, R, SI, false, false)
3574 {
3575 }
3576
3577 LTOVisibilityPublicAttr *clone(ASTContext &C) const;
3578 void printPretty(raw_ostream &OS,
3579 const PrintingPolicy &Policy) const;
3580 const char *getSpelling() const;
3581
3582
3583 static bool classof(const Attr *A) { return A->getKind() == attr::LTOVisibilityPublic; }
3584};
3585
3586class LayoutVersionAttr : public InheritableAttr {
3587unsigned version;
3588
3589public:
3590 static LayoutVersionAttr *CreateImplicit(ASTContext &Ctx, unsigned Version, SourceRange Loc = SourceRange()) {
3591 auto *A = new (Ctx) LayoutVersionAttr(Loc, Ctx, Version, 0);
3592 A->setImplicit(true);
3593 return A;
3594 }
3595
3596 LayoutVersionAttr(SourceRange R, ASTContext &Ctx
3597 , unsigned Version
3598 , unsigned SI
3599 )
3600 : InheritableAttr(attr::LayoutVersion, R, SI, false, false)
3601 , version(Version)
3602 {
3603 }
3604
3605 LayoutVersionAttr *clone(ASTContext &C) const;
3606 void printPretty(raw_ostream &OS,
3607 const PrintingPolicy &Policy) const;
3608 const char *getSpelling() const;
3609 unsigned getVersion() const {
3610 return version;
3611 }
3612
3613
3614
3615 static bool classof(const Attr *A) { return A->getKind() == attr::LayoutVersion; }
3616};
3617
3618class LockReturnedAttr : public InheritableAttr {
3619Expr * arg;
3620
3621public:
3622 static LockReturnedAttr *CreateImplicit(ASTContext &Ctx, Expr * Arg, SourceRange Loc = SourceRange()) {
3623 auto *A = new (Ctx) LockReturnedAttr(Loc, Ctx, Arg, 0);
3624 A->setImplicit(true);
3625 return A;
3626 }
3627
3628 LockReturnedAttr(SourceRange R, ASTContext &Ctx
3629 , Expr * Arg
3630 , unsigned SI
3631 )
3632 : InheritableAttr(attr::LockReturned, R, SI, true, false)
3633 , arg(Arg)
3634 {
3635 }
3636
3637 LockReturnedAttr *clone(ASTContext &C) const;
3638 void printPretty(raw_ostream &OS,
3639 const PrintingPolicy &Policy) const;
3640 const char *getSpelling() const;
3641 Expr * getArg() const {
3642 return arg;
3643 }
3644
3645
3646
3647 static bool classof(const Attr *A) { return A->getKind() == attr::LockReturned; }
3648};
3649
3650class LocksExcludedAttr : public InheritableAttr {
3651 unsigned args_Size;
3652 Expr * *args_;
3653
3654public:
3655 static LocksExcludedAttr *CreateImplicit(ASTContext &Ctx, Expr * *Args, unsigned ArgsSize, SourceRange Loc = SourceRange()) {
3656 auto *A = new (Ctx) LocksExcludedAttr(Loc, Ctx, Args, ArgsSize, 0);
3657 A->setImplicit(true);
3658 return A;
3659 }
3660
3661 LocksExcludedAttr(SourceRange R, ASTContext &Ctx
3662 , Expr * *Args, unsigned ArgsSize
3663 , unsigned SI
3664 )
3665 : InheritableAttr(attr::LocksExcluded, R, SI, true, true)
3666 , args_Size(ArgsSize), args_(new (Ctx, 16) Expr *[args_Size])
3667 {
3668 std::copy(Args, Args + args_Size, args_);
3669 }
3670
3671 LocksExcludedAttr(SourceRange R, ASTContext &Ctx
3672 , unsigned SI
3673 )
3674 : InheritableAttr(attr::LocksExcluded, R, SI, true, true)
3675 , args_Size(0), args_(nullptr)
3676 {
3677 }
3678
3679 LocksExcludedAttr *clone(ASTContext &C) const;
3680 void printPretty(raw_ostream &OS,
3681 const PrintingPolicy &Policy) const;
3682 const char *getSpelling() const;
3683 typedef Expr ** args_iterator;
3684 args_iterator args_begin() const { return args_; }
3685 args_iterator args_end() const { return args_ + args_Size; }
3686 unsigned args_size() const { return args_Size; }
3687 llvm::iterator_range<args_iterator> args() const { return llvm::make_range(args_begin(), args_end()); }
3688
3689
3690
3691
3692 static bool classof(const Attr *A) { return A->getKind() == attr::LocksExcluded; }
3693};
3694
3695class LoopHintAttr : public Attr {
3696public:
3697 enum OptionType {
3698 Vectorize,
3699 VectorizeWidth,
3700 Interleave,
3701 InterleaveCount,
3702 Unroll,
3703 UnrollCount,
3704 Distribute
3705 };
3706private:
3707 OptionType option;
3708
3709public:
3710 enum LoopHintState {
3711 Enable,
3712 Disable,
3713 Numeric,
3714 AssumeSafety,
3715 Full
3716 };
3717private:
3718 LoopHintState state;
3719
3720Expr * value;
3721
3722public:
3723 enum Spelling {
3724 Pragma_clang_loop = 0,
3725 Pragma_unroll = 1,
3726 Pragma_nounroll = 2
3727 };
3728
3729 static LoopHintAttr *CreateImplicit(ASTContext &Ctx, Spelling S, OptionType Option, LoopHintState State, Expr * Value, SourceRange Loc = SourceRange()) {
3730 auto *A = new (Ctx) LoopHintAttr(Loc, Ctx, Option, State, Value, S);
3731 A->setImplicit(true);
3732 return A;
3733 }
3734
3735 LoopHintAttr(SourceRange R, ASTContext &Ctx
3736 , OptionType Option
3737 , LoopHintState State
3738 , Expr * Value
3739 , unsigned SI
3740 )
3741 : Attr(attr::LoopHint, R, SI, false)
3742 , option(Option)
3743 , state(State)
3744 , value(Value)
3745 {
3746 }
3747
3748 LoopHintAttr *clone(ASTContext &C) const;
3749 void printPretty(raw_ostream &OS,
3750 const PrintingPolicy &Policy) const;
3751 const char *getSpelling() const;
3752 Spelling getSemanticSpelling() const {
3753 switch (SpellingListIndex) {
3754 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 3754)
;
3755 case 0: return Pragma_clang_loop;
3756 case 1: return Pragma_unroll;
3757 case 2: return Pragma_nounroll;
3758 }
3759 }
3760 OptionType getOption() const {
3761 return option;
3762 }
3763
3764 static bool ConvertStrToOptionType(StringRef Val, OptionType &Out) {
3765 Optional<OptionType> R = llvm::StringSwitch<Optional<OptionType>>(Val)
3766 .Case("vectorize", LoopHintAttr::Vectorize)
3767 .Case("vectorize_width", LoopHintAttr::VectorizeWidth)
3768 .Case("interleave", LoopHintAttr::Interleave)
3769 .Case("interleave_count", LoopHintAttr::InterleaveCount)
3770 .Case("unroll", LoopHintAttr::Unroll)
3771 .Case("unroll_count", LoopHintAttr::UnrollCount)
3772 .Case("distribute", LoopHintAttr::Distribute)
3773 .Default(Optional<OptionType>());
3774 if (R) {
3775 Out = *R;
3776 return true;
3777 }
3778 return false;
3779 }
3780
3781 static const char *ConvertOptionTypeToStr(OptionType Val) {
3782 switch(Val) {
3783 case LoopHintAttr::Vectorize: return "vectorize";
3784 case LoopHintAttr::VectorizeWidth: return "vectorize_width";
3785 case LoopHintAttr::Interleave: return "interleave";
3786 case LoopHintAttr::InterleaveCount: return "interleave_count";
3787 case LoopHintAttr::Unroll: return "unroll";
3788 case LoopHintAttr::UnrollCount: return "unroll_count";
3789 case LoopHintAttr::Distribute: return "distribute";
3790 }
3791 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 3791)
;
3792 }
3793 LoopHintState getState() const {
3794 return state;
3795 }
3796
3797 static bool ConvertStrToLoopHintState(StringRef Val, LoopHintState &Out) {
3798 Optional<LoopHintState> R = llvm::StringSwitch<Optional<LoopHintState>>(Val)
3799 .Case("enable", LoopHintAttr::Enable)
3800 .Case("disable", LoopHintAttr::Disable)
3801 .Case("numeric", LoopHintAttr::Numeric)
3802 .Case("assume_safety", LoopHintAttr::AssumeSafety)
3803 .Case("full", LoopHintAttr::Full)
3804 .Default(Optional<LoopHintState>());
3805 if (R) {
3806 Out = *R;
3807 return true;
3808 }
3809 return false;
3810 }
3811
3812 static const char *ConvertLoopHintStateToStr(LoopHintState Val) {
3813 switch(Val) {
3814 case LoopHintAttr::Enable: return "enable";
3815 case LoopHintAttr::Disable: return "disable";
3816 case LoopHintAttr::Numeric: return "numeric";
3817 case LoopHintAttr::AssumeSafety: return "assume_safety";
3818 case LoopHintAttr::Full: return "full";
3819 }
3820 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 3820)
;
3821 }
3822 Expr * getValue() const {
3823 return value;
3824 }
3825
3826
3827 static const char *getOptionName(int Option) {
3828 switch(Option) {
3829 case Vectorize: return "vectorize";
3830 case VectorizeWidth: return "vectorize_width";
3831 case Interleave: return "interleave";
3832 case InterleaveCount: return "interleave_count";
3833 case Unroll: return "unroll";
3834 case UnrollCount: return "unroll_count";
3835 case Distribute: return "distribute";
3836 }
3837 llvm_unreachable("Unhandled LoopHint option.")::llvm::llvm_unreachable_internal("Unhandled LoopHint option."
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 3837)
;
3838 }
3839
3840 void printPrettyPragma(raw_ostream &OS, const PrintingPolicy &Policy) const {
3841 unsigned SpellingIndex = getSpellingListIndex();
3842 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
3843 // "nounroll" is already emitted as the pragma name.
3844 if (SpellingIndex == Pragma_nounroll)
3845 return;
3846 else if (SpellingIndex == Pragma_unroll) {
3847 OS << ' ' << getValueString(Policy);
3848 return;
3849 }
3850
3851 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling")(static_cast <bool> (SpellingIndex == Pragma_clang_loop
&& "Unexpected spelling") ? void (0) : __assert_fail
("SpellingIndex == Pragma_clang_loop && \"Unexpected spelling\""
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 3851, __extension__ __PRETTY_FUNCTION__))
;
3852 OS << ' ' << getOptionName(option) << getValueString(Policy);
3853 }
3854
3855 // Return a string containing the loop hint argument including the
3856 // enclosing parentheses.
3857 std::string getValueString(const PrintingPolicy &Policy) const {
3858 std::string ValueName;
3859 llvm::raw_string_ostream OS(ValueName);
3860 OS << "(";
3861 if (state == Numeric)
3862 value->printPretty(OS, nullptr, Policy);
3863 else if (state == Enable)
3864 OS << "enable";
3865 else if (state == Full)
3866 OS << "full";
3867 else if (state == AssumeSafety)
3868 OS << "assume_safety";
3869 else
3870 OS << "disable";
3871 OS << ")";
3872 return OS.str();
3873 }
3874
3875 // Return a string suitable for identifying this attribute in diagnostics.
3876 std::string getDiagnosticName(const PrintingPolicy &Policy) const {
3877 unsigned SpellingIndex = getSpellingListIndex();
3878 if (SpellingIndex == Pragma_nounroll)
3879 return "#pragma nounroll";
3880 else if (SpellingIndex == Pragma_unroll)
3881 return "#pragma unroll" + (option == UnrollCount ? getValueString(Policy) : "");
3882
3883 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling")(static_cast <bool> (SpellingIndex == Pragma_clang_loop
&& "Unexpected spelling") ? void (0) : __assert_fail
("SpellingIndex == Pragma_clang_loop && \"Unexpected spelling\""
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 3883, __extension__ __PRETTY_FUNCTION__))
;
3884 return getOptionName(option) + getValueString(Policy);
3885 }
3886
3887
3888 static bool classof(const Attr *A) { return A->getKind() == attr::LoopHint; }
3889};
3890
3891class MSABIAttr : public InheritableAttr {
3892public:
3893 static MSABIAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3894 auto *A = new (Ctx) MSABIAttr(Loc, Ctx, 0);
3895 A->setImplicit(true);
3896 return A;
3897 }
3898
3899 MSABIAttr(SourceRange R, ASTContext &Ctx
3900 , unsigned SI
3901 )
3902 : InheritableAttr(attr::MSABI, R, SI, false, false)
3903 {
3904 }
3905
3906 MSABIAttr *clone(ASTContext &C) const;
3907 void printPretty(raw_ostream &OS,
3908 const PrintingPolicy &Policy) const;
3909 const char *getSpelling() const;
3910
3911
3912 static bool classof(const Attr *A) { return A->getKind() == attr::MSABI; }
3913};
3914
3915class MSInheritanceAttr : public InheritableAttr {
3916bool bestCase;
3917
3918public:
3919 enum Spelling {
3920 Keyword_single_inheritance = 0,
3921 Keyword_multiple_inheritance = 1,
3922 Keyword_virtual_inheritance = 2,
3923 Keyword_unspecified_inheritance = 3
3924 };
3925
3926 static MSInheritanceAttr *CreateImplicit(ASTContext &Ctx, Spelling S, bool BestCase, SourceRange Loc = SourceRange()) {
3927 auto *A = new (Ctx) MSInheritanceAttr(Loc, Ctx, BestCase, S);
3928 A->setImplicit(true);
3929 return A;
3930 }
3931
3932 MSInheritanceAttr(SourceRange R, ASTContext &Ctx
3933 , bool BestCase
3934 , unsigned SI
3935 )
3936 : InheritableAttr(attr::MSInheritance, R, SI, false, false)
3937 , bestCase(BestCase)
3938 {
3939 }
3940
3941 MSInheritanceAttr(SourceRange R, ASTContext &Ctx
3942 , unsigned SI
3943 )
3944 : InheritableAttr(attr::MSInheritance, R, SI, false, false)
3945 , bestCase()
3946 {
3947 }
3948
3949 MSInheritanceAttr *clone(ASTContext &C) const;
3950 void printPretty(raw_ostream &OS,
3951 const PrintingPolicy &Policy) const;
3952 const char *getSpelling() const;
3953 Spelling getSemanticSpelling() const {
3954 switch (SpellingListIndex) {
3955 default: llvm_unreachable("Unknown spelling list index")::llvm::llvm_unreachable_internal("Unknown spelling list index"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 3955)
;
3956 case 0: return Keyword_single_inheritance;
3957 case 1: return Keyword_multiple_inheritance;
3958 case 2: return Keyword_virtual_inheritance;
3959 case 3: return Keyword_unspecified_inheritance;
3960 }
3961 }
3962 bool getBestCase() const {
3963 return bestCase;
3964 }
3965
3966 static const bool DefaultBestCase = true;
3967
3968
3969 static bool hasVBPtrOffsetField(Spelling Inheritance) {
3970 return Inheritance == Keyword_unspecified_inheritance;
3971 }
3972
3973 // Only member pointers to functions need a this adjustment, since it can be
3974 // combined with the field offset for data pointers.
3975 static bool hasNVOffsetField(bool IsMemberFunction, Spelling Inheritance) {
3976 return IsMemberFunction && Inheritance >= Keyword_multiple_inheritance;
3977 }
3978
3979 static bool hasVBTableOffsetField(Spelling Inheritance) {
3980 return Inheritance >= Keyword_virtual_inheritance;
3981 }
3982
3983 static bool hasOnlyOneField(bool IsMemberFunction,
3984 Spelling Inheritance) {
3985 if (IsMemberFunction)
3986 return Inheritance <= Keyword_single_inheritance;
3987 return Inheritance <= Keyword_multiple_inheritance;
3988 }
3989
3990
3991 static bool classof(const Attr *A) { return A->getKind() == attr::MSInheritance; }
3992};
3993
3994class MSNoVTableAttr : public InheritableAttr {
3995public:
3996 static MSNoVTableAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
3997 auto *A = new (Ctx) MSNoVTableAttr(Loc, Ctx, 0);
3998 A->setImplicit(true);
3999 return A;
4000 }
4001
4002 MSNoVTableAttr(SourceRange R, ASTContext &Ctx
4003 , unsigned SI
4004 )
4005 : InheritableAttr(attr::MSNoVTable, R, SI, false, false)
4006 {
4007 }
4008
4009 MSNoVTableAttr *clone(ASTContext &C) const;
4010 void printPretty(raw_ostream &OS,
4011 const PrintingPolicy &Policy) const;
4012 const char *getSpelling() const;
4013
4014
4015 static bool classof(const Attr *A) { return A->getKind() == attr::MSNoVTable; }
4016};
4017
4018class MSP430InterruptAttr : public InheritableAttr {
4019unsigned number;
4020
4021public:
4022 static MSP430InterruptAttr *CreateImplicit(ASTContext &Ctx, unsigned Number, SourceRange Loc = SourceRange()) {
4023 auto *A = new (Ctx) MSP430InterruptAttr(Loc, Ctx, Number, 0);
4024 A->setImplicit(true);
4025 return A;
4026 }
4027
4028 MSP430InterruptAttr(SourceRange R, ASTContext &Ctx
4029 , unsigned Number
4030 , unsigned SI
4031 )
4032 : InheritableAttr(attr::MSP430Interrupt, R, SI, false, false)
4033 , number(Number)
4034 {
4035 }
4036
4037 MSP430InterruptAttr *clone(ASTContext &C) const;
4038 void printPretty(raw_ostream &OS,
4039 const PrintingPolicy &Policy) const;
4040 const char *getSpelling() const;
4041 unsigned getNumber() const {
4042 return number;
4043 }
4044
4045
4046
4047 static bool classof(const Attr *A) { return A->getKind() == attr::MSP430Interrupt; }
4048};
4049
4050class MSStructAttr : public InheritableAttr {
4051public:
4052 static MSStructAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4053 auto *A = new (Ctx) MSStructAttr(Loc, Ctx, 0);
4054 A->setImplicit(true);
4055 return A;
4056 }
4057
4058 MSStructAttr(SourceRange R, ASTContext &Ctx
4059 , unsigned SI
4060 )
4061 : InheritableAttr(attr::MSStruct, R, SI, false, false)
4062 {
4063 }
4064
4065 MSStructAttr *clone(ASTContext &C) const;
4066 void printPretty(raw_ostream &OS,
4067 const PrintingPolicy &Policy) const;
4068 const char *getSpelling() const;
4069
4070
4071 static bool classof(const Attr *A) { return A->getKind() == attr::MSStruct; }
4072};
4073
4074class MSVtorDispAttr : public InheritableAttr {
4075unsigned vdm;
4076
4077public:
4078 static MSVtorDispAttr *CreateImplicit(ASTContext &Ctx, unsigned Vdm, SourceRange Loc = SourceRange()) {
4079 auto *A = new (Ctx) MSVtorDispAttr(Loc, Ctx, Vdm, 0);
4080 A->setImplicit(true);
4081 return A;
4082 }
4083
4084 MSVtorDispAttr(SourceRange R, ASTContext &Ctx
4085 , unsigned Vdm
4086 , unsigned SI
4087 )
4088 : InheritableAttr(attr::MSVtorDisp, R, SI, false, false)
4089 , vdm(Vdm)
4090 {
4091 }
4092
4093 MSVtorDispAttr *clone(ASTContext &C) const;
4094 void printPretty(raw_ostream &OS,
4095 const PrintingPolicy &Policy) const;
4096 const char *getSpelling() const;
4097 unsigned getVdm() const {
4098 return vdm;
4099 }
4100
4101
4102 enum Mode {
4103 Never,
4104 ForVBaseOverride,
4105 ForVFTable
4106 };
4107
4108 Mode getVtorDispMode() const { return Mode(vdm); }
4109
4110
4111 static bool classof(const Attr *A) { return A->getKind() == attr::MSVtorDisp; }
4112};
4113
4114class MaxFieldAlignmentAttr : public InheritableAttr {
4115unsigned alignment;
4116
4117public:
4118 static MaxFieldAlignmentAttr *CreateImplicit(ASTContext &Ctx, unsigned Alignment, SourceRange Loc = SourceRange()) {
4119 auto *A = new (Ctx) MaxFieldAlignmentAttr(Loc, Ctx, Alignment, 0);
4120 A->setImplicit(true);
4121 return A;
4122 }
4123
4124 MaxFieldAlignmentAttr(SourceRange R, ASTContext &Ctx
4125 , unsigned Alignment
4126 , unsigned SI
4127 )
4128 : InheritableAttr(attr::MaxFieldAlignment, R, SI, false, false)
4129 , alignment(Alignment)
4130 {
4131 }
4132
4133 MaxFieldAlignmentAttr *clone(ASTContext &C) const;
4134 void printPretty(raw_ostream &OS,
4135 const PrintingPolicy &Policy) const;
4136 const char *getSpelling() const;
4137 unsigned getAlignment() const {
4138 return alignment;
4139 }
4140
4141
4142
4143 static bool classof(const Attr *A) { return A->getKind() == attr::MaxFieldAlignment; }
4144};
4145
4146class MayAliasAttr : public InheritableAttr {
4147public:
4148 static MayAliasAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4149 auto *A = new (Ctx) MayAliasAttr(Loc, Ctx, 0);
4150 A->setImplicit(true);
4151 return A;
4152 }
4153
4154 MayAliasAttr(SourceRange R, ASTContext &Ctx
4155 , unsigned SI
4156 )
4157 : InheritableAttr(attr::MayAlias, R, SI, false, false)
4158 {
4159 }
4160
4161 MayAliasAttr *clone(ASTContext &C) const;
4162 void printPretty(raw_ostream &OS,
4163 const PrintingPolicy &Policy) const;
4164 const char *getSpelling() const;
4165
4166
4167 static bool classof(const Attr *A) { return A->getKind() == attr::MayAlias; }
4168};
4169
4170class MicroMipsAttr : public InheritableAttr {
4171public:
4172 static MicroMipsAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4173 auto *A = new (Ctx) MicroMipsAttr(Loc, Ctx, 0);
4174 A->setImplicit(true);
4175 return A;
4176 }
4177
4178 MicroMipsAttr(SourceRange R, ASTContext &Ctx
4179 , unsigned SI
4180 )
4181 : InheritableAttr(attr::MicroMips, R, SI, false, false)
4182 {
4183 }
4184
4185 MicroMipsAttr *clone(ASTContext &C) const;
4186 void printPretty(raw_ostream &OS,
4187 const PrintingPolicy &Policy) const;
4188 const char *getSpelling() const;
4189
4190
4191 static bool classof(const Attr *A) { return A->getKind() == attr::MicroMips; }
4192};
4193
4194class MinSizeAttr : public InheritableAttr {
4195public:
4196 static MinSizeAttr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4197 auto *A = new (Ctx) MinSizeAttr(Loc, Ctx, 0);
4198 A->setImplicit(true);
4199 return A;
4200 }
4201
4202 MinSizeAttr(SourceRange R, ASTContext &Ctx
4203 , unsigned SI
4204 )
4205 : InheritableAttr(attr::MinSize, R, SI, false, false)
4206 {
4207 }
4208
4209 MinSizeAttr *clone(ASTContext &C) const;
4210 void printPretty(raw_ostream &OS,
4211 const PrintingPolicy &Policy) const;
4212 const char *getSpelling() const;
4213
4214
4215 static bool classof(const Attr *A) { return A->getKind() == attr::MinSize; }
4216};
4217
4218class Mips16Attr : public InheritableAttr {
4219public:
4220 static Mips16Attr *CreateImplicit(ASTContext &Ctx, SourceRange Loc = SourceRange()) {
4221 auto *A = new (Ctx) Mips16Attr(Loc, Ctx, 0);
4222 A->setImplicit(true);
4223 return A;
4224 }
4225
4226 Mips16Attr(SourceRange R, ASTContext &Ctx
4227 , unsigned SI
4228 )
4229 : InheritableAttr(attr::Mips16, R, SI, false, false)
4230 {
4231 }
4232
4233 Mips16Attr *clone(ASTContext &C) const;
4234 void printPretty(raw_ostream &OS,
4235 const PrintingPolicy &Policy) const;
4236 const char *getSpelling() const;
4237
4238
4239 static bool classof(const Attr *A) { return A->getKind() == attr::Mips16; }
4240};
4241
4242class MipsInterruptAttr : public InheritableAttr {
4243public:
4244 enum InterruptType {
4245 sw0,
4246 sw1,
4247 hw0,
4248 hw1,
4249 hw2,
4250 hw3,
4251 hw4,
4252 hw5,
4253 eic
4254 };
4255private:
4256 InterruptType interrupt;
4257
4258public:
4259 static MipsInterruptAttr *CreateImplicit(ASTContext &Ctx, InterruptType Interrupt, SourceRange Loc = SourceRange()) {
4260 auto *A = new (Ctx) MipsInterruptAttr(Loc, Ctx, Interrupt, 0);
4261 A->setImplicit(true);
4262 return A;
4263 }
4264
4265 MipsInterruptAttr(SourceRange R, ASTContext &Ctx
4266 , InterruptType Interrupt
4267 , unsigned SI
4268 )
4269 : InheritableAttr(attr::MipsInterrupt, R, SI, false, false)
4270 , interrupt(Interrupt)
4271 {
4272 }
4273
4274 MipsInterruptAttr *clone(ASTContext &C) const;
4275 void printPretty(raw_ostream &OS,
4276 const PrintingPolicy &Policy) const;
4277 const char *getSpelling() const;
4278 InterruptType getInterrupt() const {
4279 return interrupt;
4280 }
4281
4282 static bool ConvertStrToInterruptType(StringRef Val, InterruptType &Out) {
4283 Optional<InterruptType> R = llvm::StringSwitch<Optional<InterruptType>>(Val)
4284 .Case("vector=sw0", MipsInterruptAttr::sw0)
4285 .Case("vector=sw1", MipsInterruptAttr::sw1)
4286 .Case("vector=hw0", MipsInterruptAttr::hw0)
4287 .Case("vector=hw1", MipsInterruptAttr::hw1)
4288 .Case("vector=hw2", MipsInterruptAttr::hw2)
4289 .Case("vector=hw3", MipsInterruptAttr::hw3)
4290 .Case("vector=hw4", MipsInterruptAttr::hw4)
4291 .Case("vector=hw5", MipsInterruptAttr::hw5)
4292 .Case("eic", MipsInterruptAttr::eic)
4293 .Case("", MipsInterruptAttr::eic)
4294 .Default(Optional<InterruptType>());
4295 if (R) {
4296 Out = *R;
4297 return true;
4298 }
4299 return false;
4300 }
4301
4302 static const char *ConvertInterruptTypeToStr(InterruptType Val) {
4303 switch(Val) {
4304 case MipsInterruptAttr::sw0: return "vector=sw0";
4305 case MipsInterruptAttr::sw1: return "vector=sw1";
4306 case MipsInterruptAttr::hw0: return "vector=hw0";
4307 case MipsInterruptAttr::hw1: return "vector=hw1";
4308 case MipsInterruptAttr::hw2: return "vector=hw2";
4309 case MipsInterruptAttr::hw3: return "vector=hw3";
4310 case MipsInterruptAttr::hw4: return "vector=hw4";
4311 case MipsInterruptAttr::hw5: return "vector=hw5";
4312 case MipsInterruptAttr::eic: return "eic";
4313 }
4314 llvm_unreachable("No enumerator with that value")::llvm::llvm_unreachable_internal("No enumerator with that value"
, "/build/llvm-toolchain-snapshot-7~svn329677/build-llvm/tools/clang/include/clang/AST/Attrs.inc"
, 4314)
;
4315 }
4316
4317
4318 static bool classof(const Attr *A) { return A->getKind() == attr::MipsInterrupt; }
4319};
4320
4321class MipsLongCallAttr : public InheritableAttr {
4322public:
4323 enum Spelling {
4324 GNU_long_call = 0,
4325 CXX11_gnu_long_call = 1,
4326 GNU_far = 2,
4327 CXX11_gnu_far = 3
4328 };
4329
4330 static MipsLongCallAttr *CreateImplicit(ASTContext &Ctx, Spelling S, SourceRange Loc = SourceRange()) {
4331 auto *A = new (Ctx) MipsLongCallAttr(Loc, Ctx, S);
4332 A->setImplicit(true);
4333 return A;
4334 }
4335
4336 MipsLongCallAttr(SourceRange R, ASTContext &Ctx
4337 , unsigned SI
4338 )
4339 : InheritableAttr(attr::MipsLongCall, R, SI, false, false)
4340 {