Bug Summary

File:build-llvm/tools/clang/include/clang/AST/Attrs.inc
Warning:line 9039, column 5
Called C++ object pointer is null

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-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-8/lib/clang/8.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/clang/lib/Sema -I /build/llvm-toolchain-snapshot-8~svn345461/tools/clang/lib/Sema -I /build/llvm-toolchain-snapshot-8~svn345461/tools/clang/include -I /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/tools/clang/include -I /build/llvm-toolchain-snapshot-8~svn345461/build-llvm/include -I /build/llvm-toolchain-snapshot-8~svn345461/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward -internal-isystem /usr/include/clang/8.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-8/lib/clang/8.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-8~svn345461/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-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2018-10-27-211344-32123-1 -x c++ /build/llvm-toolchain-snapshot-8~svn345461/tools/clang/lib/Sema/Sema.cpp -faddrsig

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

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