Bug Summary

File:build-llvm/tools/clang/include/clang/AST/Attrs.inc
Warning:line 8240, column 9
Null pointer passed as an argument to a 'nonnull' parameter

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name Sema.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-7/lib/clang/7.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-7~svn337103/build-llvm/tools/clang/lib/Sema -I /build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema -I /build/llvm-toolchain-snapshot-7~svn337103/tools/clang/include -I /build/llvm-toolchain-snapshot-7~svn337103/build-llvm/tools/clang/include -I /build/llvm-toolchain-snapshot-7~svn337103/build-llvm/include -I /build/llvm-toolchain-snapshot-7~svn337103/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward -internal-isystem /usr/include/clang/7.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-7/lib/clang/7.0.0/include -internal-externc-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-7~svn337103/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-07-15-073923-5500-1 -x c++ /build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp

/build/llvm-toolchain-snapshot-7~svn337103/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!")(static_cast <bool> (DelayedTypos.empty() && "Uncorrected typos!"
) ? void (0) : __assert_fail ("DelayedTypos.empty() && \"Uncorrected typos!\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 366, __extension__ __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
Assuming 'fn' is non-null
2
Taking false branch
378
379 // If we're in template instantiation, it's an error.
380 if (inTemplateInstantiation())
3
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))
4
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;
5
Taking false branch
389
390 fn->addAttr(UnavailableAttr::CreateImplicit(Context, "", reason, loc));
6
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")(static_cast <bool> (E && "Cannot use with NULL ptr"
) ? void (0) : __assert_fail ("E && \"Cannot use with NULL ptr\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 404, __extension__ __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->getLocStart()))
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->getLocStart();
458 if (Diags.getSuppressSystemWarnings() &&
459 SourceMgr.isInSystemMacro(MaybeMacroLoc) &&
460 !findMacroSpelling(MaybeMacroLoc, "NULL"))
461 return;
462
463 Diag(E->getLocStart(), 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-7~svn337103/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-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 479)
;
480 case CK_LValueToRValue:
481 case CK_ArrayToPointerDecay:
482 case CK_FunctionToPointerDecay:
483 case CK_ToVoid:
484 break;
485 }
486 }
487 assert((VK == VK_RValue || !E->isRValue()) && "can't cast rvalue to lvalue")(static_cast <bool> ((VK == VK_RValue || !E->isRValue
()) && "can't cast rvalue to lvalue") ? void (0) : __assert_fail
("(VK == VK_RValue || !E->isRValue()) && \"can't cast rvalue to lvalue\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 487, __extension__ __PRETTY_FUNCTION__))
;
488#endif
489
490 diagnoseNullableToNonnullConversion(Ty, E->getType(), E->getLocStart());
491 diagnoseZeroToNullptrConversion(Kind, E);
492
493 QualType ExprTy = Context.getCanonicalType(E->getType());
494 QualType TypeTy = Context.getCanonicalType(Ty);
495
496 if (ExprTy == TypeTy)
497 return E;
498
499 // C++1z [conv.array]: The temporary materialization conversion is applied.
500 // We also use this to fuel C++ DR1213, which applies to C++11 onwards.
501 if (Kind == CK_ArrayToPointerDecay && getLangOpts().CPlusPlus &&
502 E->getValueKind() == VK_RValue) {
503 // The temporary is an lvalue in C++98 and an xvalue otherwise.
504 ExprResult Materialized = CreateMaterializeTemporaryExpr(
505 E->getType(), E, !getLangOpts().CPlusPlus11);
506 if (Materialized.isInvalid())
507 return ExprError();
508 E = Materialized.get();
509 }
510
511 if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(E)) {
512 if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
513 ImpCast->setType(Ty);
514 ImpCast->setValueKind(VK);
515 return E;
516 }
517 }
518
519 return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK);
520}
521
522/// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding
523/// to the conversion from scalar type ScalarTy to the Boolean type.
524CastKind Sema::ScalarTypeToBooleanCastKind(QualType ScalarTy) {
525 switch (ScalarTy->getScalarTypeKind()) {
526 case Type::STK_Bool: return CK_NoOp;
527 case Type::STK_CPointer: return CK_PointerToBoolean;
528 case Type::STK_BlockPointer: return CK_PointerToBoolean;
529 case Type::STK_ObjCObjectPointer: return CK_PointerToBoolean;
530 case Type::STK_MemberPointer: return CK_MemberPointerToBoolean;
531 case Type::STK_Integral: return CK_IntegralToBoolean;
532 case Type::STK_Floating: return CK_FloatingToBoolean;
533 case Type::STK_IntegralComplex: return CK_IntegralComplexToBoolean;
534 case Type::STK_FloatingComplex: return CK_FloatingComplexToBoolean;
535 }
536 llvm_unreachable("unknown scalar type kind")::llvm::llvm_unreachable_internal("unknown scalar type kind",
"/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 536)
;
537}
538
539/// Used to prune the decls of Sema's UnusedFileScopedDecls vector.
540static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D) {
541 if (D->getMostRecentDecl()->isUsed())
542 return true;
543
544 if (D->isExternallyVisible())
545 return true;
546
547 if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
548 // If this is a function template and none of its specializations is used,
549 // we should warn.
550 if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
551 for (const auto *Spec : Template->specializations())
552 if (ShouldRemoveFromUnused(SemaRef, Spec))
553 return true;
554
555 // UnusedFileScopedDecls stores the first declaration.
556 // The declaration may have become definition so check again.
557 const FunctionDecl *DeclToCheck;
558 if (FD->hasBody(DeclToCheck))
559 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
560
561 // Later redecls may add new information resulting in not having to warn,
562 // so check again.
563 DeclToCheck = FD->getMostRecentDecl();
564 if (DeclToCheck != FD)
565 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
566 }
567
568 if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
569 // If a variable usable in constant expressions is referenced,
570 // don't warn if it isn't used: if the value of a variable is required
571 // for the computation of a constant expression, it doesn't make sense to
572 // warn even if the variable isn't odr-used. (isReferenced doesn't
573 // precisely reflect that, but it's a decent approximation.)
574 if (VD->isReferenced() &&
575 VD->isUsableInConstantExpressions(SemaRef->Context))
576 return true;
577
578 if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
579 // If this is a variable template and none of its specializations is used,
580 // we should warn.
581 for (const auto *Spec : Template->specializations())
582 if (ShouldRemoveFromUnused(SemaRef, Spec))
583 return true;
584
585 // UnusedFileScopedDecls stores the first declaration.
586 // The declaration may have become definition so check again.
587 const VarDecl *DeclToCheck = VD->getDefinition();
588 if (DeclToCheck)
589 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
590
591 // Later redecls may add new information resulting in not having to warn,
592 // so check again.
593 DeclToCheck = VD->getMostRecentDecl();
594 if (DeclToCheck != VD)
595 return !SemaRef->ShouldWarnIfUnusedFileScopedDecl(DeclToCheck);
596 }
597
598 return false;
599}
600
601static bool isFunctionOrVarDeclExternC(NamedDecl *ND) {
602 if (auto *FD = dyn_cast<FunctionDecl>(ND))
603 return FD->isExternC();
604 return cast<VarDecl>(ND)->isExternC();
605}
606
607/// Determine whether ND is an external-linkage function or variable whose
608/// type has no linkage.
609bool Sema::isExternalWithNoLinkageType(ValueDecl *VD) {
610 // Note: it's not quite enough to check whether VD has UniqueExternalLinkage,
611 // because we also want to catch the case where its type has VisibleNoLinkage,
612 // which does not affect the linkage of VD.
613 return getLangOpts().CPlusPlus && VD->hasExternalFormalLinkage() &&
614 !isExternalFormalLinkage(VD->getType()->getLinkage()) &&
615 !isFunctionOrVarDeclExternC(VD);
616}
617
618/// Obtains a sorted list of functions and variables that are undefined but
619/// ODR-used.
620void Sema::getUndefinedButUsed(
621 SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> > &Undefined) {
622 for (const auto &UndefinedUse : UndefinedButUsed) {
623 NamedDecl *ND = UndefinedUse.first;
624
625 // Ignore attributes that have become invalid.
626 if (ND->isInvalidDecl()) continue;
627
628 // __attribute__((weakref)) is basically a definition.
629 if (ND->hasAttr<WeakRefAttr>()) continue;
630
631 if (isa<CXXDeductionGuideDecl>(ND))
632 continue;
633
634 if (ND->hasAttr<DLLImportAttr>() || ND->hasAttr<DLLExportAttr>()) {
635 // An exported function will always be emitted when defined, so even if
636 // the function is inline, it doesn't have to be emitted in this TU. An
637 // imported function implies that it has been exported somewhere else.
638 continue;
639 }
640
641 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
642 if (FD->isDefined())
643 continue;
644 if (FD->isExternallyVisible() &&
645 !isExternalWithNoLinkageType(FD) &&
646 !FD->getMostRecentDecl()->isInlined())
647 continue;
648 if (FD->getBuiltinID())
649 continue;
650 } else {
651 auto *VD = cast<VarDecl>(ND);
652 if (VD->hasDefinition() != VarDecl::DeclarationOnly)
653 continue;
654 if (VD->isExternallyVisible() &&
655 !isExternalWithNoLinkageType(VD) &&
656 !VD->getMostRecentDecl()->isInline())
657 continue;
658
659 // Skip VarDecls that lack formal definitions but which we know are in
660 // fact defined somewhere.
661 if (VD->isKnownToBeDefined())
662 continue;
663 }
664
665 Undefined.push_back(std::make_pair(ND, UndefinedUse.second));
666 }
667}
668
669/// checkUndefinedButUsed - Check for undefined objects with internal linkage
670/// or that are inline.
671static void checkUndefinedButUsed(Sema &S) {
672 if (S.UndefinedButUsed.empty()) return;
673
674 // Collect all the still-undefined entities with internal linkage.
675 SmallVector<std::pair<NamedDecl *, SourceLocation>, 16> Undefined;
676 S.getUndefinedButUsed(Undefined);
677 if (Undefined.empty()) return;
678
679 for (auto Undef : Undefined) {
680 ValueDecl *VD = cast<ValueDecl>(Undef.first);
681 SourceLocation UseLoc = Undef.second;
682
683 if (S.isExternalWithNoLinkageType(VD)) {
684 // C++ [basic.link]p8:
685 // A type without linkage shall not be used as the type of a variable
686 // or function with external linkage unless
687 // -- the entity has C language linkage
688 // -- the entity is not odr-used or is defined in the same TU
689 //
690 // As an extension, accept this in cases where the type is externally
691 // visible, since the function or variable actually can be defined in
692 // another translation unit in that case.
693 S.Diag(VD->getLocation(), isExternallyVisible(VD->getType()->getLinkage())
694 ? diag::ext_undefined_internal_type
695 : diag::err_undefined_internal_type)
696 << isa<VarDecl>(VD) << VD;
697 } else if (!VD->isExternallyVisible()) {
698 // FIXME: We can promote this to an error. The function or variable can't
699 // be defined anywhere else, so the program must necessarily violate the
700 // one definition rule.
701 S.Diag(VD->getLocation(), diag::warn_undefined_internal)
702 << isa<VarDecl>(VD) << VD;
703 } else if (auto *FD = dyn_cast<FunctionDecl>(VD)) {
704 (void)FD;
705 assert(FD->getMostRecentDecl()->isInlined() &&(static_cast <bool> (FD->getMostRecentDecl()->isInlined
() && "used object requires definition but isn't inline or internal?"
) ? void (0) : __assert_fail ("FD->getMostRecentDecl()->isInlined() && \"used object requires definition but isn't inline or internal?\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 706, __extension__ __PRETTY_FUNCTION__))
706 "used object requires definition but isn't inline or internal?")(static_cast <bool> (FD->getMostRecentDecl()->isInlined
() && "used object requires definition but isn't inline or internal?"
) ? void (0) : __assert_fail ("FD->getMostRecentDecl()->isInlined() && \"used object requires definition but isn't inline or internal?\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 706, __extension__ __PRETTY_FUNCTION__))
;
707 // FIXME: This is ill-formed; we should reject.
708 S.Diag(VD->getLocation(), diag::warn_undefined_inline) << VD;
709 } else {
710 assert(cast<VarDecl>(VD)->getMostRecentDecl()->isInline() &&(static_cast <bool> (cast<VarDecl>(VD)->getMostRecentDecl
()->isInline() && "used var requires definition but isn't inline or internal?"
) ? void (0) : __assert_fail ("cast<VarDecl>(VD)->getMostRecentDecl()->isInline() && \"used var requires definition but isn't inline or internal?\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 711, __extension__ __PRETTY_FUNCTION__))
711 "used var requires definition but isn't inline or internal?")(static_cast <bool> (cast<VarDecl>(VD)->getMostRecentDecl
()->isInline() && "used var requires definition but isn't inline or internal?"
) ? void (0) : __assert_fail ("cast<VarDecl>(VD)->getMostRecentDecl()->isInline() && \"used var requires definition but isn't inline or internal?\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 711, __extension__ __PRETTY_FUNCTION__))
;
712 S.Diag(VD->getLocation(), diag::err_undefined_inline_var) << VD;
713 }
714 if (UseLoc.isValid())
715 S.Diag(UseLoc, diag::note_used_here);
716 }
717
718 S.UndefinedButUsed.clear();
719}
720
721void Sema::LoadExternalWeakUndeclaredIdentifiers() {
722 if (!ExternalSource)
723 return;
724
725 SmallVector<std::pair<IdentifierInfo *, WeakInfo>, 4> WeakIDs;
726 ExternalSource->ReadWeakUndeclaredIdentifiers(WeakIDs);
727 for (auto &WeakID : WeakIDs)
728 WeakUndeclaredIdentifiers.insert(WeakID);
729}
730
731
732typedef llvm::DenseMap<const CXXRecordDecl*, bool> RecordCompleteMap;
733
734/// Returns true, if all methods and nested classes of the given
735/// CXXRecordDecl are defined in this translation unit.
736///
737/// Should only be called from ActOnEndOfTranslationUnit so that all
738/// definitions are actually read.
739static bool MethodsAndNestedClassesComplete(const CXXRecordDecl *RD,
740 RecordCompleteMap &MNCComplete) {
741 RecordCompleteMap::iterator Cache = MNCComplete.find(RD);
742 if (Cache != MNCComplete.end())
743 return Cache->second;
744 if (!RD->isCompleteDefinition())
745 return false;
746 bool Complete = true;
747 for (DeclContext::decl_iterator I = RD->decls_begin(),
748 E = RD->decls_end();
749 I != E && Complete; ++I) {
750 if (const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(*I))
751 Complete = M->isDefined() || M->isDefaulted() ||
752 (M->isPure() && !isa<CXXDestructorDecl>(M));
753 else if (const FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(*I))
754 // If the template function is marked as late template parsed at this
755 // point, it has not been instantiated and therefore we have not
756 // performed semantic analysis on it yet, so we cannot know if the type
757 // can be considered complete.
758 Complete = !F->getTemplatedDecl()->isLateTemplateParsed() &&
759 F->getTemplatedDecl()->isDefined();
760 else if (const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) {
761 if (R->isInjectedClassName())
762 continue;
763 if (R->hasDefinition())
764 Complete = MethodsAndNestedClassesComplete(R->getDefinition(),
765 MNCComplete);
766 else
767 Complete = false;
768 }
769 }
770 MNCComplete[RD] = Complete;
771 return Complete;
772}
773
774/// Returns true, if the given CXXRecordDecl is fully defined in this
775/// translation unit, i.e. all methods are defined or pure virtual and all
776/// friends, friend functions and nested classes are fully defined in this
777/// translation unit.
778///
779/// Should only be called from ActOnEndOfTranslationUnit so that all
780/// definitions are actually read.
781static bool IsRecordFullyDefined(const CXXRecordDecl *RD,
782 RecordCompleteMap &RecordsComplete,
783 RecordCompleteMap &MNCComplete) {
784 RecordCompleteMap::iterator Cache = RecordsComplete.find(RD);
785 if (Cache != RecordsComplete.end())
786 return Cache->second;
787 bool Complete = MethodsAndNestedClassesComplete(RD, MNCComplete);
788 for (CXXRecordDecl::friend_iterator I = RD->friend_begin(),
789 E = RD->friend_end();
790 I != E && Complete; ++I) {
791 // Check if friend classes and methods are complete.
792 if (TypeSourceInfo *TSI = (*I)->getFriendType()) {
793 // Friend classes are available as the TypeSourceInfo of the FriendDecl.
794 if (CXXRecordDecl *FriendD = TSI->getType()->getAsCXXRecordDecl())
795 Complete = MethodsAndNestedClassesComplete(FriendD, MNCComplete);
796 else
797 Complete = false;
798 } else {
799 // Friend functions are available through the NamedDecl of FriendDecl.
800 if (const FunctionDecl *FD =
801 dyn_cast<FunctionDecl>((*I)->getFriendDecl()))
802 Complete = FD->isDefined();
803 else
804 // This is a template friend, give up.
805 Complete = false;
806 }
807 }
808 RecordsComplete[RD] = Complete;
809 return Complete;
810}
811
812void Sema::emitAndClearUnusedLocalTypedefWarnings() {
813 if (ExternalSource)
814 ExternalSource->ReadUnusedLocalTypedefNameCandidates(
815 UnusedLocalTypedefNameCandidates);
816 for (const TypedefNameDecl *TD : UnusedLocalTypedefNameCandidates) {
817 if (TD->isReferenced())
818 continue;
819 Diag(TD->getLocation(), diag::warn_unused_local_typedef)
820 << isa<TypeAliasDecl>(TD) << TD->getDeclName();
821 }
822 UnusedLocalTypedefNameCandidates.clear();
823}
824
825/// This is called before the very first declaration in the translation unit
826/// is parsed. Note that the ASTContext may have already injected some
827/// declarations.
828void Sema::ActOnStartOfTranslationUnit() {
829 if (getLangOpts().ModulesTS) {
830 SourceLocation StartOfTU =
831 SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
832
833 // We start in the global module; all those declarations are implicitly
834 // module-private (though they do not have module linkage).
835 auto &Map = PP.getHeaderSearchInfo().getModuleMap();
836 auto *GlobalModule = Map.createGlobalModuleForInterfaceUnit(StartOfTU);
837 assert(GlobalModule && "module creation should not fail")(static_cast <bool> (GlobalModule && "module creation should not fail"
) ? void (0) : __assert_fail ("GlobalModule && \"module creation should not fail\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 837, __extension__ __PRETTY_FUNCTION__))
;
838
839 // Enter the scope of the global module.
840 ModuleScopes.push_back({});
841 ModuleScopes.back().Module = GlobalModule;
842 VisibleModules.setVisible(GlobalModule, StartOfTU);
843
844 // All declarations created from now on are owned by the global module.
845 auto *TU = Context.getTranslationUnitDecl();
846 TU->setModuleOwnershipKind(Decl::ModuleOwnershipKind::Visible);
847 TU->setLocalOwningModule(GlobalModule);
848 }
849}
850
851/// ActOnEndOfTranslationUnit - This is called at the very end of the
852/// translation unit when EOF is reached and all but the top-level scope is
853/// popped.
854void Sema::ActOnEndOfTranslationUnit() {
855 assert(DelayedDiagnostics.getCurrentPool() == nullptr(static_cast <bool> (DelayedDiagnostics.getCurrentPool(
) == nullptr && "reached end of translation unit with a pool attached?"
) ? void (0) : __assert_fail ("DelayedDiagnostics.getCurrentPool() == nullptr && \"reached end of translation unit with a pool attached?\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 856, __extension__ __PRETTY_FUNCTION__))
856 && "reached end of translation unit with a pool attached?")(static_cast <bool> (DelayedDiagnostics.getCurrentPool(
) == nullptr && "reached end of translation unit with a pool attached?"
) ? void (0) : __assert_fail ("DelayedDiagnostics.getCurrentPool() == nullptr && \"reached end of translation unit with a pool attached?\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 856, __extension__ __PRETTY_FUNCTION__))
;
857
858 // If code completion is enabled, don't perform any end-of-translation-unit
859 // work.
860 if (PP.isCodeCompletionEnabled())
861 return;
862
863 // Transfer late parsed template instantiations over to the pending template
864 // instantiation list. During normal compliation, the late template parser
865 // will be installed and instantiating these templates will succeed.
866 //
867 // If we are building a TU prefix for serialization, it is also safe to
868 // transfer these over, even though they are not parsed. The end of the TU
869 // should be outside of any eager template instantiation scope, so when this
870 // AST is deserialized, these templates will not be parsed until the end of
871 // the combined TU.
872 PendingInstantiations.insert(PendingInstantiations.end(),
873 LateParsedInstantiations.begin(),
874 LateParsedInstantiations.end());
875 LateParsedInstantiations.clear();
876
877 // Complete translation units and modules define vtables and perform implicit
878 // instantiations. PCH files do not.
879 if (TUKind != TU_Prefix) {
880 DiagnoseUseOfUnimplementedSelectors();
881
882 // If DefinedUsedVTables ends up marking any virtual member functions it
883 // might lead to more pending template instantiations, which we then need
884 // to instantiate.
885 DefineUsedVTables();
886
887 // C++: Perform implicit template instantiations.
888 //
889 // FIXME: When we perform these implicit instantiations, we do not
890 // carefully keep track of the point of instantiation (C++ [temp.point]).
891 // This means that name lookup that occurs within the template
892 // instantiation will always happen at the end of the translation unit,
893 // so it will find some names that are not required to be found. This is
894 // valid, but we could do better by diagnosing if an instantiation uses a
895 // name that was not visible at its first point of instantiation.
896 if (ExternalSource) {
897 // Load pending instantiations from the external source.
898 SmallVector<PendingImplicitInstantiation, 4> Pending;
899 ExternalSource->ReadPendingInstantiations(Pending);
900 for (auto PII : Pending)
901 if (auto Func = dyn_cast<FunctionDecl>(PII.first))
902 Func->setInstantiationIsPending(true);
903 PendingInstantiations.insert(PendingInstantiations.begin(),
904 Pending.begin(), Pending.end());
905 }
906
907 PerformPendingInstantiations();
908
909 assert(LateParsedInstantiations.empty() &&(static_cast <bool> (LateParsedInstantiations.empty() &&
"end of TU template instantiation should not create more " "late-parsed templates"
) ? void (0) : __assert_fail ("LateParsedInstantiations.empty() && \"end of TU template instantiation should not create more \" \"late-parsed templates\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 911, __extension__ __PRETTY_FUNCTION__))
910 "end of TU template instantiation should not create more "(static_cast <bool> (LateParsedInstantiations.empty() &&
"end of TU template instantiation should not create more " "late-parsed templates"
) ? void (0) : __assert_fail ("LateParsedInstantiations.empty() && \"end of TU template instantiation should not create more \" \"late-parsed templates\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 911, __extension__ __PRETTY_FUNCTION__))
911 "late-parsed templates")(static_cast <bool> (LateParsedInstantiations.empty() &&
"end of TU template instantiation should not create more " "late-parsed templates"
) ? void (0) : __assert_fail ("LateParsedInstantiations.empty() && \"end of TU template instantiation should not create more \" \"late-parsed templates\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 911, __extension__ __PRETTY_FUNCTION__))
;
912
913 if (LateTemplateParserCleanup)
914 LateTemplateParserCleanup(OpaqueParser);
915
916 CheckDelayedMemberExceptionSpecs();
917 }
918
919 DiagnoseUnterminatedPragmaPack();
920 DiagnoseUnterminatedPragmaAttribute();
921
922 // All delayed member exception specs should be checked or we end up accepting
923 // incompatible declarations.
924 // FIXME: This is wrong for TUKind == TU_Prefix. In that case, we need to
925 // write out the lists to the AST file (if any).
926 assert(DelayedDefaultedMemberExceptionSpecs.empty())(static_cast <bool> (DelayedDefaultedMemberExceptionSpecs
.empty()) ? void (0) : __assert_fail ("DelayedDefaultedMemberExceptionSpecs.empty()"
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 926, __extension__ __PRETTY_FUNCTION__))
;
927 assert(DelayedExceptionSpecChecks.empty())(static_cast <bool> (DelayedExceptionSpecChecks.empty()
) ? void (0) : __assert_fail ("DelayedExceptionSpecChecks.empty()"
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 927, __extension__ __PRETTY_FUNCTION__))
;
928
929 // All dllexport classes should have been processed already.
930 assert(DelayedDllExportClasses.empty())(static_cast <bool> (DelayedDllExportClasses.empty()) ?
void (0) : __assert_fail ("DelayedDllExportClasses.empty()",
"/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 930, __extension__ __PRETTY_FUNCTION__))
;
931
932 // Remove file scoped decls that turned out to be used.
933 UnusedFileScopedDecls.erase(
934 std::remove_if(UnusedFileScopedDecls.begin(nullptr, true),
935 UnusedFileScopedDecls.end(),
936 [this](const DeclaratorDecl *DD) {
937 return ShouldRemoveFromUnused(this, DD);
938 }),
939 UnusedFileScopedDecls.end());
940
941 if (TUKind == TU_Prefix) {
942 // Translation unit prefixes don't need any of the checking below.
943 if (!PP.isIncrementalProcessingEnabled())
944 TUScope = nullptr;
945 return;
946 }
947
948 // Check for #pragma weak identifiers that were never declared
949 LoadExternalWeakUndeclaredIdentifiers();
950 for (auto WeakID : WeakUndeclaredIdentifiers) {
951 if (WeakID.second.getUsed())
952 continue;
953
954 Decl *PrevDecl = LookupSingleName(TUScope, WeakID.first, SourceLocation(),
955 LookupOrdinaryName);
956 if (PrevDecl != nullptr &&
957 !(isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl)))
958 Diag(WeakID.second.getLocation(), diag::warn_attribute_wrong_decl_type)
959 << "'weak'" << ExpectedVariableOrFunction;
960 else
961 Diag(WeakID.second.getLocation(), diag::warn_weak_identifier_undeclared)
962 << WeakID.first;
963 }
964
965 if (LangOpts.CPlusPlus11 &&
966 !Diags.isIgnored(diag::warn_delegating_ctor_cycle, SourceLocation()))
967 CheckDelegatingCtorCycles();
968
969 if (!Diags.hasErrorOccurred()) {
970 if (ExternalSource)
971 ExternalSource->ReadUndefinedButUsed(UndefinedButUsed);
972 checkUndefinedButUsed(*this);
973 }
974
975 if (TUKind == TU_Module) {
976 // If we are building a module interface unit, we need to have seen the
977 // module declaration by now.
978 if (getLangOpts().getCompilingModule() ==
979 LangOptions::CMK_ModuleInterface &&
980 ModuleScopes.back().Module->Kind != Module::ModuleInterfaceUnit) {
981 // FIXME: Make a better guess as to where to put the module declaration.
982 Diag(getSourceManager().getLocForStartOfFile(
983 getSourceManager().getMainFileID()),
984 diag::err_module_declaration_missing);
985 }
986
987 // If we are building a module, resolve all of the exported declarations
988 // now.
989 if (Module *CurrentModule = PP.getCurrentModule()) {
990 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
991
992 SmallVector<Module *, 2> Stack;
993 Stack.push_back(CurrentModule);
994 while (!Stack.empty()) {
995 Module *Mod = Stack.pop_back_val();
996
997 // Resolve the exported declarations and conflicts.
998 // FIXME: Actually complain, once we figure out how to teach the
999 // diagnostic client to deal with complaints in the module map at this
1000 // point.
1001 ModMap.resolveExports(Mod, /*Complain=*/false);
1002 ModMap.resolveUses(Mod, /*Complain=*/false);
1003 ModMap.resolveConflicts(Mod, /*Complain=*/false);
1004
1005 // Queue the submodules, so their exports will also be resolved.
1006 Stack.append(Mod->submodule_begin(), Mod->submodule_end());
1007 }
1008 }
1009
1010 // Warnings emitted in ActOnEndOfTranslationUnit() should be emitted for
1011 // modules when they are built, not every time they are used.
1012 emitAndClearUnusedLocalTypedefWarnings();
1013 }
1014
1015 // C99 6.9.2p2:
1016 // A declaration of an identifier for an object that has file
1017 // scope without an initializer, and without a storage-class
1018 // specifier or with the storage-class specifier static,
1019 // constitutes a tentative definition. If a translation unit
1020 // contains one or more tentative definitions for an identifier,
1021 // and the translation unit contains no external definition for
1022 // that identifier, then the behavior is exactly as if the
1023 // translation unit contains a file scope declaration of that
1024 // identifier, with the composite type as of the end of the
1025 // translation unit, with an initializer equal to 0.
1026 llvm::SmallSet<VarDecl *, 32> Seen;
1027 for (TentativeDefinitionsType::iterator
1028 T = TentativeDefinitions.begin(ExternalSource),
1029 TEnd = TentativeDefinitions.end();
1030 T != TEnd; ++T) {
1031 VarDecl *VD = (*T)->getActingDefinition();
1032
1033 // If the tentative definition was completed, getActingDefinition() returns
1034 // null. If we've already seen this variable before, insert()'s second
1035 // return value is false.
1036 if (!VD || VD->isInvalidDecl() || !Seen.insert(VD).second)
1037 continue;
1038
1039 if (const IncompleteArrayType *ArrayT
1040 = Context.getAsIncompleteArrayType(VD->getType())) {
1041 // Set the length of the array to 1 (C99 6.9.2p5).
1042 Diag(VD->getLocation(), diag::warn_tentative_incomplete_array);
1043 llvm::APInt One(Context.getTypeSize(Context.getSizeType()), true);
1044 QualType T = Context.getConstantArrayType(ArrayT->getElementType(),
1045 One, ArrayType::Normal, 0);
1046 VD->setType(T);
1047 } else if (RequireCompleteType(VD->getLocation(), VD->getType(),
1048 diag::err_tentative_def_incomplete_type))
1049 VD->setInvalidDecl();
1050
1051 // No initialization is performed for a tentative definition.
1052 CheckCompleteVariableDeclaration(VD);
1053
1054 // Notify the consumer that we've completed a tentative definition.
1055 if (!VD->isInvalidDecl())
1056 Consumer.CompleteTentativeDefinition(VD);
1057 }
1058
1059 // If there were errors, disable 'unused' warnings since they will mostly be
1060 // noise. Don't warn for a use from a module: either we should warn on all
1061 // file-scope declarations in modules or not at all, but whether the
1062 // declaration is used is immaterial.
1063 if (!Diags.hasErrorOccurred() && TUKind != TU_Module) {
1064 // Output warning for unused file scoped decls.
1065 for (UnusedFileScopedDeclsType::iterator
1066 I = UnusedFileScopedDecls.begin(ExternalSource),
1067 E = UnusedFileScopedDecls.end(); I != E; ++I) {
1068 if (ShouldRemoveFromUnused(this, *I))
1069 continue;
1070
1071 if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) {
1072 const FunctionDecl *DiagD;
1073 if (!FD->hasBody(DiagD))
1074 DiagD = FD;
1075 if (DiagD->isDeleted())
1076 continue; // Deleted functions are supposed to be unused.
1077 if (DiagD->isReferenced()) {
1078 if (isa<CXXMethodDecl>(DiagD))
1079 Diag(DiagD->getLocation(), diag::warn_unneeded_member_function)
1080 << DiagD->getDeclName();
1081 else {
1082 if (FD->getStorageClass() == SC_Static &&
1083 !FD->isInlineSpecified() &&
1084 !SourceMgr.isInMainFile(
1085 SourceMgr.getExpansionLoc(FD->getLocation())))
1086 Diag(DiagD->getLocation(),
1087 diag::warn_unneeded_static_internal_decl)
1088 << DiagD->getDeclName();
1089 else
1090 Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
1091 << /*function*/0 << DiagD->getDeclName();
1092 }
1093 } else {
1094 if (FD->getDescribedFunctionTemplate())
1095 Diag(DiagD->getLocation(), diag::warn_unused_template)
1096 << /*function*/0 << DiagD->getDeclName();
1097 else
1098 Diag(DiagD->getLocation(),
1099 isa<CXXMethodDecl>(DiagD) ? diag::warn_unused_member_function
1100 : diag::warn_unused_function)
1101 << DiagD->getDeclName();
1102 }
1103 } else {
1104 const VarDecl *DiagD = cast<VarDecl>(*I)->getDefinition();
1105 if (!DiagD)
1106 DiagD = cast<VarDecl>(*I);
1107 if (DiagD->isReferenced()) {
1108 Diag(DiagD->getLocation(), diag::warn_unneeded_internal_decl)
1109 << /*variable*/1 << DiagD->getDeclName();
1110 } else if (DiagD->getType().isConstQualified()) {
1111 const SourceManager &SM = SourceMgr;
1112 if (SM.getMainFileID() != SM.getFileID(DiagD->getLocation()) ||
1113 !PP.getLangOpts().IsHeaderFile)
1114 Diag(DiagD->getLocation(), diag::warn_unused_const_variable)
1115 << DiagD->getDeclName();
1116 } else {
1117 if (DiagD->getDescribedVarTemplate())
1118 Diag(DiagD->getLocation(), diag::warn_unused_template)
1119 << /*variable*/1 << DiagD->getDeclName();
1120 else
1121 Diag(DiagD->getLocation(), diag::warn_unused_variable)
1122 << DiagD->getDeclName();
1123 }
1124 }
1125 }
1126
1127 emitAndClearUnusedLocalTypedefWarnings();
1128 }
1129
1130 if (!Diags.isIgnored(diag::warn_unused_private_field, SourceLocation())) {
1131 // FIXME: Load additional unused private field candidates from the external
1132 // source.
1133 RecordCompleteMap RecordsComplete;
1134 RecordCompleteMap MNCComplete;
1135 for (NamedDeclSetType::iterator I = UnusedPrivateFields.begin(),
1136 E = UnusedPrivateFields.end(); I != E; ++I) {
1137 const NamedDecl *D = *I;
1138 const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D->getDeclContext());
1139 if (RD && !RD->isUnion() &&
1140 IsRecordFullyDefined(RD, RecordsComplete, MNCComplete)) {
1141 Diag(D->getLocation(), diag::warn_unused_private_field)
1142 << D->getDeclName();
1143 }
1144 }
1145 }
1146
1147 if (!Diags.isIgnored(diag::warn_mismatched_delete_new, SourceLocation())) {
1148 if (ExternalSource)
1149 ExternalSource->ReadMismatchingDeleteExpressions(DeleteExprs);
1150 for (const auto &DeletedFieldInfo : DeleteExprs) {
1151 for (const auto &DeleteExprLoc : DeletedFieldInfo.second) {
1152 AnalyzeDeleteExprMismatch(DeletedFieldInfo.first, DeleteExprLoc.first,
1153 DeleteExprLoc.second);
1154 }
1155 }
1156 }
1157
1158 // Check we've noticed that we're no longer parsing the initializer for every
1159 // variable. If we miss cases, then at best we have a performance issue and
1160 // at worst a rejects-valid bug.
1161 assert(ParsingInitForAutoVars.empty() &&(static_cast <bool> (ParsingInitForAutoVars.empty() &&
"Didn't unmark var as having its initializer parsed") ? void
(0) : __assert_fail ("ParsingInitForAutoVars.empty() && \"Didn't unmark var as having its initializer parsed\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 1162, __extension__ __PRETTY_FUNCTION__))
1162 "Didn't unmark var as having its initializer parsed")(static_cast <bool> (ParsingInitForAutoVars.empty() &&
"Didn't unmark var as having its initializer parsed") ? void
(0) : __assert_fail ("ParsingInitForAutoVars.empty() && \"Didn't unmark var as having its initializer parsed\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 1162, __extension__ __PRETTY_FUNCTION__))
;
1163
1164 if (!PP.isIncrementalProcessingEnabled())
1165 TUScope = nullptr;
1166}
1167
1168
1169//===----------------------------------------------------------------------===//
1170// Helper functions.
1171//===----------------------------------------------------------------------===//
1172
1173DeclContext *Sema::getFunctionLevelDeclContext() {
1174 DeclContext *DC = CurContext;
1175
1176 while (true) {
1177 if (isa<BlockDecl>(DC) || isa<EnumDecl>(DC) || isa<CapturedDecl>(DC)) {
1178 DC = DC->getParent();
1179 } else if (isa<CXXMethodDecl>(DC) &&
1180 cast<CXXMethodDecl>(DC)->getOverloadedOperator() == OO_Call &&
1181 cast<CXXRecordDecl>(DC->getParent())->isLambda()) {
1182 DC = DC->getParent()->getParent();
1183 }
1184 else break;
1185 }
1186
1187 return DC;
1188}
1189
1190/// getCurFunctionDecl - If inside of a function body, this returns a pointer
1191/// to the function decl for the function being parsed. If we're currently
1192/// in a 'block', this returns the containing context.
1193FunctionDecl *Sema::getCurFunctionDecl() {
1194 DeclContext *DC = getFunctionLevelDeclContext();
1195 return dyn_cast<FunctionDecl>(DC);
1196}
1197
1198ObjCMethodDecl *Sema::getCurMethodDecl() {
1199 DeclContext *DC = getFunctionLevelDeclContext();
1200 while (isa<RecordDecl>(DC))
1201 DC = DC->getParent();
1202 return dyn_cast<ObjCMethodDecl>(DC);
1203}
1204
1205NamedDecl *Sema::getCurFunctionOrMethodDecl() {
1206 DeclContext *DC = getFunctionLevelDeclContext();
1207 if (isa<ObjCMethodDecl>(DC) || isa<FunctionDecl>(DC))
1208 return cast<NamedDecl>(DC);
1209 return nullptr;
1210}
1211
1212void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
1213 // FIXME: It doesn't make sense to me that DiagID is an incoming argument here
1214 // and yet we also use the current diag ID on the DiagnosticsEngine. This has
1215 // been made more painfully obvious by the refactor that introduced this
1216 // function, but it is possible that the incoming argument can be
1217 // eliminated. If it truly cannot be (for example, there is some reentrancy
1218 // issue I am not seeing yet), then there should at least be a clarifying
1219 // comment somewhere.
1220 if (Optional<TemplateDeductionInfo*> Info = isSFINAEContext()) {
1221 switch (DiagnosticIDs::getDiagnosticSFINAEResponse(
1222 Diags.getCurrentDiagID())) {
1223 case DiagnosticIDs::SFINAE_Report:
1224 // We'll report the diagnostic below.
1225 break;
1226
1227 case DiagnosticIDs::SFINAE_SubstitutionFailure:
1228 // Count this failure so that we know that template argument deduction
1229 // has failed.
1230 ++NumSFINAEErrors;
1231
1232 // Make a copy of this suppressed diagnostic and store it with the
1233 // template-deduction information.
1234 if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
1235 Diagnostic DiagInfo(&Diags);
1236 (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
1237 PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
1238 }
1239
1240 Diags.setLastDiagnosticIgnored();
1241 Diags.Clear();
1242 return;
1243
1244 case DiagnosticIDs::SFINAE_AccessControl: {
1245 // Per C++ Core Issue 1170, access control is part of SFINAE.
1246 // Additionally, the AccessCheckingSFINAE flag can be used to temporarily
1247 // make access control a part of SFINAE for the purposes of checking
1248 // type traits.
1249 if (!AccessCheckingSFINAE && !getLangOpts().CPlusPlus11)
1250 break;
1251
1252 SourceLocation Loc = Diags.getCurrentDiagLoc();
1253
1254 // Suppress this diagnostic.
1255 ++NumSFINAEErrors;
1256
1257 // Make a copy of this suppressed diagnostic and store it with the
1258 // template-deduction information.
1259 if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
1260 Diagnostic DiagInfo(&Diags);
1261 (*Info)->addSFINAEDiagnostic(DiagInfo.getLocation(),
1262 PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
1263 }
1264
1265 Diags.setLastDiagnosticIgnored();
1266 Diags.Clear();
1267
1268 // Now the diagnostic state is clear, produce a C++98 compatibility
1269 // warning.
1270 Diag(Loc, diag::warn_cxx98_compat_sfinae_access_control);
1271
1272 // The last diagnostic which Sema produced was ignored. Suppress any
1273 // notes attached to it.
1274 Diags.setLastDiagnosticIgnored();
1275 return;
1276 }
1277
1278 case DiagnosticIDs::SFINAE_Suppress:
1279 // Make a copy of this suppressed diagnostic and store it with the
1280 // template-deduction information;
1281 if (*Info) {
1282 Diagnostic DiagInfo(&Diags);
1283 (*Info)->addSuppressedDiagnostic(DiagInfo.getLocation(),
1284 PartialDiagnostic(DiagInfo, Context.getDiagAllocator()));
1285 }
1286
1287 // Suppress this diagnostic.
1288 Diags.setLastDiagnosticIgnored();
1289 Diags.Clear();
1290 return;
1291 }
1292 }
1293
1294 // Copy the diagnostic printing policy over the ASTContext printing policy.
1295 // TODO: Stop doing that. See: https://reviews.llvm.org/D45093#1090292
1296 Context.setPrintingPolicy(getPrintingPolicy());
1297
1298 // Emit the diagnostic.
1299 if (!Diags.EmitCurrentDiagnostic())
1300 return;
1301
1302 // If this is not a note, and we're in a template instantiation
1303 // that is different from the last template instantiation where
1304 // we emitted an error, print a template instantiation
1305 // backtrace.
1306 if (!DiagnosticIDs::isBuiltinNote(DiagID))
1307 PrintContextStack();
1308}
1309
1310Sema::SemaDiagnosticBuilder
1311Sema::Diag(SourceLocation Loc, const PartialDiagnostic& PD) {
1312 SemaDiagnosticBuilder Builder(Diag(Loc, PD.getDiagID()));
1313 PD.Emit(Builder);
1314
1315 return Builder;
1316}
1317
1318/// Looks through the macro-expansion chain for the given
1319/// location, looking for a macro expansion with the given name.
1320/// If one is found, returns true and sets the location to that
1321/// expansion loc.
1322bool Sema::findMacroSpelling(SourceLocation &locref, StringRef name) {
1323 SourceLocation loc = locref;
1324 if (!loc.isMacroID()) return false;
1325
1326 // There's no good way right now to look at the intermediate
1327 // expansions, so just jump to the expansion location.
1328 loc = getSourceManager().getExpansionLoc(loc);
1329
1330 // If that's written with the name, stop here.
1331 SmallVector<char, 16> buffer;
1332 if (getPreprocessor().getSpelling(loc, buffer) == name) {
1333 locref = loc;
1334 return true;
1335 }
1336 return false;
1337}
1338
1339/// Determines the active Scope associated with the given declaration
1340/// context.
1341///
1342/// This routine maps a declaration context to the active Scope object that
1343/// represents that declaration context in the parser. It is typically used
1344/// from "scope-less" code (e.g., template instantiation, lazy creation of
1345/// declarations) that injects a name for name-lookup purposes and, therefore,
1346/// must update the Scope.
1347///
1348/// \returns The scope corresponding to the given declaraion context, or NULL
1349/// if no such scope is open.
1350Scope *Sema::getScopeForContext(DeclContext *Ctx) {
1351
1352 if (!Ctx)
1353 return nullptr;
1354
1355 Ctx = Ctx->getPrimaryContext();
1356 for (Scope *S = getCurScope(); S; S = S->getParent()) {
1357 // Ignore scopes that cannot have declarations. This is important for
1358 // out-of-line definitions of static class members.
1359 if (S->getFlags() & (Scope::DeclScope | Scope::TemplateParamScope))
1360 if (DeclContext *Entity = S->getEntity())
1361 if (Ctx == Entity->getPrimaryContext())
1362 return S;
1363 }
1364
1365 return nullptr;
1366}
1367
1368/// Enter a new function scope
1369void Sema::PushFunctionScope() {
1370 if (FunctionScopes.empty()) {
1371 // Use PreallocatedFunctionScope to avoid allocating memory when possible.
1372 PreallocatedFunctionScope->Clear();
1373 FunctionScopes.push_back(PreallocatedFunctionScope.get());
1374 } else {
1375 FunctionScopes.push_back(new FunctionScopeInfo(getDiagnostics()));
1376 }
1377 if (LangOpts.OpenMP)
1378 pushOpenMPFunctionRegion();
1379}
1380
1381void Sema::PushBlockScope(Scope *BlockScope, BlockDecl *Block) {
1382 FunctionScopes.push_back(new BlockScopeInfo(getDiagnostics(),
1383 BlockScope, Block));
1384}
1385
1386LambdaScopeInfo *Sema::PushLambdaScope() {
1387 LambdaScopeInfo *const LSI = new LambdaScopeInfo(getDiagnostics());
1388 FunctionScopes.push_back(LSI);
1389 return LSI;
1390}
1391
1392void Sema::RecordParsingTemplateParameterDepth(unsigned Depth) {
1393 if (LambdaScopeInfo *const LSI = getCurLambda()) {
1394 LSI->AutoTemplateParameterDepth = Depth;
1395 return;
1396 }
1397 llvm_unreachable(::llvm::llvm_unreachable_internal("Remove assertion if intentionally called in a non-lambda context."
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 1398)
1398 "Remove assertion if intentionally called in a non-lambda context.")::llvm::llvm_unreachable_internal("Remove assertion if intentionally called in a non-lambda context."
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 1398)
;
1399}
1400
1401void Sema::PopFunctionScopeInfo(const AnalysisBasedWarnings::Policy *WP,
1402 const Decl *D, const BlockExpr *blkExpr) {
1403 assert(!FunctionScopes.empty() && "mismatched push/pop!")(static_cast <bool> (!FunctionScopes.empty() &&
"mismatched push/pop!") ? void (0) : __assert_fail ("!FunctionScopes.empty() && \"mismatched push/pop!\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 1403, __extension__ __PRETTY_FUNCTION__))
;
1404 FunctionScopeInfo *Scope = FunctionScopes.pop_back_val();
1405
1406 if (LangOpts.OpenMP)
1407 popOpenMPFunctionRegion(Scope);
1408
1409 // Issue any analysis-based warnings.
1410 if (WP && D)
1411 AnalysisWarnings.IssueWarnings(*WP, Scope, D, blkExpr);
1412 else
1413 for (const auto &PUD : Scope->PossiblyUnreachableDiags)
1414 Diag(PUD.Loc, PUD.PD);
1415
1416 // Delete the scope unless its our preallocated scope.
1417 if (Scope != PreallocatedFunctionScope.get())
1418 delete Scope;
1419}
1420
1421void Sema::PushCompoundScope(bool IsStmtExpr) {
1422 getCurFunction()->CompoundScopes.push_back(CompoundScopeInfo(IsStmtExpr));
1423}
1424
1425void Sema::PopCompoundScope() {
1426 FunctionScopeInfo *CurFunction = getCurFunction();
1427 assert(!CurFunction->CompoundScopes.empty() && "mismatched push/pop")(static_cast <bool> (!CurFunction->CompoundScopes.empty
() && "mismatched push/pop") ? void (0) : __assert_fail
("!CurFunction->CompoundScopes.empty() && \"mismatched push/pop\""
, "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 1427, __extension__ __PRETTY_FUNCTION__))
;
1428
1429 CurFunction->CompoundScopes.pop_back();
1430}
1431
1432/// Determine whether any errors occurred within this function/method/
1433/// block.
1434bool Sema::hasAnyUnrecoverableErrorsInThisFunction() const {
1435 return getCurFunction()->ErrorTrap.hasUnrecoverableErrorOccurred();
1436}
1437
1438void Sema::setFunctionHasBranchIntoScope() {
1439 if (!FunctionScopes.empty())
1440 FunctionScopes.back()->setHasBranchIntoScope();
1441}
1442
1443void Sema::setFunctionHasBranchProtectedScope() {
1444 if (!FunctionScopes.empty())
1445 FunctionScopes.back()->setHasBranchProtectedScope();
1446}
1447
1448void Sema::setFunctionHasIndirectGoto() {
1449 if (!FunctionScopes.empty())
1450 FunctionScopes.back()->setHasIndirectGoto();
1451}
1452
1453BlockScopeInfo *Sema::getCurBlock() {
1454 if (FunctionScopes.empty())
1455 return nullptr;
1456
1457 auto CurBSI = dyn_cast<BlockScopeInfo>(FunctionScopes.back());
1458 if (CurBSI && CurBSI->TheDecl &&
1459 !CurBSI->TheDecl->Encloses(CurContext)) {
1460 // We have switched contexts due to template instantiation.
1461 assert(!CodeSynthesisContexts.empty())(static_cast <bool> (!CodeSynthesisContexts.empty()) ? void
(0) : __assert_fail ("!CodeSynthesisContexts.empty()", "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 1461, __extension__ __PRETTY_FUNCTION__))
;
1462 return nullptr;
1463 }
1464
1465 return CurBSI;
1466}
1467
1468FunctionScopeInfo *Sema::getEnclosingFunction() const {
1469 if (FunctionScopes.empty())
1470 return nullptr;
1471
1472 for (int e = FunctionScopes.size() - 1; e >= 0; --e) {
1473 if (isa<sema::BlockScopeInfo>(FunctionScopes[e]))
1474 continue;
1475 return FunctionScopes[e];
1476 }
1477 return nullptr;
1478}
1479
1480LambdaScopeInfo *Sema::getCurLambda(bool IgnoreNonLambdaCapturingScope) {
1481 if (FunctionScopes.empty())
1482 return nullptr;
1483
1484 auto I = FunctionScopes.rbegin();
1485 if (IgnoreNonLambdaCapturingScope) {
1486 auto E = FunctionScopes.rend();
1487 while (I != E && isa<CapturingScopeInfo>(*I) && !isa<LambdaScopeInfo>(*I))
1488 ++I;
1489 if (I == E)
1490 return nullptr;
1491 }
1492 auto *CurLSI = dyn_cast<LambdaScopeInfo>(*I);
1493 if (CurLSI && CurLSI->Lambda &&
1494 !CurLSI->Lambda->Encloses(CurContext)) {
1495 // We have switched contexts due to template instantiation.
1496 assert(!CodeSynthesisContexts.empty())(static_cast <bool> (!CodeSynthesisContexts.empty()) ? void
(0) : __assert_fail ("!CodeSynthesisContexts.empty()", "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 1496, __extension__ __PRETTY_FUNCTION__))
;
1497 return nullptr;
1498 }
1499
1500 return CurLSI;
1501}
1502// We have a generic lambda if we parsed auto parameters, or we have
1503// an associated template parameter list.
1504LambdaScopeInfo *Sema::getCurGenericLambda() {
1505 if (LambdaScopeInfo *LSI = getCurLambda()) {
1506 return (LSI->AutoTemplateParams.size() ||
1507 LSI->GLTemplateParameterList) ? LSI : nullptr;
1508 }
1509 return nullptr;
1510}
1511
1512
1513void Sema::ActOnComment(SourceRange Comment) {
1514 if (!LangOpts.RetainCommentsFromSystemHeaders &&
1515 SourceMgr.isInSystemHeader(Comment.getBegin()))
1516 return;
1517 RawComment RC(SourceMgr, Comment, LangOpts.CommentOpts, false);
1518 if (RC.isAlmostTrailingComment()) {
1519 SourceRange MagicMarkerRange(Comment.getBegin(),
1520 Comment.getBegin().getLocWithOffset(3));
1521 StringRef MagicMarkerText;
1522 switch (RC.getKind()) {
1523 case RawComment::RCK_OrdinaryBCPL:
1524 MagicMarkerText = "///<";
1525 break;
1526 case RawComment::RCK_OrdinaryC:
1527 MagicMarkerText = "/**<";
1528 break;
1529 default:
1530 llvm_unreachable("if this is an almost Doxygen comment, "::llvm::llvm_unreachable_internal("if this is an almost Doxygen comment, "
"it should be ordinary", "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 1531)
1531 "it should be ordinary")::llvm::llvm_unreachable_internal("if this is an almost Doxygen comment, "
"it should be ordinary", "/build/llvm-toolchain-snapshot-7~svn337103/tools/clang/lib/Sema/Sema.cpp"
, 1531)
;
1532 }
1533 Diag(Comment.getBegin(), diag::warn_not_a_doxygen_trailing_member_comment) <<
1534 FixItHint::CreateReplacement(MagicMarkerRange, MagicMarkerText);
1535 }
1536 Context.addComment(RC);
1537}
1538
1539// Pin this vtable to this file.
1540ExternalSemaSource::~ExternalSemaSource() {}
1541
1542void ExternalSemaSource::ReadMethodPool(Selector Sel) { }
1543void ExternalSemaSource::updateOutOfDateSelector(Selector Sel) { }
1544
1545void ExternalSemaSource::ReadKnownNamespaces(
1546 SmallVectorImpl<NamespaceDecl *> &Namespaces) {
1547}
1548
1549void ExternalSemaSource::ReadUndefinedButUsed(
1550 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {}
1551
1552void ExternalSemaSource::ReadMismatchingDeleteExpressions(llvm::MapVector<
1553 FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &) {}
1554
1555/// Figure out if an expression could be turned into a call.
1556///
1557/// Use this when trying to recover from an error where the programmer may have
1558/// written just the name of a function instead of actually calling it.
1559///
1560/// \param E - The expression to examine.
1561/// \param ZeroArgCallReturnTy - If the expression can be turned into a call
1562/// with no arguments, this parameter is set to the type returned by such a
1563/// call; otherwise, it is set to an empty QualType.
1564/// \param OverloadSet - If the expression is an overloaded function
1565/// name, this parameter is populated with the decls of the various overloads.
1566bool Sema::tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy,
1567 UnresolvedSetImpl &OverloadSet) {
1568 ZeroArgCallReturnTy = QualType();
1569 OverloadSet.clear();
1570
1571 const OverloadExpr *Overloads = nullptr;
1572 bool IsMemExpr = false;
1573 if (E.getType() == Context.OverloadTy) {
1574 OverloadExpr::FindResult FR = OverloadExpr::find(const_cast<Expr*>(&E));
1575
1576 // Ignore overloads that are pointer-to-member constants.
1577 if (FR.HasFormOfMemberPointer)
1578 return false;
1579
1580 Overloads = FR.Expression;
1581 } else if (E.getType() == Context.BoundMemberTy) {
1582 Overloads = dyn_cast<UnresolvedMemberExpr>(E.IgnoreParens());
1583 IsMemExpr = true;
1584 }
1585
1586 bool Ambiguous = false;
1587
1588 if (Overloads) {
1589 for (OverloadExpr::decls_iterator it = Overloads->decls_begin(),
1590 DeclsEnd = Overloads->decls_end(); it != DeclsEnd; ++it) {
1591 OverloadSet.addDecl(*it);
1592
1593 // Check whether the function is a non-template, non-member which takes no
1594 // arguments.
1595 if (IsMemExpr)
1596 continue;
1597 if (const FunctionDecl *OverloadDecl
1598 = dyn_cast<FunctionDecl>((*it)->getUnderlyingDecl())) {
1599 if (OverloadDecl->getMinRequiredArguments() == 0) {
1600 if (!ZeroArgCallReturnTy.isNull() && !Ambiguous) {
1601 ZeroArgCallReturnTy = QualType();
1602 Ambiguous = true;
1603 } else
1604 ZeroArgCallReturnTy = OverloadDecl->getReturnType();
1605 }
1606 }
1607 }
1608
1609 // If it's not a member, use better machinery to try to resolve the call
1610 if (!IsMemExpr)
1611 return !ZeroArgCallReturnTy.isNull();
1612 }
1613
1614 // Attempt to call the member with no arguments - this will correctly handle
1615 // member templates with defaults/deduction of template arguments, overloads
1616 // with default arguments, etc.
1617 if (IsMemExpr && !E.isTypeDependent()) {
1618 bool Suppress = getDiagnostics().getSuppressAllDiagnostics();
1619 getDiagnostics().setSuppressAllDiagnostics(true);
1620 ExprResult R = BuildCallToMemberFunction(nullptr, &E, SourceLocation(),
1621 None, SourceLocation());
1622 getDiagnostics().setSuppressAllDiagnostics(Suppress);
1623 if (R.isUsable()) {
1624 ZeroArgCallReturnTy = R.get()->getType();
1625 return true;
1626 }
1627 return false;
1628 }
1629
1630 if (const DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E.IgnoreParens())) {
1631 if (const FunctionDecl *Fun = dyn_cast<FunctionDecl>(DeclRef->getDecl())) {
1632 if (Fun->getMinRequiredArguments() == 0)
1633 ZeroArgCallReturnTy = Fun->getReturnType();
1634 return true;
1635 }
1636 }
1637
1638 // We don't have an expression that's convenient to get a FunctionDecl from,
1639 // but we can at least check if the type is "function of 0 arguments".
1640 QualType ExprTy = E.getType();
1641 const FunctionType *FunTy = nullptr;
1642 QualType PointeeTy = ExprTy->getPointeeType();
1643 if (!PointeeTy.isNull())
1644 FunTy = PointeeTy->getAs<FunctionType>();
1645 if (!FunTy)
1646 FunTy = ExprTy->getAs<FunctionType>();
1647
1648 if (const FunctionProtoType *FPT =
1649 dyn_cast_or_null<FunctionProtoType>(FunTy)) {
1650 if (FPT->getNumParams() == 0)
1651 ZeroArgCallReturnTy = FunTy->getReturnType();
1652 return true;
1653 }
1654 return false;
1655}
1656
1657/// Give notes for a set of overloads.
1658///
1659/// A companion to tryExprAsCall. In cases when the name that the programmer
1660/// wrote was an overloaded function, we may be able to make some guesses about
1661/// plausible overloads based on their return types; such guesses can be handed
1662/// off to this method to be emitted as notes.
1663///
1664/// \param Overloads - The overloads to note.
1665/// \param FinalNoteLoc - If we've suppressed printing some overloads due to
1666/// -fshow-overloads=best, this is the location to attach to the note about too
1667/// many candidates. Typically this will be the location of the original
1668/// ill-formed expression.
1669static void noteOverloads(Sema &S, const UnresolvedSetImpl &Overloads,
1670 const SourceLocation FinalNoteLoc) {
1671 int ShownOverloads = 0;
1672 int SuppressedOverloads = 0;
1673 for (UnresolvedSetImpl::iterator It = Overloads.begin(),
1674 DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) {
1675 // FIXME: Magic number for max shown overloads stolen from
1676 // OverloadCandidateSet::NoteCandidates.
1677 if (ShownOverloads >= 4 && S.Diags.getShowOverloads() == Ovl_Best) {
1678 ++SuppressedOverloads;
1679 continue;
1680 }
1681
1682 NamedDecl *Fn = (*It)->getUnderlyingDecl();
1683 // Don't print overloads for non-default multiversioned functions.
1684 if (const auto *FD = Fn->getAsFunction()) {
1685 if (FD->isMultiVersion() &&
1686 !FD->getAttr<TargetAttr>()->isDefaultVersion())
1687 continue;
1688 }
1689 S.Diag(Fn->getLocation(), diag::note_possible_target_of_call);
1690 ++ShownOverloads;
1691 }
1692
1693 if (SuppressedOverloads)
1694 S.Diag(FinalNoteLoc, diag::note_ovl_too_many_candidates)
1695 << SuppressedOverloads;
1696}
1697
1698static void notePlausibleOverloads(Sema &S, SourceLocation Loc,
1699 const UnresolvedSetImpl &Overloads,
1700 bool (*IsPlausibleResult)(QualType)) {
1701 if (!IsPlausibleResult)
1702 return noteOverloads(S, Overloads, Loc);
1703
1704 UnresolvedSet<2> PlausibleOverloads;
1705 for (OverloadExpr::decls_iterator It = Overloads.begin(),
1706 DeclsEnd = Overloads.end(); It != DeclsEnd; ++It) {
1707 const FunctionDecl *OverloadDecl = cast<FunctionDecl>(*It);
1708 QualType OverloadResultTy = OverloadDecl->getReturnType();
1709 if (IsPlausibleResult(OverloadResultTy))
1710 PlausibleOverloads.addDecl(It.getDecl());
1711 }
1712 noteOverloads(S, PlausibleOverloads, Loc);
1713}
1714
1715/// Determine whether the given expression can be called by just
1716/// putting parentheses after it. Notably, expressions with unary
1717/// operators can't be because the unary operator will start parsing
1718/// outside the call.
1719static bool IsCallableWithAppend(Expr *E) {
1720 E = E->IgnoreImplicit();
1721 return (!isa<CStyleCastExpr>(E) &&
1722 !isa<UnaryOperator>(E) &&
1723 !isa<BinaryOperator>(E) &&
1724 !isa<CXXOperatorCallExpr>(E));
1725}
1726
1727bool Sema::tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD,
1728 bool ForceComplain,
1729 bool (*IsPlausibleResult)(QualType)) {
1730 SourceLocation Loc = E.get()->getExprLoc();
1731 SourceRange Range = E.get()->getSourceRange();
1732
1733 QualType ZeroArgCallTy;
1734 UnresolvedSet<4> Overloads;
1735 if (tryExprAsCall(*E.get(), ZeroArgCallTy, Overloads) &&
1736 !ZeroArgCallTy.isNull() &&
1737 (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
1738 // At this point, we know E is potentially callable with 0
1739 // arguments and that it returns something of a reasonable type,
1740 // so we can emit a fixit and carry on pretending that E was
1741 // actually a CallExpr.
1742 SourceLocation ParenInsertionLoc = getLocForEndOfToken(Range.getEnd());
1743 Diag(Loc, PD)
1744 << /*zero-arg*/ 1 << Range
1745 << (IsCallableWithAppend(E.get())
1746 ? FixItHint::CreateInsertion(ParenInsertionLoc, "()")
1747 : FixItHint());
1748 notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
1749
1750 // FIXME: Try this before emitting the fixit, and suppress diagnostics
1751 // while doing so.
1752 E = ActOnCallExpr(nullptr, E.get(), Range.getEnd(), None,
1753 Range.getEnd().getLocWithOffset(1));
1754 return true;
1755 }
1756
1757 if (!ForceComplain) return false;
1758
1759 Diag(Loc, PD) << /*not zero-arg*/ 0 << Range;
1760 notePlausibleOverloads(*this, Loc, Overloads, IsPlausibleResult);
1761 E = ExprError();
1762 return true;
1763}
1764
1765IdentifierInfo *Sema::getSuperIdentifier() const {
1766 if (!Ident_super)
1767 Ident_super = &Context.Idents.get("super");
1768 return Ident_super;
1769}
1770
1771IdentifierInfo *Sema::getFloat128Identifier() const {
1772 if (!Ident___float128)
1773 Ident___float128 = &Context.Idents.get("__float128");
1774 return Ident___float128;
1775}
1776
1777void Sema::PushCapturedRegionScope(Scope *S, CapturedDecl *CD, RecordDecl *RD,
1778 CapturedRegionKind K) {
1779 CapturingScopeInfo *CSI = new CapturedRegionScopeInfo(
1780 getDiagnostics(), S, CD, RD, CD->getContextParam(), K,
1781 (getLangOpts().OpenMP && K == CR_OpenMP) ? getOpenMPNestingLevel() : 0);
1782 CSI->ReturnType = Context.VoidTy;
1783 FunctionScopes.push_back(CSI);
1784}
1785
1786CapturedRegionScopeInfo *Sema::getCurCapturedRegion() {
1787 if (FunctionScopes.empty())
1788 return nullptr;
1789
1790 return dyn_cast<CapturedRegionScopeInfo>(FunctionScopes.back());
1791}
1792
1793const llvm::MapVector<FieldDecl *, Sema::DeleteLocs> &
1794Sema::getMismatchingDeleteExpressions() const {
1795 return DeleteExprs;
1796}
1797
1798void Sema::setOpenCLExtensionForType(QualType T, llvm::StringRef ExtStr) {
1799 if (ExtStr.empty())
1800 return;
1801 llvm::SmallVector<StringRef, 1> Exts;
1802 ExtStr.split(Exts, " ", /* limit */ -1, /* keep empty */ false);
1803 auto CanT = T.getCanonicalType().getTypePtr();
1804 for (auto &I : Exts)
1805 OpenCLTypeExtMap[CanT].insert(I.str());
1806}
1807
1808void Sema::setOpenCLExtensionForDecl(Decl *FD, StringRef ExtStr) {
1809 llvm::SmallVector<StringRef, 1> Exts;
1810 ExtStr.split(Exts, " ", /* limit */ -1, /* keep empty */ false);
1811 if (Exts.empty())
1812 return;
1813 for (auto &I : Exts)
1814 OpenCLDeclExtMap[FD].insert(I.str());
1815}
1816
1817void Sema::setCurrentOpenCLExtensionForType(QualType T) {
1818 if (CurrOpenCLExtension.empty())
1819 return;
1820 setOpenCLExtensionForType(T, CurrOpenCLExtension);
1821}
1822
1823void Sema::setCurrentOpenCLExtensionForDecl(Decl *D) {
1824 if (CurrOpenCLExtension.empty())
1825 return;
1826 setOpenCLExtensionForDecl(D, CurrOpenCLExtension);
1827}
1828
1829bool Sema::isOpenCLDisabledDecl(Decl *FD) {
1830 auto Loc = OpenCLDeclExtMap.find(FD);
1831 if (Loc == OpenCLDeclExtMap.end())
1832 return false;
1833 for (auto &I : Loc->second) {
1834 if (!getOpenCLOptions().isEnabled(I))
1835 return true;
1836 }
1837 return false;
1838}
1839
1840template <typename T, typename DiagLocT, typename DiagInfoT, typename MapT>
1841bool Sema::checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc,
1842 DiagInfoT DiagInfo, MapT &Map,
1843 unsigned Selector,
1844 SourceRange SrcRange) {
1845 auto Loc = Map.find(D);
1846 if (Loc == Map.end())
1847 return false;
1848 bool Disabled = false;
1849 for (auto &I : Loc->second) {
1850 if (I != CurrOpenCLExtension && !getOpenCLOptions().isEnabled(I)) {
1851 Diag(DiagLoc, diag::err_opencl_requires_extension) << Selector << DiagInfo
1852 << I << SrcRange;
1853 Disabled = true;
1854 }
1855 }
1856 return Disabled;
1857}
1858
1859bool Sema::checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType QT) {
1860 // Check extensions for declared types.
1861 Decl *Decl = nullptr;
1862 if (auto TypedefT = dyn_cast<TypedefType>(QT.getTypePtr()))
1863 Decl = TypedefT->getDecl();
1864 if (auto TagT = dyn_cast<TagType>(QT.getCanonicalType().getTypePtr()))
1865 Decl = TagT->getDecl();
1866 auto Loc = DS.getTypeSpecTypeLoc();
1867 if (checkOpenCLDisabledTypeOrDecl(Decl, Loc, QT, OpenCLDeclExtMap))
1868 return true;
1869
1870 // Check extensions for builtin types.
1871 return checkOpenCLDisabledTypeOrDecl(QT.getCanonicalType().getTypePtr(), Loc,
1872 QT, OpenCLTypeExtMap);
1873}
1874
1875bool Sema::checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E) {
1876 IdentifierInfo *FnName = D.getIdentifier();
1877 return checkOpenCLDisabledTypeOrDecl(&D, E.getLocStart(), FnName,
1878 OpenCLDeclExtMap, 1, D.getSourceRange());
1879}

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

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