| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | #include "clang/AST/DeclBase.h" |
| 14 | #include "clang/AST/ASTContext.h" |
| 15 | #include "clang/AST/ASTMutationListener.h" |
| 16 | #include "clang/AST/Attr.h" |
| 17 | #include "clang/AST/AttrIterator.h" |
| 18 | #include "clang/AST/Decl.h" |
| 19 | #include "clang/AST/DeclCXX.h" |
| 20 | #include "clang/AST/DeclContextInternals.h" |
| 21 | #include "clang/AST/DeclFriend.h" |
| 22 | #include "clang/AST/DeclObjC.h" |
| 23 | #include "clang/AST/DeclOpenMP.h" |
| 24 | #include "clang/AST/DeclTemplate.h" |
| 25 | #include "clang/AST/DependentDiagnostic.h" |
| 26 | #include "clang/AST/ExternalASTSource.h" |
| 27 | #include "clang/AST/Stmt.h" |
| 28 | #include "clang/AST/Type.h" |
| 29 | #include "clang/Basic/IdentifierTable.h" |
| 30 | #include "clang/Basic/LLVM.h" |
| 31 | #include "clang/Basic/LangOptions.h" |
| 32 | #include "clang/Basic/ObjCRuntime.h" |
| 33 | #include "clang/Basic/PartialDiagnostic.h" |
| 34 | #include "clang/Basic/SourceLocation.h" |
| 35 | #include "clang/Basic/TargetInfo.h" |
| 36 | #include "llvm/ADT/ArrayRef.h" |
| 37 | #include "llvm/ADT/PointerIntPair.h" |
| 38 | #include "llvm/ADT/SmallVector.h" |
| 39 | #include "llvm/ADT/StringRef.h" |
| 40 | #include "llvm/Support/Casting.h" |
| 41 | #include "llvm/Support/ErrorHandling.h" |
| 42 | #include "llvm/Support/MathExtras.h" |
| 43 | #include "llvm/Support/VersionTuple.h" |
| 44 | #include "llvm/Support/raw_ostream.h" |
| 45 | #include <algorithm> |
| 46 | #include <cassert> |
| 47 | #include <cstddef> |
| 48 | #include <string> |
| 49 | #include <tuple> |
| 50 | #include <utility> |
| 51 | |
| 52 | using namespace clang; |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | #define DECL(DERIVED, BASE) static int n##DERIVED##s = 0; |
| 59 | #define ABSTRACT_DECL(DECL) |
| 60 | #include "clang/AST/DeclNodes.inc" |
| 61 | |
| 62 | void Decl::updateOutOfDate(IdentifierInfo &II) const { |
| 63 | getASTContext().getExternalSource()->updateOutOfDateIdentifier(II); |
| 64 | } |
| 65 | |
| 66 | #define DECL(DERIVED, BASE) \ |
| 67 | static_assert(alignof(Decl) >= alignof(DERIVED##Decl), \ |
| 68 | "Alignment sufficient after objects prepended to " #DERIVED); |
| 69 | #define ABSTRACT_DECL(DECL) |
| 70 | #include "clang/AST/DeclNodes.inc" |
| 71 | |
| 72 | void *Decl::operator new(std::size_t Size, const ASTContext &Context, |
| 73 | unsigned ID, std::size_t ) { |
| 74 | |
| 75 | |
| 76 | static_assert(sizeof(unsigned) * 2 >= alignof(Decl), |
| 77 | "Decl won't be misaligned"); |
| 78 | void *Start = Context.Allocate(Size + Extra + 8); |
| 79 | void *Result = (char*)Start + 8; |
| 80 | |
| 81 | unsigned *PrefixPtr = (unsigned *)Result - 2; |
| 82 | |
| 83 | |
| 84 | PrefixPtr[0] = 0; |
| 85 | |
| 86 | |
| 87 | PrefixPtr[1] = ID; |
| 88 | |
| 89 | return Result; |
| 90 | } |
| 91 | |
| 92 | void *Decl::operator new(std::size_t Size, const ASTContext &Ctx, |
| 93 | DeclContext *Parent, std::size_t ) { |
| 94 | getParentASTContext() == &Ctx", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 94, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!Parent || &Parent->getParentASTContext() == &Ctx); |
| 95 | |
| 96 | |
| 97 | |
| 98 | if (Ctx.getLangOpts().trackLocalOwningModule() || !Parent) { |
| 99 | |
| 100 | |
| 101 | size_t = |
| 102 | llvm::OffsetToAlignment(sizeof(Module *), alignof(Decl)); |
| 103 | auto *Buffer = reinterpret_cast<char *>( |
| 104 | ::operator new(ExtraAlign + sizeof(Module *) + Size + Extra, Ctx)); |
| 105 | Buffer += ExtraAlign; |
| 106 | auto *ParentModule = |
| 107 | Parent ? cast<Decl>(Parent)->getOwningModule() : nullptr; |
| 108 | return new (Buffer) Module*(ParentModule) + 1; |
| 109 | } |
| 110 | return ::operator new(Size + Extra, Ctx); |
| 111 | } |
| 112 | |
| 113 | Module *Decl::getOwningModuleSlow() const { |
| 114 | (0) . __assert_fail ("isFromASTFile() && \"Not from AST file?\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 114, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(isFromASTFile() && "Not from AST file?"); |
| 115 | return getASTContext().getExternalSource()->getModule(getOwningModuleID()); |
| 116 | } |
| 117 | |
| 118 | bool Decl::hasLocalOwningModuleStorage() const { |
| 119 | return getASTContext().getLangOpts().trackLocalOwningModule(); |
| 120 | } |
| 121 | |
| 122 | const char *Decl::getDeclKindName() const { |
| 123 | switch (DeclKind) { |
| 124 | default: llvm_unreachable("Declaration not in DeclNodes.inc!"); |
| 125 | #define DECL(DERIVED, BASE) case DERIVED: return #DERIVED; |
| 126 | #define ABSTRACT_DECL(DECL) |
| 127 | #include "clang/AST/DeclNodes.inc" |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | void Decl::setInvalidDecl(bool Invalid) { |
| 132 | InvalidDecl = Invalid; |
| 133 | (this) || !cast(this)->isCompleteDefinition()", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 133, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!isa<TagDecl>(this) || !cast<TagDecl>(this)->isCompleteDefinition()); |
| 134 | if (!Invalid) { |
| 135 | return; |
| 136 | } |
| 137 | |
| 138 | if (!isa<ParmVarDecl>(this)) { |
| 139 | |
| 140 | |
| 141 | |
| 142 | setAccess(AS_public); |
| 143 | } |
| 144 | |
| 145 | |
| 146 | |
| 147 | if (auto *DD = dyn_cast<DecompositionDecl>(this)) { |
| 148 | for (auto *Binding : DD->bindings()) { |
| 149 | Binding->setInvalidDecl(); |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | const char *DeclContext::getDeclKindName() const { |
| 155 | switch (getDeclKind()) { |
| 156 | #define DECL(DERIVED, BASE) case Decl::DERIVED: return #DERIVED; |
| 157 | #define ABSTRACT_DECL(DECL) |
| 158 | #include "clang/AST/DeclNodes.inc" |
| 159 | } |
| 160 | llvm_unreachable("Declaration context not in DeclNodes.inc!"); |
| 161 | } |
| 162 | |
| 163 | bool Decl::StatisticsEnabled = false; |
| 164 | void Decl::EnableStatistics() { |
| 165 | StatisticsEnabled = true; |
| 166 | } |
| 167 | |
| 168 | void Decl::PrintStats() { |
| 169 | llvm::errs() << "\n*** Decl Stats:\n"; |
| 170 | |
| 171 | int totalDecls = 0; |
| 172 | #define DECL(DERIVED, BASE) totalDecls += n##DERIVED##s; |
| 173 | #define ABSTRACT_DECL(DECL) |
| 174 | #include "clang/AST/DeclNodes.inc" |
| 175 | llvm::errs() << " " << totalDecls << " decls total.\n"; |
| 176 | |
| 177 | int totalBytes = 0; |
| 178 | #define DECL(DERIVED, BASE) \ |
| 179 | if (n##DERIVED##s > 0) { \ |
| 180 | totalBytes += (int)(n##DERIVED##s * sizeof(DERIVED##Decl)); \ |
| 181 | llvm::errs() << " " << n##DERIVED##s << " " #DERIVED " decls, " \ |
| 182 | << sizeof(DERIVED##Decl) << " each (" \ |
| 183 | << n##DERIVED##s * sizeof(DERIVED##Decl) \ |
| 184 | << " bytes)\n"; \ |
| 185 | } |
| 186 | #define ABSTRACT_DECL(DECL) |
| 187 | #include "clang/AST/DeclNodes.inc" |
| 188 | |
| 189 | llvm::errs() << "Total bytes = " << totalBytes << "\n"; |
| 190 | } |
| 191 | |
| 192 | void Decl::add(Kind k) { |
| 193 | switch (k) { |
| 194 | #define DECL(DERIVED, BASE) case DERIVED: ++n##DERIVED##s; break; |
| 195 | #define ABSTRACT_DECL(DECL) |
| 196 | #include "clang/AST/DeclNodes.inc" |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | bool Decl::isTemplateParameterPack() const { |
| 201 | if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(this)) |
| 202 | return TTP->isParameterPack(); |
| 203 | if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(this)) |
| 204 | return NTTP->isParameterPack(); |
| 205 | if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(this)) |
| 206 | return TTP->isParameterPack(); |
| 207 | return false; |
| 208 | } |
| 209 | |
| 210 | bool Decl::isParameterPack() const { |
| 211 | if (const auto *Parm = dyn_cast<ParmVarDecl>(this)) |
| 212 | return Parm->isParameterPack(); |
| 213 | |
| 214 | return isTemplateParameterPack(); |
| 215 | } |
| 216 | |
| 217 | FunctionDecl *Decl::getAsFunction() { |
| 218 | if (auto *FD = dyn_cast<FunctionDecl>(this)) |
| 219 | return FD; |
| 220 | if (const auto *FTD = dyn_cast<FunctionTemplateDecl>(this)) |
| 221 | return FTD->getTemplatedDecl(); |
| 222 | return nullptr; |
| 223 | } |
| 224 | |
| 225 | bool Decl::isTemplateDecl() const { |
| 226 | return isa<TemplateDecl>(this); |
| 227 | } |
| 228 | |
| 229 | TemplateDecl *Decl::getDescribedTemplate() const { |
| 230 | if (auto *FD = dyn_cast<FunctionDecl>(this)) |
| 231 | return FD->getDescribedFunctionTemplate(); |
| 232 | else if (auto *RD = dyn_cast<CXXRecordDecl>(this)) |
| 233 | return RD->getDescribedClassTemplate(); |
| 234 | else if (auto *VD = dyn_cast<VarDecl>(this)) |
| 235 | return VD->getDescribedVarTemplate(); |
| 236 | else if (auto *AD = dyn_cast<TypeAliasDecl>(this)) |
| 237 | return AD->getDescribedAliasTemplate(); |
| 238 | |
| 239 | return nullptr; |
| 240 | } |
| 241 | |
| 242 | bool Decl::isTemplated() const { |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | if (auto *AsDC = dyn_cast<DeclContext>(this)) |
| 248 | return AsDC->isDependentContext(); |
| 249 | auto *DC = getFriendObjectKind() ? getLexicalDeclContext() : getDeclContext(); |
| 250 | return DC->isDependentContext() || isTemplateDecl() || getDescribedTemplate(); |
| 251 | } |
| 252 | |
| 253 | const DeclContext *Decl::getParentFunctionOrMethod() const { |
| 254 | for (const DeclContext *DC = getDeclContext(); |
| 255 | DC && !DC->isTranslationUnit() && !DC->isNamespace(); |
| 256 | DC = DC->getParent()) |
| 257 | if (DC->isFunctionOrMethod()) |
| 258 | return DC; |
| 259 | |
| 260 | return nullptr; |
| 261 | } |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | void PrettyStackTraceDecl::print(raw_ostream &OS) const { |
| 268 | SourceLocation TheLoc = Loc; |
| 269 | if (TheLoc.isInvalid() && TheDecl) |
| 270 | TheLoc = TheDecl->getLocation(); |
| 271 | |
| 272 | if (TheLoc.isValid()) { |
| 273 | TheLoc.print(OS, SM); |
| 274 | OS << ": "; |
| 275 | } |
| 276 | |
| 277 | OS << Message; |
| 278 | |
| 279 | if (const auto *DN = dyn_cast_or_null<NamedDecl>(TheDecl)) { |
| 280 | OS << " '"; |
| 281 | DN->printQualifiedName(OS); |
| 282 | OS << '\''; |
| 283 | } |
| 284 | OS << '\n'; |
| 285 | } |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | Decl::~Decl() = default; |
| 293 | |
| 294 | void Decl::setDeclContext(DeclContext *DC) { |
| 295 | DeclCtx = DC; |
| 296 | } |
| 297 | |
| 298 | void Decl::setLexicalDeclContext(DeclContext *DC) { |
| 299 | if (DC == getLexicalDeclContext()) |
| 300 | return; |
| 301 | |
| 302 | if (isInSemaDC()) { |
| 303 | setDeclContextsImpl(getDeclContext(), DC, getASTContext()); |
| 304 | } else { |
| 305 | getMultipleDC()->LexicalDC = DC; |
| 306 | } |
| 307 | |
| 308 | |
| 309 | |
| 310 | if (!isFromASTFile()) { |
| 311 | setModuleOwnershipKind(getModuleOwnershipKindForChildOf(DC)); |
| 312 | if (hasOwningModule()) |
| 313 | setLocalOwningModule(cast<Decl>(DC)->getOwningModule()); |
| 314 | } |
| 315 | |
| 316 | (0) . __assert_fail ("(getModuleOwnershipKind() != ModuleOwnershipKind..VisibleWhenImported || getOwningModule()) && \"hidden declaration has no owning module\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 319, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert( |
| 317 | (0) . __assert_fail ("(getModuleOwnershipKind() != ModuleOwnershipKind..VisibleWhenImported || getOwningModule()) && \"hidden declaration has no owning module\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 319, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> (getModuleOwnershipKind() != ModuleOwnershipKind::VisibleWhenImported || |
| 318 | (0) . __assert_fail ("(getModuleOwnershipKind() != ModuleOwnershipKind..VisibleWhenImported || getOwningModule()) && \"hidden declaration has no owning module\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 319, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> getOwningModule()) && |
| 319 | (0) . __assert_fail ("(getModuleOwnershipKind() != ModuleOwnershipKind..VisibleWhenImported || getOwningModule()) && \"hidden declaration has no owning module\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 319, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "hidden declaration has no owning module"); |
| 320 | } |
| 321 | |
| 322 | void Decl::setDeclContextsImpl(DeclContext *SemaDC, DeclContext *LexicalDC, |
| 323 | ASTContext &Ctx) { |
| 324 | if (SemaDC == LexicalDC) { |
| 325 | DeclCtx = SemaDC; |
| 326 | } else { |
| 327 | auto *MDC = new (Ctx) Decl::MultipleDC(); |
| 328 | MDC->SemanticDC = SemaDC; |
| 329 | MDC->LexicalDC = LexicalDC; |
| 330 | DeclCtx = MDC; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | bool Decl::isLexicallyWithinFunctionOrMethod() const { |
| 335 | const DeclContext *LDC = getLexicalDeclContext(); |
| 336 | while (true) { |
| 337 | if (LDC->isFunctionOrMethod()) |
| 338 | return true; |
| 339 | if (!isa<TagDecl>(LDC)) |
| 340 | return false; |
| 341 | LDC = LDC->getLexicalParent(); |
| 342 | } |
| 343 | return false; |
| 344 | } |
| 345 | |
| 346 | bool Decl::isInAnonymousNamespace() const { |
| 347 | for (const DeclContext *DC = getDeclContext(); DC; DC = DC->getParent()) { |
| 348 | if (const auto *ND = dyn_cast<NamespaceDecl>(DC)) |
| 349 | if (ND->isAnonymousNamespace()) |
| 350 | return true; |
| 351 | } |
| 352 | |
| 353 | return false; |
| 354 | } |
| 355 | |
| 356 | bool Decl::isInStdNamespace() const { |
| 357 | return getDeclContext()->isStdNamespace(); |
| 358 | } |
| 359 | |
| 360 | TranslationUnitDecl *Decl::getTranslationUnitDecl() { |
| 361 | if (auto *TUD = dyn_cast<TranslationUnitDecl>(this)) |
| 362 | return TUD; |
| 363 | |
| 364 | DeclContext *DC = getDeclContext(); |
| 365 | (0) . __assert_fail ("DC && \"This decl is not contained in a translation unit!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 365, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(DC && "This decl is not contained in a translation unit!"); |
| 366 | |
| 367 | while (!DC->isTranslationUnit()) { |
| 368 | DC = DC->getParent(); |
| 369 | (0) . __assert_fail ("DC && \"This decl is not contained in a translation unit!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 369, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(DC && "This decl is not contained in a translation unit!"); |
| 370 | } |
| 371 | |
| 372 | return cast<TranslationUnitDecl>(DC); |
| 373 | } |
| 374 | |
| 375 | ASTContext &Decl::getASTContext() const { |
| 376 | return getTranslationUnitDecl()->getASTContext(); |
| 377 | } |
| 378 | |
| 379 | ASTMutationListener *Decl::getASTMutationListener() const { |
| 380 | return getASTContext().getASTMutationListener(); |
| 381 | } |
| 382 | |
| 383 | unsigned Decl::getMaxAlignment() const { |
| 384 | if (!hasAttrs()) |
| 385 | return 0; |
| 386 | |
| 387 | unsigned Align = 0; |
| 388 | const AttrVec &V = getAttrs(); |
| 389 | ASTContext &Ctx = getASTContext(); |
| 390 | specific_attr_iterator<AlignedAttr> I(V.begin()), E(V.end()); |
| 391 | for (; I != E; ++I) |
| 392 | Align = std::max(Align, I->getAlignment(Ctx)); |
| 393 | return Align; |
| 394 | } |
| 395 | |
| 396 | bool Decl::isUsed(bool CheckUsedAttr) const { |
| 397 | const Decl *CanonD = getCanonicalDecl(); |
| 398 | if (CanonD->Used) |
| 399 | return true; |
| 400 | |
| 401 | |
| 402 | |
| 403 | if (CheckUsedAttr && getMostRecentDecl()->hasAttr<UsedAttr>()) |
| 404 | return true; |
| 405 | |
| 406 | |
| 407 | |
| 408 | return getMostRecentDecl()->getCanonicalDecl()->Used; |
| 409 | } |
| 410 | |
| 411 | void Decl::markUsed(ASTContext &C) { |
| 412 | if (isUsed(false)) |
| 413 | return; |
| 414 | |
| 415 | if (C.getASTMutationListener()) |
| 416 | C.getASTMutationListener()->DeclarationMarkedUsed(this); |
| 417 | |
| 418 | setIsUsed(); |
| 419 | } |
| 420 | |
| 421 | bool Decl::isReferenced() const { |
| 422 | if (Referenced) |
| 423 | return true; |
| 424 | |
| 425 | |
| 426 | for (const auto *I : redecls()) |
| 427 | if (I->Referenced) |
| 428 | return true; |
| 429 | |
| 430 | return false; |
| 431 | } |
| 432 | |
| 433 | bool Decl::isExported() const { |
| 434 | if (isModulePrivate()) |
| 435 | return false; |
| 436 | |
| 437 | if (isa<TranslationUnitDecl>(this) || isa<NamespaceDecl>(this)) |
| 438 | return true; |
| 439 | |
| 440 | for (auto *DC = getLexicalDeclContext(); DC; DC = DC->getLexicalParent()) { |
| 441 | if (cast<Decl>(DC)->isModulePrivate()) |
| 442 | return false; |
| 443 | if (isa<ExportDecl>(DC)) |
| 444 | return true; |
| 445 | } |
| 446 | return false; |
| 447 | } |
| 448 | |
| 449 | ExternalSourceSymbolAttr *Decl::getExternalSourceSymbolAttr() const { |
| 450 | const Decl *Definition = nullptr; |
| 451 | if (auto *ID = dyn_cast<ObjCInterfaceDecl>(this)) { |
| 452 | Definition = ID->getDefinition(); |
| 453 | } else if (auto *PD = dyn_cast<ObjCProtocolDecl>(this)) { |
| 454 | Definition = PD->getDefinition(); |
| 455 | } else if (auto *TD = dyn_cast<TagDecl>(this)) { |
| 456 | Definition = TD->getDefinition(); |
| 457 | } |
| 458 | if (!Definition) |
| 459 | Definition = this; |
| 460 | |
| 461 | if (auto *attr = Definition->getAttr<ExternalSourceSymbolAttr>()) |
| 462 | return attr; |
| 463 | if (auto *dcd = dyn_cast<Decl>(getDeclContext())) { |
| 464 | return dcd->getAttr<ExternalSourceSymbolAttr>(); |
| 465 | } |
| 466 | |
| 467 | return nullptr; |
| 468 | } |
| 469 | |
| 470 | bool Decl::hasDefiningAttr() const { |
| 471 | return hasAttr<AliasAttr>() || hasAttr<IFuncAttr>(); |
| 472 | } |
| 473 | |
| 474 | const Attr *Decl::getDefiningAttr() const { |
| 475 | if (auto *AA = getAttr<AliasAttr>()) |
| 476 | return AA; |
| 477 | if (auto *IFA = getAttr<IFuncAttr>()) |
| 478 | return IFA; |
| 479 | return nullptr; |
| 480 | } |
| 481 | |
| 482 | static StringRef getRealizedPlatform(const AvailabilityAttr *A, |
| 483 | const ASTContext &Context) { |
| 484 | |
| 485 | |
| 486 | StringRef RealizedPlatform = A->getPlatform()->getName(); |
| 487 | if (!Context.getLangOpts().AppExt) |
| 488 | return RealizedPlatform; |
| 489 | size_t suffix = RealizedPlatform.rfind("_app_extension"); |
| 490 | if (suffix != StringRef::npos) |
| 491 | return RealizedPlatform.slice(0, suffix); |
| 492 | return RealizedPlatform; |
| 493 | } |
| 494 | |
| 495 | |
| 496 | |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | |
| 502 | |
| 503 | |
| 504 | static AvailabilityResult CheckAvailability(ASTContext &Context, |
| 505 | const AvailabilityAttr *A, |
| 506 | std::string *Message, |
| 507 | VersionTuple EnclosingVersion) { |
| 508 | if (EnclosingVersion.empty()) |
| 509 | EnclosingVersion = Context.getTargetInfo().getPlatformMinVersion(); |
| 510 | |
| 511 | if (EnclosingVersion.empty()) |
| 512 | return AR_Available; |
| 513 | |
| 514 | StringRef ActualPlatform = A->getPlatform()->getName(); |
| 515 | StringRef TargetPlatform = Context.getTargetInfo().getPlatformName(); |
| 516 | |
| 517 | |
| 518 | if (getRealizedPlatform(A, Context) != TargetPlatform) |
| 519 | return AR_Available; |
| 520 | |
| 521 | StringRef PrettyPlatformName |
| 522 | = AvailabilityAttr::getPrettyPlatformName(ActualPlatform); |
| 523 | |
| 524 | if (PrettyPlatformName.empty()) |
| 525 | PrettyPlatformName = ActualPlatform; |
| 526 | |
| 527 | std::string HintMessage; |
| 528 | if (!A->getMessage().empty()) { |
| 529 | HintMessage = " - "; |
| 530 | HintMessage += A->getMessage(); |
| 531 | } |
| 532 | |
| 533 | |
| 534 | if (A->getUnavailable()) { |
| 535 | if (Message) { |
| 536 | Message->clear(); |
| 537 | llvm::raw_string_ostream Out(*Message); |
| 538 | Out << "not available on " << PrettyPlatformName |
| 539 | << HintMessage; |
| 540 | } |
| 541 | |
| 542 | return AR_Unavailable; |
| 543 | } |
| 544 | |
| 545 | |
| 546 | if (!A->getIntroduced().empty() && |
| 547 | EnclosingVersion < A->getIntroduced()) { |
| 548 | if (Message) { |
| 549 | Message->clear(); |
| 550 | llvm::raw_string_ostream Out(*Message); |
| 551 | VersionTuple VTI(A->getIntroduced()); |
| 552 | Out << "introduced in " << PrettyPlatformName << ' ' |
| 553 | << VTI << HintMessage; |
| 554 | } |
| 555 | |
| 556 | return A->getStrict() ? AR_Unavailable : AR_NotYetIntroduced; |
| 557 | } |
| 558 | |
| 559 | |
| 560 | if (!A->getObsoleted().empty() && EnclosingVersion >= A->getObsoleted()) { |
| 561 | if (Message) { |
| 562 | Message->clear(); |
| 563 | llvm::raw_string_ostream Out(*Message); |
| 564 | VersionTuple VTO(A->getObsoleted()); |
| 565 | Out << "obsoleted in " << PrettyPlatformName << ' ' |
| 566 | << VTO << HintMessage; |
| 567 | } |
| 568 | |
| 569 | return AR_Unavailable; |
| 570 | } |
| 571 | |
| 572 | |
| 573 | if (!A->getDeprecated().empty() && EnclosingVersion >= A->getDeprecated()) { |
| 574 | if (Message) { |
| 575 | Message->clear(); |
| 576 | llvm::raw_string_ostream Out(*Message); |
| 577 | VersionTuple VTD(A->getDeprecated()); |
| 578 | Out << "first deprecated in " << PrettyPlatformName << ' ' |
| 579 | << VTD << HintMessage; |
| 580 | } |
| 581 | |
| 582 | return AR_Deprecated; |
| 583 | } |
| 584 | |
| 585 | return AR_Available; |
| 586 | } |
| 587 | |
| 588 | AvailabilityResult Decl::getAvailability(std::string *Message, |
| 589 | VersionTuple EnclosingVersion, |
| 590 | StringRef *RealizedPlatform) const { |
| 591 | if (auto *FTD = dyn_cast<FunctionTemplateDecl>(this)) |
| 592 | return FTD->getTemplatedDecl()->getAvailability(Message, EnclosingVersion, |
| 593 | RealizedPlatform); |
| 594 | |
| 595 | AvailabilityResult Result = AR_Available; |
| 596 | std::string ResultMessage; |
| 597 | |
| 598 | for (const auto *A : attrs()) { |
| 599 | if (const auto *Deprecated = dyn_cast<DeprecatedAttr>(A)) { |
| 600 | if (Result >= AR_Deprecated) |
| 601 | continue; |
| 602 | |
| 603 | if (Message) |
| 604 | ResultMessage = Deprecated->getMessage(); |
| 605 | |
| 606 | Result = AR_Deprecated; |
| 607 | continue; |
| 608 | } |
| 609 | |
| 610 | if (const auto *Unavailable = dyn_cast<UnavailableAttr>(A)) { |
| 611 | if (Message) |
| 612 | *Message = Unavailable->getMessage(); |
| 613 | return AR_Unavailable; |
| 614 | } |
| 615 | |
| 616 | if (const auto *Availability = dyn_cast<AvailabilityAttr>(A)) { |
| 617 | AvailabilityResult AR = CheckAvailability(getASTContext(), Availability, |
| 618 | Message, EnclosingVersion); |
| 619 | |
| 620 | if (AR == AR_Unavailable) { |
| 621 | if (RealizedPlatform) |
| 622 | *RealizedPlatform = Availability->getPlatform()->getName(); |
| 623 | return AR_Unavailable; |
| 624 | } |
| 625 | |
| 626 | if (AR > Result) { |
| 627 | Result = AR; |
| 628 | if (Message) |
| 629 | ResultMessage.swap(*Message); |
| 630 | } |
| 631 | continue; |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | if (Message) |
| 636 | Message->swap(ResultMessage); |
| 637 | return Result; |
| 638 | } |
| 639 | |
| 640 | VersionTuple Decl::getVersionIntroduced() const { |
| 641 | const ASTContext &Context = getASTContext(); |
| 642 | StringRef TargetPlatform = Context.getTargetInfo().getPlatformName(); |
| 643 | for (const auto *A : attrs()) { |
| 644 | if (const auto *Availability = dyn_cast<AvailabilityAttr>(A)) { |
| 645 | if (getRealizedPlatform(Availability, Context) != TargetPlatform) |
| 646 | continue; |
| 647 | if (!Availability->getIntroduced().empty()) |
| 648 | return Availability->getIntroduced(); |
| 649 | } |
| 650 | } |
| 651 | return {}; |
| 652 | } |
| 653 | |
| 654 | bool Decl::canBeWeakImported(bool &IsDefinition) const { |
| 655 | IsDefinition = false; |
| 656 | |
| 657 | |
| 658 | if (const auto *Var = dyn_cast<VarDecl>(this)) { |
| 659 | if (Var->isThisDeclarationADefinition()) { |
| 660 | IsDefinition = true; |
| 661 | return false; |
| 662 | } |
| 663 | return true; |
| 664 | |
| 665 | |
| 666 | } else if (const auto *FD = dyn_cast<FunctionDecl>(this)) { |
| 667 | if (FD->hasBody()) { |
| 668 | IsDefinition = true; |
| 669 | return false; |
| 670 | } |
| 671 | return true; |
| 672 | |
| 673 | |
| 674 | } else if (isa<ObjCInterfaceDecl>(this) && |
| 675 | getASTContext().getLangOpts().ObjCRuntime.hasWeakClassImport()) { |
| 676 | return true; |
| 677 | |
| 678 | |
| 679 | } else { |
| 680 | return false; |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | bool Decl::isWeakImported() const { |
| 685 | bool IsDefinition; |
| 686 | if (!canBeWeakImported(IsDefinition)) |
| 687 | return false; |
| 688 | |
| 689 | for (const auto *A : attrs()) { |
| 690 | if (isa<WeakImportAttr>(A)) |
| 691 | return true; |
| 692 | |
| 693 | if (const auto *Availability = dyn_cast<AvailabilityAttr>(A)) { |
| 694 | if (CheckAvailability(getASTContext(), Availability, nullptr, |
| 695 | VersionTuple()) == AR_NotYetIntroduced) |
| 696 | return true; |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | return false; |
| 701 | } |
| 702 | |
| 703 | unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) { |
| 704 | switch (DeclKind) { |
| 705 | case Function: |
| 706 | case CXXDeductionGuide: |
| 707 | case CXXMethod: |
| 708 | case CXXConstructor: |
| 709 | case ConstructorUsingShadow: |
| 710 | case CXXDestructor: |
| 711 | case CXXConversion: |
| 712 | case EnumConstant: |
| 713 | case Var: |
| 714 | case ImplicitParam: |
| 715 | case ParmVar: |
| 716 | case ObjCMethod: |
| 717 | case ObjCProperty: |
| 718 | case MSProperty: |
| 719 | return IDNS_Ordinary; |
| 720 | case Label: |
| 721 | return IDNS_Label; |
| 722 | case IndirectField: |
| 723 | return IDNS_Ordinary | IDNS_Member; |
| 724 | |
| 725 | case Binding: |
| 726 | case NonTypeTemplateParm: |
| 727 | case VarTemplate: |
| 728 | |
| 729 | |
| 730 | return IDNS_Ordinary | IDNS_Tag; |
| 731 | |
| 732 | case ObjCCompatibleAlias: |
| 733 | case ObjCInterface: |
| 734 | return IDNS_Ordinary | IDNS_Type; |
| 735 | |
| 736 | case Typedef: |
| 737 | case TypeAlias: |
| 738 | case TemplateTypeParm: |
| 739 | case ObjCTypeParam: |
| 740 | return IDNS_Ordinary | IDNS_Type; |
| 741 | |
| 742 | case UnresolvedUsingTypename: |
| 743 | return IDNS_Ordinary | IDNS_Type | IDNS_Using; |
| 744 | |
| 745 | case UsingShadow: |
| 746 | return 0; |
| 747 | |
| 748 | case UnresolvedUsingValue: |
| 749 | return IDNS_Ordinary | IDNS_Using; |
| 750 | |
| 751 | case Using: |
| 752 | case UsingPack: |
| 753 | return IDNS_Using; |
| 754 | |
| 755 | case ObjCProtocol: |
| 756 | return IDNS_ObjCProtocol; |
| 757 | |
| 758 | case Field: |
| 759 | case ObjCAtDefsField: |
| 760 | case ObjCIvar: |
| 761 | return IDNS_Member; |
| 762 | |
| 763 | case Record: |
| 764 | case CXXRecord: |
| 765 | case Enum: |
| 766 | return IDNS_Tag | IDNS_Type; |
| 767 | |
| 768 | case Namespace: |
| 769 | case NamespaceAlias: |
| 770 | return IDNS_Namespace; |
| 771 | |
| 772 | case FunctionTemplate: |
| 773 | return IDNS_Ordinary; |
| 774 | |
| 775 | case ClassTemplate: |
| 776 | case TemplateTemplateParm: |
| 777 | case TypeAliasTemplate: |
| 778 | return IDNS_Ordinary | IDNS_Tag | IDNS_Type; |
| 779 | |
| 780 | case OMPDeclareReduction: |
| 781 | return IDNS_OMPReduction; |
| 782 | |
| 783 | case OMPDeclareMapper: |
| 784 | return IDNS_OMPMapper; |
| 785 | |
| 786 | |
| 787 | case Friend: |
| 788 | case FriendTemplate: |
| 789 | case AccessSpec: |
| 790 | case LinkageSpec: |
| 791 | case Export: |
| 792 | case FileScopeAsm: |
| 793 | case StaticAssert: |
| 794 | case ObjCPropertyImpl: |
| 795 | case PragmaComment: |
| 796 | case PragmaDetectMismatch: |
| 797 | case Block: |
| 798 | case Captured: |
| 799 | case TranslationUnit: |
| 800 | case ExternCContext: |
| 801 | case Decomposition: |
| 802 | |
| 803 | case UsingDirective: |
| 804 | case BuiltinTemplate: |
| 805 | case ClassTemplateSpecialization: |
| 806 | case ClassTemplatePartialSpecialization: |
| 807 | case ClassScopeFunctionSpecialization: |
| 808 | case VarTemplateSpecialization: |
| 809 | case VarTemplatePartialSpecialization: |
| 810 | case ObjCImplementation: |
| 811 | case ObjCCategory: |
| 812 | case ObjCCategoryImpl: |
| 813 | case Import: |
| 814 | case OMPThreadPrivate: |
| 815 | case OMPAllocate: |
| 816 | case OMPRequires: |
| 817 | case OMPCapturedExpr: |
| 818 | case Empty: |
| 819 | |
| 820 | return 0; |
| 821 | } |
| 822 | |
| 823 | llvm_unreachable("Invalid DeclKind!"); |
| 824 | } |
| 825 | |
| 826 | void Decl::setAttrsImpl(const AttrVec &attrs, ASTContext &Ctx) { |
| 827 | (0) . __assert_fail ("!HasAttrs && \"Decl already contains attrs.\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 827, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!HasAttrs && "Decl already contains attrs."); |
| 828 | |
| 829 | AttrVec &AttrBlank = Ctx.getDeclAttrs(this); |
| 830 | (0) . __assert_fail ("AttrBlank.empty() && \"HasAttrs was wrong?\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 830, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(AttrBlank.empty() && "HasAttrs was wrong?"); |
| 831 | |
| 832 | AttrBlank = attrs; |
| 833 | HasAttrs = true; |
| 834 | } |
| 835 | |
| 836 | void Decl::dropAttrs() { |
| 837 | if (!HasAttrs) return; |
| 838 | |
| 839 | HasAttrs = false; |
| 840 | getASTContext().eraseDeclAttrs(this); |
| 841 | } |
| 842 | |
| 843 | void Decl::addAttr(Attr *A) { |
| 844 | if (!hasAttrs()) { |
| 845 | setAttrs(AttrVec(1, A)); |
| 846 | return; |
| 847 | } |
| 848 | |
| 849 | AttrVec &Attrs = getAttrs(); |
| 850 | if (!A->isInherited()) { |
| 851 | Attrs.push_back(A); |
| 852 | return; |
| 853 | } |
| 854 | |
| 855 | |
| 856 | |
| 857 | |
| 858 | auto I = Attrs.begin(), E = Attrs.end(); |
| 859 | for (; I != E; ++I) { |
| 860 | if (!(*I)->isInherited()) |
| 861 | break; |
| 862 | } |
| 863 | Attrs.insert(I, A); |
| 864 | } |
| 865 | |
| 866 | const AttrVec &Decl::getAttrs() const { |
| 867 | (0) . __assert_fail ("HasAttrs && \"No attrs to get!\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 867, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(HasAttrs && "No attrs to get!"); |
| 868 | return getASTContext().getDeclAttrs(this); |
| 869 | } |
| 870 | |
| 871 | Decl *Decl::castFromDeclContext (const DeclContext *D) { |
| 872 | Decl::Kind DK = D->getDeclKind(); |
| 873 | switch(DK) { |
| 874 | #define DECL(NAME, BASE) |
| 875 | #define DECL_CONTEXT(NAME) \ |
| 876 | case Decl::NAME: \ |
| 877 | return static_cast<NAME##Decl *>(const_cast<DeclContext *>(D)); |
| 878 | #define DECL_CONTEXT_BASE(NAME) |
| 879 | #include "clang/AST/DeclNodes.inc" |
| 880 | default: |
| 881 | #define DECL(NAME, BASE) |
| 882 | #define DECL_CONTEXT_BASE(NAME) \ |
| 883 | if (DK >= first##NAME && DK <= last##NAME) \ |
| 884 | return static_cast<NAME##Decl *>(const_cast<DeclContext *>(D)); |
| 885 | #include "clang/AST/DeclNodes.inc" |
| 886 | llvm_unreachable("a decl that inherits DeclContext isn't handled"); |
| 887 | } |
| 888 | } |
| 889 | |
| 890 | DeclContext *Decl::castToDeclContext(const Decl *D) { |
| 891 | Decl::Kind DK = D->getKind(); |
| 892 | switch(DK) { |
| 893 | #define DECL(NAME, BASE) |
| 894 | #define DECL_CONTEXT(NAME) \ |
| 895 | case Decl::NAME: \ |
| 896 | return static_cast<NAME##Decl *>(const_cast<Decl *>(D)); |
| 897 | #define DECL_CONTEXT_BASE(NAME) |
| 898 | #include "clang/AST/DeclNodes.inc" |
| 899 | default: |
| 900 | #define DECL(NAME, BASE) |
| 901 | #define DECL_CONTEXT_BASE(NAME) \ |
| 902 | if (DK >= first##NAME && DK <= last##NAME) \ |
| 903 | return static_cast<NAME##Decl *>(const_cast<Decl *>(D)); |
| 904 | #include "clang/AST/DeclNodes.inc" |
| 905 | llvm_unreachable("a decl that inherits DeclContext isn't handled"); |
| 906 | } |
| 907 | } |
| 908 | |
| 909 | SourceLocation Decl::getBodyRBrace() const { |
| 910 | |
| 911 | |
| 912 | if (const auto *FD = dyn_cast<FunctionDecl>(this)) { |
| 913 | const FunctionDecl *Definition; |
| 914 | if (FD->hasBody(Definition)) |
| 915 | return Definition->getSourceRange().getEnd(); |
| 916 | return {}; |
| 917 | } |
| 918 | |
| 919 | if (Stmt *Body = getBody()) |
| 920 | return Body->getSourceRange().getEnd(); |
| 921 | |
| 922 | return {}; |
| 923 | } |
| 924 | |
| 925 | bool Decl::AccessDeclContextSanity() const { |
| 926 | #ifndef NDEBUG |
| 927 | |
| 928 | |
| 929 | |
| 930 | |
| 931 | |
| 932 | |
| 933 | |
| 934 | |
| 935 | if (isa<TranslationUnitDecl>(this) || |
| 936 | isa<TemplateTypeParmDecl>(this) || |
| 937 | isa<NonTypeTemplateParmDecl>(this) || |
| 938 | !isa<CXXRecordDecl>(getDeclContext()) || |
| 939 | isInvalidDecl() || |
| 940 | isa<StaticAssertDecl>(this) || |
| 941 | isa<BlockDecl>(this) || |
| 942 | |
| 943 | |
| 944 | isa<ParmVarDecl>(this) || |
| 945 | |
| 946 | |
| 947 | isa<CXXRecordDecl>(this) || |
| 948 | isa<ClassScopeFunctionSpecializationDecl>(this)) |
| 949 | return true; |
| 950 | |
| 951 | (0) . __assert_fail ("Access != AS_none && \"Access specifier is AS_none inside a record decl\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 952, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Access != AS_none && |
| 952 | (0) . __assert_fail ("Access != AS_none && \"Access specifier is AS_none inside a record decl\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 952, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Access specifier is AS_none inside a record decl"); |
| 953 | #endif |
| 954 | return true; |
| 955 | } |
| 956 | |
| 957 | static Decl::Kind getKind(const Decl *D) { return D->getKind(); } |
| 958 | static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); } |
| 959 | |
| 960 | int64_t Decl::getID() const { |
| 961 | return getASTContext().getAllocator().identifyKnownAlignedObject<Decl>(this); |
| 962 | } |
| 963 | |
| 964 | const FunctionType *Decl::getFunctionType(bool BlocksToo) const { |
| 965 | QualType Ty; |
| 966 | if (const auto *D = dyn_cast<ValueDecl>(this)) |
| 967 | Ty = D->getType(); |
| 968 | else if (const auto *D = dyn_cast<TypedefNameDecl>(this)) |
| 969 | Ty = D->getUnderlyingType(); |
| 970 | else |
| 971 | return nullptr; |
| 972 | |
| 973 | if (Ty->isFunctionPointerType()) |
| 974 | Ty = Ty->getAs<PointerType>()->getPointeeType(); |
| 975 | else if (BlocksToo && Ty->isBlockPointerType()) |
| 976 | Ty = Ty->getAs<BlockPointerType>()->getPointeeType(); |
| 977 | |
| 978 | return Ty->getAs<FunctionType>(); |
| 979 | } |
| 980 | |
| 981 | |
| 982 | |
| 983 | template <class T> static Decl *getNonClosureContext(T *D) { |
| 984 | if (getKind(D) == Decl::CXXMethod) { |
| 985 | auto *MD = cast<CXXMethodDecl>(D); |
| 986 | if (MD->getOverloadedOperator() == OO_Call && |
| 987 | MD->getParent()->isLambda()) |
| 988 | return getNonClosureContext(MD->getParent()->getParent()); |
| 989 | return MD; |
| 990 | } else if (auto *FD = dyn_cast<FunctionDecl>(D)) |
| 991 | return FD; |
| 992 | else if (auto *MD = dyn_cast<ObjCMethodDecl>(D)) |
| 993 | return MD; |
| 994 | else if (auto *BD = dyn_cast<BlockDecl>(D)) |
| 995 | return getNonClosureContext(BD->getParent()); |
| 996 | else if (auto *CD = dyn_cast<CapturedDecl>(D)) |
| 997 | return getNonClosureContext(CD->getParent()); |
| 998 | else |
| 999 | return nullptr; |
| 1000 | } |
| 1001 | |
| 1002 | Decl *Decl::getNonClosureContext() { |
| 1003 | return ::getNonClosureContext(this); |
| 1004 | } |
| 1005 | |
| 1006 | Decl *DeclContext::getNonClosureAncestor() { |
| 1007 | return ::getNonClosureContext(this); |
| 1008 | } |
| 1009 | |
| 1010 | |
| 1011 | |
| 1012 | |
| 1013 | |
| 1014 | DeclContext::DeclContext(Decl::Kind K) { |
| 1015 | DeclContextBits.DeclKind = K; |
| 1016 | setHasExternalLexicalStorage(false); |
| 1017 | setHasExternalVisibleStorage(false); |
| 1018 | setNeedToReconcileExternalVisibleStorage(false); |
| 1019 | setHasLazyLocalLexicalLookups(false); |
| 1020 | setHasLazyExternalLexicalLookups(false); |
| 1021 | setUseQualifiedLookup(false); |
| 1022 | } |
| 1023 | |
| 1024 | bool DeclContext::classof(const Decl *D) { |
| 1025 | switch (D->getKind()) { |
| 1026 | #define DECL(NAME, BASE) |
| 1027 | #define DECL_CONTEXT(NAME) case Decl::NAME: |
| 1028 | #define DECL_CONTEXT_BASE(NAME) |
| 1029 | #include "clang/AST/DeclNodes.inc" |
| 1030 | return true; |
| 1031 | default: |
| 1032 | #define DECL(NAME, BASE) |
| 1033 | #define DECL_CONTEXT_BASE(NAME) \ |
| 1034 | if (D->getKind() >= Decl::first##NAME && \ |
| 1035 | D->getKind() <= Decl::last##NAME) \ |
| 1036 | return true; |
| 1037 | #include "clang/AST/DeclNodes.inc" |
| 1038 | return false; |
| 1039 | } |
| 1040 | } |
| 1041 | |
| 1042 | DeclContext::~DeclContext() = default; |
| 1043 | |
| 1044 | |
| 1045 | |
| 1046 | |
| 1047 | |
| 1048 | |
| 1049 | |
| 1050 | DeclContext *DeclContext::getLookupParent() { |
| 1051 | |
| 1052 | if (isa<FunctionDecl>(this)) |
| 1053 | if (getParent()->getRedeclContext()->isFileContext() && |
| 1054 | getLexicalParent()->getRedeclContext()->isRecord()) |
| 1055 | return getLexicalParent(); |
| 1056 | |
| 1057 | return getParent(); |
| 1058 | } |
| 1059 | |
| 1060 | bool DeclContext::isInlineNamespace() const { |
| 1061 | return isNamespace() && |
| 1062 | cast<NamespaceDecl>(this)->isInline(); |
| 1063 | } |
| 1064 | |
| 1065 | bool DeclContext::isStdNamespace() const { |
| 1066 | if (!isNamespace()) |
| 1067 | return false; |
| 1068 | |
| 1069 | const auto *ND = cast<NamespaceDecl>(this); |
| 1070 | if (ND->isInline()) { |
| 1071 | return ND->getParent()->isStdNamespace(); |
| 1072 | } |
| 1073 | |
| 1074 | if (!getParent()->getRedeclContext()->isTranslationUnit()) |
| 1075 | return false; |
| 1076 | |
| 1077 | const IdentifierInfo *II = ND->getIdentifier(); |
| 1078 | return II && II->isStr("std"); |
| 1079 | } |
| 1080 | |
| 1081 | bool DeclContext::isDependentContext() const { |
| 1082 | if (isFileContext()) |
| 1083 | return false; |
| 1084 | |
| 1085 | if (isa<ClassTemplatePartialSpecializationDecl>(this)) |
| 1086 | return true; |
| 1087 | |
| 1088 | if (const auto *Record = dyn_cast<CXXRecordDecl>(this)) { |
| 1089 | if (Record->getDescribedClassTemplate()) |
| 1090 | return true; |
| 1091 | |
| 1092 | if (Record->isDependentLambda()) |
| 1093 | return true; |
| 1094 | } |
| 1095 | |
| 1096 | if (const auto *Function = dyn_cast<FunctionDecl>(this)) { |
| 1097 | if (Function->getDescribedFunctionTemplate()) |
| 1098 | return true; |
| 1099 | |
| 1100 | |
| 1101 | |
| 1102 | if (cast<Decl>(this)->getFriendObjectKind()) |
| 1103 | return getLexicalParent()->isDependentContext(); |
| 1104 | } |
| 1105 | |
| 1106 | |
| 1107 | |
| 1108 | |
| 1109 | |
| 1110 | return getParent() && getParent()->isDependentContext(); |
| 1111 | } |
| 1112 | |
| 1113 | bool DeclContext::isTransparentContext() const { |
| 1114 | if (getDeclKind() == Decl::Enum) |
| 1115 | return !cast<EnumDecl>(this)->isScoped(); |
| 1116 | else if (getDeclKind() == Decl::LinkageSpec || getDeclKind() == Decl::Export) |
| 1117 | return true; |
| 1118 | |
| 1119 | return false; |
| 1120 | } |
| 1121 | |
| 1122 | static bool isLinkageSpecContext(const DeclContext *DC, |
| 1123 | LinkageSpecDecl::LanguageIDs ID) { |
| 1124 | while (DC->getDeclKind() != Decl::TranslationUnit) { |
| 1125 | if (DC->getDeclKind() == Decl::LinkageSpec) |
| 1126 | return cast<LinkageSpecDecl>(DC)->getLanguage() == ID; |
| 1127 | DC = DC->getLexicalParent(); |
| 1128 | } |
| 1129 | return false; |
| 1130 | } |
| 1131 | |
| 1132 | bool DeclContext::isExternCContext() const { |
| 1133 | return isLinkageSpecContext(this, LinkageSpecDecl::lang_c); |
| 1134 | } |
| 1135 | |
| 1136 | const LinkageSpecDecl *DeclContext::getExternCContext() const { |
| 1137 | const DeclContext *DC = this; |
| 1138 | while (DC->getDeclKind() != Decl::TranslationUnit) { |
| 1139 | if (DC->getDeclKind() == Decl::LinkageSpec && |
| 1140 | cast<LinkageSpecDecl>(DC)->getLanguage() == LinkageSpecDecl::lang_c) |
| 1141 | return cast<LinkageSpecDecl>(DC); |
| 1142 | DC = DC->getLexicalParent(); |
| 1143 | } |
| 1144 | return nullptr; |
| 1145 | } |
| 1146 | |
| 1147 | bool DeclContext::isExternCXXContext() const { |
| 1148 | return isLinkageSpecContext(this, LinkageSpecDecl::lang_cxx); |
| 1149 | } |
| 1150 | |
| 1151 | bool DeclContext::Encloses(const DeclContext *DC) const { |
| 1152 | if (getPrimaryContext() != this) |
| 1153 | return getPrimaryContext()->Encloses(DC); |
| 1154 | |
| 1155 | for (; DC; DC = DC->getParent()) |
| 1156 | if (DC->getPrimaryContext() == this) |
| 1157 | return true; |
| 1158 | return false; |
| 1159 | } |
| 1160 | |
| 1161 | DeclContext *DeclContext::getPrimaryContext() { |
| 1162 | switch (getDeclKind()) { |
| 1163 | case Decl::TranslationUnit: |
| 1164 | case Decl::ExternCContext: |
| 1165 | case Decl::LinkageSpec: |
| 1166 | case Decl::Export: |
| 1167 | case Decl::Block: |
| 1168 | case Decl::Captured: |
| 1169 | case Decl::OMPDeclareReduction: |
| 1170 | case Decl::OMPDeclareMapper: |
| 1171 | |
| 1172 | return this; |
| 1173 | |
| 1174 | case Decl::Namespace: |
| 1175 | |
| 1176 | return static_cast<NamespaceDecl *>(this)->getOriginalNamespace(); |
| 1177 | |
| 1178 | case Decl::ObjCMethod: |
| 1179 | return this; |
| 1180 | |
| 1181 | case Decl::ObjCInterface: |
| 1182 | if (auto *OID = dyn_cast<ObjCInterfaceDecl>(this)) |
| 1183 | if (auto *Def = OID->getDefinition()) |
| 1184 | return Def; |
| 1185 | return this; |
| 1186 | |
| 1187 | case Decl::ObjCProtocol: |
| 1188 | if (auto *OPD = dyn_cast<ObjCProtocolDecl>(this)) |
| 1189 | if (auto *Def = OPD->getDefinition()) |
| 1190 | return Def; |
| 1191 | return this; |
| 1192 | |
| 1193 | case Decl::ObjCCategory: |
| 1194 | return this; |
| 1195 | |
| 1196 | case Decl::ObjCImplementation: |
| 1197 | case Decl::ObjCCategoryImpl: |
| 1198 | return this; |
| 1199 | |
| 1200 | default: |
| 1201 | if (getDeclKind() >= Decl::firstTag && getDeclKind() <= Decl::lastTag) { |
| 1202 | |
| 1203 | |
| 1204 | auto *Tag = cast<TagDecl>(this); |
| 1205 | |
| 1206 | if (TagDecl *Def = Tag->getDefinition()) |
| 1207 | return Def; |
| 1208 | |
| 1209 | if (const auto *TagTy = dyn_cast<TagType>(Tag->getTypeForDecl())) { |
| 1210 | |
| 1211 | TagDecl *PossiblePartialDef = TagTy->getDecl(); |
| 1212 | if (PossiblePartialDef->isBeingDefined()) |
| 1213 | return PossiblePartialDef; |
| 1214 | } else { |
| 1215 | (Tag->getTypeForDecl())", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1215, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(isa<InjectedClassNameType>(Tag->getTypeForDecl())); |
| 1216 | } |
| 1217 | |
| 1218 | return Tag; |
| 1219 | } |
| 1220 | |
| 1221 | (0) . __assert_fail ("getDeclKind() >= Decl..firstFunction && getDeclKind() <= Decl..lastFunction && \"Unknown DeclContext kind\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1223, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(getDeclKind() >= Decl::firstFunction && |
| 1222 | (0) . __assert_fail ("getDeclKind() >= Decl..firstFunction && getDeclKind() <= Decl..lastFunction && \"Unknown DeclContext kind\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1223, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> getDeclKind() <= Decl::lastFunction && |
| 1223 | (0) . __assert_fail ("getDeclKind() >= Decl..firstFunction && getDeclKind() <= Decl..lastFunction && \"Unknown DeclContext kind\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1223, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Unknown DeclContext kind"); |
| 1224 | return this; |
| 1225 | } |
| 1226 | } |
| 1227 | |
| 1228 | void |
| 1229 | DeclContext::collectAllContexts(SmallVectorImpl<DeclContext *> &Contexts){ |
| 1230 | Contexts.clear(); |
| 1231 | |
| 1232 | if (getDeclKind() != Decl::Namespace) { |
| 1233 | Contexts.push_back(this); |
| 1234 | return; |
| 1235 | } |
| 1236 | |
| 1237 | auto *Self = static_cast<NamespaceDecl *>(this); |
| 1238 | for (NamespaceDecl *N = Self->getMostRecentDecl(); N; |
| 1239 | N = N->getPreviousDecl()) |
| 1240 | Contexts.push_back(N); |
| 1241 | |
| 1242 | std::reverse(Contexts.begin(), Contexts.end()); |
| 1243 | } |
| 1244 | |
| 1245 | std::pair<Decl *, Decl *> |
| 1246 | DeclContext::BuildDeclChain(ArrayRef<Decl *> Decls, |
| 1247 | bool FieldsAlreadyLoaded) { |
| 1248 | |
| 1249 | Decl *FirstNewDecl = nullptr; |
| 1250 | Decl *PrevDecl = nullptr; |
| 1251 | for (auto *D : Decls) { |
| 1252 | if (FieldsAlreadyLoaded && isa<FieldDecl>(D)) |
| 1253 | continue; |
| 1254 | |
| 1255 | if (PrevDecl) |
| 1256 | PrevDecl->NextInContextAndBits.setPointer(D); |
| 1257 | else |
| 1258 | FirstNewDecl = D; |
| 1259 | |
| 1260 | PrevDecl = D; |
| 1261 | } |
| 1262 | |
| 1263 | return std::make_pair(FirstNewDecl, PrevDecl); |
| 1264 | } |
| 1265 | |
| 1266 | |
| 1267 | |
| 1268 | |
| 1269 | void DeclContext::reconcileExternalVisibleStorage() const { |
| 1270 | assert(hasNeedToReconcileExternalVisibleStorage() && LookupPtr); |
| 1271 | setNeedToReconcileExternalVisibleStorage(false); |
| 1272 | |
| 1273 | for (auto &Lookup : *LookupPtr) |
| 1274 | Lookup.second.setHasExternalDecls(); |
| 1275 | } |
| 1276 | |
| 1277 | |
| 1278 | |
| 1279 | |
| 1280 | bool |
| 1281 | DeclContext::LoadLexicalDeclsFromExternalStorage() const { |
| 1282 | ExternalASTSource *Source = getParentASTContext().getExternalSource(); |
| 1283 | (0) . __assert_fail ("hasExternalLexicalStorage() && Source && \"No external storage?\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1283, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(hasExternalLexicalStorage() && Source && "No external storage?"); |
| 1284 | |
| 1285 | |
| 1286 | ExternalASTSource::Deserializing ADeclContext(Source); |
| 1287 | |
| 1288 | |
| 1289 | SmallVector<Decl*, 64> Decls; |
| 1290 | setHasExternalLexicalStorage(false); |
| 1291 | Source->FindExternalLexicalDecls(this, Decls); |
| 1292 | |
| 1293 | if (Decls.empty()) |
| 1294 | return false; |
| 1295 | |
| 1296 | |
| 1297 | |
| 1298 | bool FieldsAlreadyLoaded = false; |
| 1299 | if (const auto *RD = dyn_cast<RecordDecl>(this)) |
| 1300 | FieldsAlreadyLoaded = RD->hasLoadedFieldsFromExternalStorage(); |
| 1301 | |
| 1302 | |
| 1303 | |
| 1304 | Decl *ExternalFirst, *ExternalLast; |
| 1305 | std::tie(ExternalFirst, ExternalLast) = |
| 1306 | BuildDeclChain(Decls, FieldsAlreadyLoaded); |
| 1307 | ExternalLast->NextInContextAndBits.setPointer(FirstDecl); |
| 1308 | FirstDecl = ExternalFirst; |
| 1309 | if (!LastDecl) |
| 1310 | LastDecl = ExternalLast; |
| 1311 | return true; |
| 1312 | } |
| 1313 | |
| 1314 | DeclContext::lookup_result |
| 1315 | ExternalASTSource::SetNoExternalVisibleDeclsForName(const DeclContext *DC, |
| 1316 | DeclarationName Name) { |
| 1317 | ASTContext &Context = DC->getParentASTContext(); |
| 1318 | StoredDeclsMap *Map; |
| 1319 | if (!(Map = DC->LookupPtr)) |
| 1320 | Map = DC->CreateStoredDeclsMap(Context); |
| 1321 | if (DC->hasNeedToReconcileExternalVisibleStorage()) |
| 1322 | DC->reconcileExternalVisibleStorage(); |
| 1323 | |
| 1324 | (*Map)[Name].removeExternalDecls(); |
| 1325 | |
| 1326 | return DeclContext::lookup_result(); |
| 1327 | } |
| 1328 | |
| 1329 | DeclContext::lookup_result |
| 1330 | ExternalASTSource::SetExternalVisibleDeclsForName(const DeclContext *DC, |
| 1331 | DeclarationName Name, |
| 1332 | ArrayRef<NamedDecl*> Decls) { |
| 1333 | ASTContext &Context = DC->getParentASTContext(); |
| 1334 | StoredDeclsMap *Map; |
| 1335 | if (!(Map = DC->LookupPtr)) |
| 1336 | Map = DC->CreateStoredDeclsMap(Context); |
| 1337 | if (DC->hasNeedToReconcileExternalVisibleStorage()) |
| 1338 | DC->reconcileExternalVisibleStorage(); |
| 1339 | |
| 1340 | StoredDeclsList &List = (*Map)[Name]; |
| 1341 | |
| 1342 | |
| 1343 | |
| 1344 | List.removeExternalDecls(); |
| 1345 | |
| 1346 | if (!List.isNull()) { |
| 1347 | |
| 1348 | |
| 1349 | |
| 1350 | llvm::SmallVector<unsigned, 8> Skip; |
| 1351 | for (unsigned I = 0, N = Decls.size(); I != N; ++I) |
| 1352 | if (List.HandleRedeclaration(Decls[I], )) |
| 1353 | Skip.push_back(I); |
| 1354 | Skip.push_back(Decls.size()); |
| 1355 | |
| 1356 | |
| 1357 | unsigned SkipPos = 0; |
| 1358 | for (unsigned I = 0, N = Decls.size(); I != N; ++I) { |
| 1359 | if (I == Skip[SkipPos]) |
| 1360 | ++SkipPos; |
| 1361 | else |
| 1362 | List.AddSubsequentDecl(Decls[I]); |
| 1363 | } |
| 1364 | } else { |
| 1365 | |
| 1366 | for (auto *D : Decls) { |
| 1367 | if (List.isNull()) |
| 1368 | List.setOnlyValue(D); |
| 1369 | else |
| 1370 | List.AddSubsequentDecl(D); |
| 1371 | } |
| 1372 | } |
| 1373 | |
| 1374 | return List.getLookupResult(); |
| 1375 | } |
| 1376 | |
| 1377 | DeclContext::decl_iterator DeclContext::decls_begin() const { |
| 1378 | if (hasExternalLexicalStorage()) |
| 1379 | LoadLexicalDeclsFromExternalStorage(); |
| 1380 | return decl_iterator(FirstDecl); |
| 1381 | } |
| 1382 | |
| 1383 | bool DeclContext::decls_empty() const { |
| 1384 | if (hasExternalLexicalStorage()) |
| 1385 | LoadLexicalDeclsFromExternalStorage(); |
| 1386 | |
| 1387 | return !FirstDecl; |
| 1388 | } |
| 1389 | |
| 1390 | bool DeclContext::containsDecl(Decl *D) const { |
| 1391 | return (D->getLexicalDeclContext() == this && |
| 1392 | (D->NextInContextAndBits.getPointer() || D == LastDecl)); |
| 1393 | } |
| 1394 | |
| 1395 | bool DeclContext::containsDeclAndLoad(Decl *D) const { |
| 1396 | if (hasExternalLexicalStorage()) |
| 1397 | LoadLexicalDeclsFromExternalStorage(); |
| 1398 | return containsDecl(D); |
| 1399 | } |
| 1400 | |
| 1401 | |
| 1402 | |
| 1403 | static bool shouldBeHidden(NamedDecl *D) { |
| 1404 | |
| 1405 | if (!D->getDeclName()) |
| 1406 | return true; |
| 1407 | |
| 1408 | |
| 1409 | |
| 1410 | if ((D->getIdentifierNamespace() == 0 && !isa<UsingDirectiveDecl>(D)) || |
| 1411 | D->isTemplateParameter()) |
| 1412 | return true; |
| 1413 | |
| 1414 | |
| 1415 | |
| 1416 | if ((D->isLocalExternDecl() || D->getFriendObjectKind()) && |
| 1417 | D != D->getCanonicalDecl()) |
| 1418 | return true; |
| 1419 | |
| 1420 | |
| 1421 | |
| 1422 | |
| 1423 | |
| 1424 | if (isa<ClassTemplateSpecializationDecl>(D)) |
| 1425 | return true; |
| 1426 | if (auto *FD = dyn_cast<FunctionDecl>(D)) |
| 1427 | if (FD->isFunctionTemplateSpecialization()) |
| 1428 | return true; |
| 1429 | |
| 1430 | return false; |
| 1431 | } |
| 1432 | |
| 1433 | void DeclContext::removeDecl(Decl *D) { |
| 1434 | (0) . __assert_fail ("D->getLexicalDeclContext() == this && \"decl being removed from non-lexical context\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1435, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(D->getLexicalDeclContext() == this && |
| 1435 | (0) . __assert_fail ("D->getLexicalDeclContext() == this && \"decl being removed from non-lexical context\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1435, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "decl being removed from non-lexical context"); |
| 1436 | (0) . __assert_fail ("(D->NextInContextAndBits.getPointer() || D == LastDecl) && \"decl is not in decls list\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1437, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert((D->NextInContextAndBits.getPointer() || D == LastDecl) && |
| 1437 | (0) . __assert_fail ("(D->NextInContextAndBits.getPointer() || D == LastDecl) && \"decl is not in decls list\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1437, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "decl is not in decls list"); |
| 1438 | |
| 1439 | |
| 1440 | if (D == FirstDecl) { |
| 1441 | if (D == LastDecl) |
| 1442 | FirstDecl = LastDecl = nullptr; |
| 1443 | else |
| 1444 | FirstDecl = D->NextInContextAndBits.getPointer(); |
| 1445 | } else { |
| 1446 | for (Decl *I = FirstDecl; true; I = I->NextInContextAndBits.getPointer()) { |
| 1447 | (0) . __assert_fail ("I && \"decl not found in linked list\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1447, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(I && "decl not found in linked list"); |
| 1448 | if (I->NextInContextAndBits.getPointer() == D) { |
| 1449 | I->NextInContextAndBits.setPointer(D->NextInContextAndBits.getPointer()); |
| 1450 | if (D == LastDecl) LastDecl = I; |
| 1451 | break; |
| 1452 | } |
| 1453 | } |
| 1454 | } |
| 1455 | |
| 1456 | |
| 1457 | D->NextInContextAndBits.setPointer(nullptr); |
| 1458 | |
| 1459 | |
| 1460 | if (isa<NamedDecl>(D)) { |
| 1461 | auto *ND = cast<NamedDecl>(D); |
| 1462 | |
| 1463 | |
| 1464 | |
| 1465 | if (shouldBeHidden(ND)) |
| 1466 | return; |
| 1467 | |
| 1468 | |
| 1469 | if (!ND->getDeclName()) |
| 1470 | return; |
| 1471 | |
| 1472 | auto *DC = D->getDeclContext(); |
| 1473 | do { |
| 1474 | StoredDeclsMap *Map = DC->getPrimaryContext()->LookupPtr; |
| 1475 | if (Map) { |
| 1476 | StoredDeclsMap::iterator Pos = Map->find(ND->getDeclName()); |
| 1477 | (0) . __assert_fail ("Pos != Map->end() && \"no lookup entry for decl\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1477, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Pos != Map->end() && "no lookup entry for decl"); |
| 1478 | |
| 1479 | StoredDeclsList::DeclsTy *Vec = Pos->second.getAsVector(); |
| 1480 | if ((Vec && is_contained(*Vec, ND)) || Pos->second.getAsDecl() == ND) |
| 1481 | Pos->second.remove(ND); |
| 1482 | } |
| 1483 | } while (DC->isTransparentContext() && (DC = DC->getParent())); |
| 1484 | } |
| 1485 | } |
| 1486 | |
| 1487 | void DeclContext::addHiddenDecl(Decl *D) { |
| 1488 | (0) . __assert_fail ("D->getLexicalDeclContext() == this && \"Decl inserted into wrong lexical context\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1489, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(D->getLexicalDeclContext() == this && |
| 1489 | (0) . __assert_fail ("D->getLexicalDeclContext() == this && \"Decl inserted into wrong lexical context\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1489, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Decl inserted into wrong lexical context"); |
| 1490 | (0) . __assert_fail ("!D->getNextDeclInContext() && D != LastDecl && \"Decl already inserted into a DeclContext\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1491, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!D->getNextDeclInContext() && D != LastDecl && |
| 1491 | (0) . __assert_fail ("!D->getNextDeclInContext() && D != LastDecl && \"Decl already inserted into a DeclContext\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1491, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "Decl already inserted into a DeclContext"); |
| 1492 | |
| 1493 | if (FirstDecl) { |
| 1494 | LastDecl->NextInContextAndBits.setPointer(D); |
| 1495 | LastDecl = D; |
| 1496 | } else { |
| 1497 | FirstDecl = LastDecl = D; |
| 1498 | } |
| 1499 | |
| 1500 | |
| 1501 | |
| 1502 | if (auto *Record = dyn_cast<CXXRecordDecl>(this)) |
| 1503 | Record->addedMember(D); |
| 1504 | |
| 1505 | |
| 1506 | |
| 1507 | if (!D->isFromASTFile()) { |
| 1508 | if (auto *Import = dyn_cast<ImportDecl>(D)) |
| 1509 | D->getASTContext().addedLocalImportDecl(Import); |
| 1510 | } |
| 1511 | } |
| 1512 | |
| 1513 | void DeclContext::addDecl(Decl *D) { |
| 1514 | addHiddenDecl(D); |
| 1515 | |
| 1516 | if (auto *ND = dyn_cast<NamedDecl>(D)) |
| 1517 | ND->getDeclContext()->getPrimaryContext()-> |
| 1518 | makeDeclVisibleInContextWithFlags(ND, false, true); |
| 1519 | } |
| 1520 | |
| 1521 | void DeclContext::addDeclInternal(Decl *D) { |
| 1522 | addHiddenDecl(D); |
| 1523 | |
| 1524 | if (auto *ND = dyn_cast<NamedDecl>(D)) |
| 1525 | ND->getDeclContext()->getPrimaryContext()-> |
| 1526 | makeDeclVisibleInContextWithFlags(ND, true, true); |
| 1527 | } |
| 1528 | |
| 1529 | |
| 1530 | |
| 1531 | |
| 1532 | |
| 1533 | |
| 1534 | |
| 1535 | |
| 1536 | StoredDeclsMap *DeclContext::buildLookup() { |
| 1537 | (0) . __assert_fail ("this == getPrimaryContext() && \"buildLookup called on non-primary DC\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1537, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(this == getPrimaryContext() && "buildLookup called on non-primary DC"); |
| 1538 | |
| 1539 | if (!hasLazyLocalLexicalLookups() && |
| 1540 | !hasLazyExternalLexicalLookups()) |
| 1541 | return LookupPtr; |
| 1542 | |
| 1543 | SmallVector<DeclContext *, 2> Contexts; |
| 1544 | collectAllContexts(Contexts); |
| 1545 | |
| 1546 | if (hasLazyExternalLexicalLookups()) { |
| 1547 | setHasLazyExternalLexicalLookups(false); |
| 1548 | for (auto *DC : Contexts) { |
| 1549 | if (DC->hasExternalLexicalStorage()) { |
| 1550 | bool LoadedDecls = DC->LoadLexicalDeclsFromExternalStorage(); |
| 1551 | setHasLazyLocalLexicalLookups( |
| 1552 | hasLazyLocalLexicalLookups() | LoadedDecls ); |
| 1553 | } |
| 1554 | } |
| 1555 | |
| 1556 | if (!hasLazyLocalLexicalLookups()) |
| 1557 | return LookupPtr; |
| 1558 | } |
| 1559 | |
| 1560 | for (auto *DC : Contexts) |
| 1561 | buildLookupImpl(DC, hasExternalVisibleStorage()); |
| 1562 | |
| 1563 | |
| 1564 | setHasLazyLocalLexicalLookups(false); |
| 1565 | return LookupPtr; |
| 1566 | } |
| 1567 | |
| 1568 | |
| 1569 | |
| 1570 | |
| 1571 | |
| 1572 | void DeclContext::buildLookupImpl(DeclContext *DCtx, bool Internal) { |
| 1573 | for (auto *D : DCtx->noload_decls()) { |
| 1574 | |
| 1575 | |
| 1576 | |
| 1577 | |
| 1578 | |
| 1579 | |
| 1580 | |
| 1581 | |
| 1582 | if (auto *ND = dyn_cast<NamedDecl>(D)) |
| 1583 | if (ND->getDeclContext() == DCtx && !shouldBeHidden(ND) && |
| 1584 | (!ND->isFromASTFile() || |
| 1585 | (isTranslationUnit() && |
| 1586 | !getParentASTContext().getLangOpts().CPlusPlus))) |
| 1587 | makeDeclVisibleInContextImpl(ND, Internal); |
| 1588 | |
| 1589 | |
| 1590 | |
| 1591 | |
| 1592 | if (auto *InnerCtx = dyn_cast<DeclContext>(D)) |
| 1593 | if (InnerCtx->isTransparentContext() || InnerCtx->isInlineNamespace()) |
| 1594 | buildLookupImpl(InnerCtx, Internal); |
| 1595 | } |
| 1596 | } |
| 1597 | |
| 1598 | NamedDecl *const DeclContextLookupResult::SingleElementDummyList = nullptr; |
| 1599 | |
| 1600 | DeclContext::lookup_result |
| 1601 | DeclContext::lookup(DeclarationName Name) const { |
| 1602 | (0) . __assert_fail ("getDeclKind() != Decl..LinkageSpec && getDeclKind() != Decl..Export && \"should not perform lookups into transparent contexts\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1604, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(getDeclKind() != Decl::LinkageSpec && |
| 1603 | (0) . __assert_fail ("getDeclKind() != Decl..LinkageSpec && getDeclKind() != Decl..Export && \"should not perform lookups into transparent contexts\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1604, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> getDeclKind() != Decl::Export && |
| 1604 | (0) . __assert_fail ("getDeclKind() != Decl..LinkageSpec && getDeclKind() != Decl..Export && \"should not perform lookups into transparent contexts\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1604, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "should not perform lookups into transparent contexts"); |
| 1605 | |
| 1606 | const DeclContext *PrimaryContext = getPrimaryContext(); |
| 1607 | if (PrimaryContext != this) |
| 1608 | return PrimaryContext->lookup(Name); |
| 1609 | |
| 1610 | |
| 1611 | |
| 1612 | |
| 1613 | ExternalASTSource *Source = getParentASTContext().getExternalSource(); |
| 1614 | if (Source) |
| 1615 | (void)cast<Decl>(this)->getMostRecentDecl(); |
| 1616 | |
| 1617 | if (hasExternalVisibleStorage()) { |
| 1618 | (0) . __assert_fail ("Source && \"external visible storage but no external source?\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1618, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Source && "external visible storage but no external source?"); |
| 1619 | |
| 1620 | if (hasNeedToReconcileExternalVisibleStorage()) |
| 1621 | reconcileExternalVisibleStorage(); |
| 1622 | |
| 1623 | StoredDeclsMap *Map = LookupPtr; |
| 1624 | |
| 1625 | if (hasLazyLocalLexicalLookups() || |
| 1626 | hasLazyExternalLexicalLookups()) |
| 1627 | |
| 1628 | Map = const_cast<DeclContext*>(this)->buildLookup(); |
| 1629 | |
| 1630 | if (!Map) |
| 1631 | Map = CreateStoredDeclsMap(getParentASTContext()); |
| 1632 | |
| 1633 | |
| 1634 | std::pair<StoredDeclsMap::iterator, bool> R = |
| 1635 | Map->insert(std::make_pair(Name, StoredDeclsList())); |
| 1636 | if (!R.second && !R.first->second.hasExternalDecls()) |
| 1637 | return R.first->second.getLookupResult(); |
| 1638 | |
| 1639 | if (Source->FindExternalVisibleDeclsByName(this, Name) || !R.second) { |
| 1640 | if (StoredDeclsMap *Map = LookupPtr) { |
| 1641 | StoredDeclsMap::iterator I = Map->find(Name); |
| 1642 | if (I != Map->end()) |
| 1643 | return I->second.getLookupResult(); |
| 1644 | } |
| 1645 | } |
| 1646 | |
| 1647 | return {}; |
| 1648 | } |
| 1649 | |
| 1650 | StoredDeclsMap *Map = LookupPtr; |
| 1651 | if (hasLazyLocalLexicalLookups() || |
| 1652 | hasLazyExternalLexicalLookups()) |
| 1653 | Map = const_cast<DeclContext*>(this)->buildLookup(); |
| 1654 | |
| 1655 | if (!Map) |
| 1656 | return {}; |
| 1657 | |
| 1658 | StoredDeclsMap::iterator I = Map->find(Name); |
| 1659 | if (I == Map->end()) |
| 1660 | return {}; |
| 1661 | |
| 1662 | return I->second.getLookupResult(); |
| 1663 | } |
| 1664 | |
| 1665 | DeclContext::lookup_result |
| 1666 | DeclContext::noload_lookup(DeclarationName Name) { |
| 1667 | (0) . __assert_fail ("getDeclKind() != Decl..LinkageSpec && getDeclKind() != Decl..Export && \"should not perform lookups into transparent contexts\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1669, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(getDeclKind() != Decl::LinkageSpec && |
| 1668 | (0) . __assert_fail ("getDeclKind() != Decl..LinkageSpec && getDeclKind() != Decl..Export && \"should not perform lookups into transparent contexts\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1669, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> getDeclKind() != Decl::Export && |
| 1669 | (0) . __assert_fail ("getDeclKind() != Decl..LinkageSpec && getDeclKind() != Decl..Export && \"should not perform lookups into transparent contexts\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1669, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "should not perform lookups into transparent contexts"); |
| 1670 | |
| 1671 | DeclContext *PrimaryContext = getPrimaryContext(); |
| 1672 | if (PrimaryContext != this) |
| 1673 | return PrimaryContext->noload_lookup(Name); |
| 1674 | |
| 1675 | loadLazyLocalLexicalLookups(); |
| 1676 | StoredDeclsMap *Map = LookupPtr; |
| 1677 | if (!Map) |
| 1678 | return {}; |
| 1679 | |
| 1680 | StoredDeclsMap::iterator I = Map->find(Name); |
| 1681 | return I != Map->end() ? I->second.getLookupResult() |
| 1682 | : lookup_result(); |
| 1683 | } |
| 1684 | |
| 1685 | |
| 1686 | |
| 1687 | |
| 1688 | void DeclContext::loadLazyLocalLexicalLookups() { |
| 1689 | if (hasLazyLocalLexicalLookups()) { |
| 1690 | SmallVector<DeclContext *, 2> Contexts; |
| 1691 | collectAllContexts(Contexts); |
| 1692 | for (auto *Context : Contexts) |
| 1693 | buildLookupImpl(Context, hasExternalVisibleStorage()); |
| 1694 | setHasLazyLocalLexicalLookups(false); |
| 1695 | } |
| 1696 | } |
| 1697 | |
| 1698 | void DeclContext::localUncachedLookup(DeclarationName Name, |
| 1699 | SmallVectorImpl<NamedDecl *> &Results) { |
| 1700 | Results.clear(); |
| 1701 | |
| 1702 | |
| 1703 | |
| 1704 | if (!hasExternalVisibleStorage() && !hasExternalLexicalStorage() && Name) { |
| 1705 | lookup_result LookupResults = lookup(Name); |
| 1706 | Results.insert(Results.end(), LookupResults.begin(), LookupResults.end()); |
| 1707 | return; |
| 1708 | } |
| 1709 | |
| 1710 | |
| 1711 | |
| 1712 | if (Name && !hasLazyLocalLexicalLookups() && |
| 1713 | !hasLazyExternalLexicalLookups()) { |
| 1714 | if (StoredDeclsMap *Map = LookupPtr) { |
| 1715 | StoredDeclsMap::iterator Pos = Map->find(Name); |
| 1716 | if (Pos != Map->end()) { |
| 1717 | Results.insert(Results.end(), |
| 1718 | Pos->second.getLookupResult().begin(), |
| 1719 | Pos->second.getLookupResult().end()); |
| 1720 | return; |
| 1721 | } |
| 1722 | } |
| 1723 | } |
| 1724 | |
| 1725 | |
| 1726 | |
| 1727 | |
| 1728 | |
| 1729 | for (Decl *D = FirstDecl; D; D = D->getNextDeclInContext()) { |
| 1730 | if (auto *ND = dyn_cast<NamedDecl>(D)) |
| 1731 | if (ND->getDeclName() == Name) |
| 1732 | Results.push_back(ND); |
| 1733 | } |
| 1734 | } |
| 1735 | |
| 1736 | DeclContext *DeclContext::getRedeclContext() { |
| 1737 | DeclContext *Ctx = this; |
| 1738 | |
| 1739 | |
| 1740 | |
| 1741 | |
| 1742 | |
| 1743 | |
| 1744 | bool SkipRecords = getDeclKind() == Decl::Kind::Enum && |
| 1745 | !getParentASTContext().getLangOpts().CPlusPlus; |
| 1746 | |
| 1747 | |
| 1748 | |
| 1749 | while ((SkipRecords && Ctx->isRecord()) || Ctx->isTransparentContext()) |
| 1750 | Ctx = Ctx->getParent(); |
| 1751 | return Ctx; |
| 1752 | } |
| 1753 | |
| 1754 | DeclContext *DeclContext::getEnclosingNamespaceContext() { |
| 1755 | DeclContext *Ctx = this; |
| 1756 | |
| 1757 | while (!Ctx->isFileContext()) |
| 1758 | Ctx = Ctx->getParent(); |
| 1759 | return Ctx->getPrimaryContext(); |
| 1760 | } |
| 1761 | |
| 1762 | RecordDecl *DeclContext::getOuterLexicalRecordContext() { |
| 1763 | |
| 1764 | RecordDecl *OutermostRD = nullptr; |
| 1765 | DeclContext *DC = this; |
| 1766 | while (DC->isRecord()) { |
| 1767 | OutermostRD = cast<RecordDecl>(DC); |
| 1768 | DC = DC->getLexicalParent(); |
| 1769 | } |
| 1770 | return OutermostRD; |
| 1771 | } |
| 1772 | |
| 1773 | bool DeclContext::InEnclosingNamespaceSetOf(const DeclContext *O) const { |
| 1774 | |
| 1775 | if (!isFileContext()) |
| 1776 | return O->Equals(this); |
| 1777 | |
| 1778 | do { |
| 1779 | if (O->Equals(this)) |
| 1780 | return true; |
| 1781 | |
| 1782 | const auto *NS = dyn_cast<NamespaceDecl>(O); |
| 1783 | if (!NS || !NS->isInline()) |
| 1784 | break; |
| 1785 | O = NS->getParent(); |
| 1786 | } while (O); |
| 1787 | |
| 1788 | return false; |
| 1789 | } |
| 1790 | |
| 1791 | void DeclContext::makeDeclVisibleInContext(NamedDecl *D) { |
| 1792 | DeclContext *PrimaryDC = this->getPrimaryContext(); |
| 1793 | DeclContext *DeclDC = D->getDeclContext()->getPrimaryContext(); |
| 1794 | |
| 1795 | |
| 1796 | PrimaryDC->makeDeclVisibleInContextWithFlags(D, false, PrimaryDC == DeclDC); |
| 1797 | } |
| 1798 | |
| 1799 | void DeclContext::makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal, |
| 1800 | bool Recoverable) { |
| 1801 | (0) . __assert_fail ("this == getPrimaryContext() && \"expected a primary DC\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1801, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(this == getPrimaryContext() && "expected a primary DC"); |
| 1802 | |
| 1803 | if (!isLookupContext()) { |
| 1804 | if (isTransparentContext()) |
| 1805 | getParent()->getPrimaryContext() |
| 1806 | ->makeDeclVisibleInContextWithFlags(D, Internal, Recoverable); |
| 1807 | return; |
| 1808 | } |
| 1809 | |
| 1810 | |
| 1811 | if (shouldBeHidden(D)) |
| 1812 | return; |
| 1813 | |
| 1814 | |
| 1815 | |
| 1816 | |
| 1817 | |
| 1818 | |
| 1819 | |
| 1820 | |
| 1821 | |
| 1822 | if (LookupPtr || hasExternalVisibleStorage() || |
| 1823 | ((!Recoverable || D->getDeclContext() != D->getLexicalDeclContext()) && |
| 1824 | (getParentASTContext().getLangOpts().CPlusPlus || |
| 1825 | !isTranslationUnit()))) { |
| 1826 | |
| 1827 | |
| 1828 | |
| 1829 | buildLookup(); |
| 1830 | makeDeclVisibleInContextImpl(D, Internal); |
| 1831 | } else { |
| 1832 | setHasLazyLocalLexicalLookups(true); |
| 1833 | } |
| 1834 | |
| 1835 | |
| 1836 | |
| 1837 | if (isTransparentContext() || isInlineNamespace()) |
| 1838 | getParent()->getPrimaryContext()-> |
| 1839 | makeDeclVisibleInContextWithFlags(D, Internal, Recoverable); |
| 1840 | |
| 1841 | auto *DCAsDecl = cast<Decl>(this); |
| 1842 | |
| 1843 | if (!(isa<TagDecl>(DCAsDecl) && cast<TagDecl>(DCAsDecl)->isBeingDefined())) |
| 1844 | if (ASTMutationListener *L = DCAsDecl->getASTMutationListener()) |
| 1845 | L->AddedVisibleDecl(this, D); |
| 1846 | } |
| 1847 | |
| 1848 | void DeclContext::makeDeclVisibleInContextImpl(NamedDecl *D, bool Internal) { |
| 1849 | |
| 1850 | StoredDeclsMap *Map = LookupPtr; |
| 1851 | if (!Map) { |
| 1852 | ASTContext *C = &getParentASTContext(); |
| 1853 | Map = CreateStoredDeclsMap(*C); |
| 1854 | } |
| 1855 | |
| 1856 | |
| 1857 | |
| 1858 | |
| 1859 | |
| 1860 | if (!Internal) |
| 1861 | if (ExternalASTSource *Source = getParentASTContext().getExternalSource()) |
| 1862 | if (hasExternalVisibleStorage() && |
| 1863 | Map->find(D->getDeclName()) == Map->end()) |
| 1864 | Source->FindExternalVisibleDeclsByName(this, D->getDeclName()); |
| 1865 | |
| 1866 | |
| 1867 | StoredDeclsList &DeclNameEntries = (*Map)[D->getDeclName()]; |
| 1868 | |
| 1869 | if (Internal) { |
| 1870 | |
| 1871 | |
| 1872 | |
| 1873 | |
| 1874 | DeclNameEntries.setHasExternalDecls(); |
| 1875 | DeclNameEntries.AddSubsequentDecl(D); |
| 1876 | return; |
| 1877 | } |
| 1878 | |
| 1879 | if (DeclNameEntries.isNull()) { |
| 1880 | DeclNameEntries.setOnlyValue(D); |
| 1881 | return; |
| 1882 | } |
| 1883 | |
| 1884 | if (DeclNameEntries.HandleRedeclaration(D, !Internal)) { |
| 1885 | |
| 1886 | |
| 1887 | return; |
| 1888 | } |
| 1889 | |
| 1890 | |
| 1891 | DeclNameEntries.AddSubsequentDecl(D); |
| 1892 | } |
| 1893 | |
| 1894 | UsingDirectiveDecl *DeclContext::udir_iterator::operator*() const { |
| 1895 | return cast<UsingDirectiveDecl>(*I); |
| 1896 | } |
| 1897 | |
| 1898 | |
| 1899 | |
| 1900 | DeclContext::udir_range DeclContext::using_directives() const { |
| 1901 | |
| 1902 | |
| 1903 | lookup_result Result = lookup(UsingDirectiveDecl::getName()); |
| 1904 | return udir_range(Result.begin(), Result.end()); |
| 1905 | } |
| 1906 | |
| 1907 | |
| 1908 | |
| 1909 | |
| 1910 | |
| 1911 | StoredDeclsMap *DeclContext::CreateStoredDeclsMap(ASTContext &C) const { |
| 1912 | (0) . __assert_fail ("!LookupPtr && \"context already has a decls map\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1912, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(!LookupPtr && "context already has a decls map"); |
| 1913 | (0) . __assert_fail ("getPrimaryContext() == this && \"creating decls map on non-primary context\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1914, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(getPrimaryContext() == this && |
| 1914 | (0) . __assert_fail ("getPrimaryContext() == this && \"creating decls map on non-primary context\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1914, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> "creating decls map on non-primary context"); |
| 1915 | |
| 1916 | StoredDeclsMap *M; |
| 1917 | bool Dependent = isDependentContext(); |
| 1918 | if (Dependent) |
| 1919 | M = new DependentStoredDeclsMap(); |
| 1920 | else |
| 1921 | M = new StoredDeclsMap(); |
| 1922 | M->Previous = C.LastSDM; |
| 1923 | C.LastSDM = llvm::PointerIntPair<StoredDeclsMap*,1>(M, Dependent); |
| 1924 | LookupPtr = M; |
| 1925 | return M; |
| 1926 | } |
| 1927 | |
| 1928 | void ASTContext::ReleaseDeclContextMaps() { |
| 1929 | |
| 1930 | |
| 1931 | |
| 1932 | StoredDeclsMap::DestroyAll(LastSDM.getPointer(), LastSDM.getInt()); |
| 1933 | } |
| 1934 | |
| 1935 | void StoredDeclsMap::DestroyAll(StoredDeclsMap *Map, bool Dependent) { |
| 1936 | while (Map) { |
| 1937 | |
| 1938 | llvm::PointerIntPair<StoredDeclsMap*,1> Next = Map->Previous; |
| 1939 | |
| 1940 | if (Dependent) |
| 1941 | delete static_cast<DependentStoredDeclsMap*>(Map); |
| 1942 | else |
| 1943 | delete Map; |
| 1944 | |
| 1945 | Map = Next.getPointer(); |
| 1946 | Dependent = Next.getInt(); |
| 1947 | } |
| 1948 | } |
| 1949 | |
| 1950 | DependentDiagnostic *DependentDiagnostic::Create(ASTContext &C, |
| 1951 | DeclContext *Parent, |
| 1952 | const PartialDiagnostic &PDiag) { |
| 1953 | (0) . __assert_fail ("Parent->isDependentContext() && \"cannot iterate dependent diagnostics of non-dependent context\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1954, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true">assert(Parent->isDependentContext() |
| 1954 | (0) . __assert_fail ("Parent->isDependentContext() && \"cannot iterate dependent diagnostics of non-dependent context\"", "/home/seafit/code_projects/clang_source/clang/lib/AST/DeclBase.cpp", 1954, __PRETTY_FUNCTION__))" file_link="../../../include/assert.h.html#88" macro="true"> && "cannot iterate dependent diagnostics of non-dependent context"); |
| 1955 | Parent = Parent->getPrimaryContext(); |
| 1956 | if (!Parent->LookupPtr) |
| 1957 | Parent->CreateStoredDeclsMap(C); |
| 1958 | |
| 1959 | auto *Map = static_cast<DependentStoredDeclsMap *>(Parent->LookupPtr); |
| 1960 | |
| 1961 | |
| 1962 | |
| 1963 | PartialDiagnostic::Storage *DiagStorage = nullptr; |
| 1964 | if (PDiag.hasStorage()) |
| 1965 | DiagStorage = new (C) PartialDiagnostic::Storage; |
| 1966 | |
| 1967 | auto *DD = new (C) DependentDiagnostic(PDiag, DiagStorage); |
| 1968 | |
| 1969 | |
| 1970 | DD->NextDiagnostic = Map->FirstDiagnostic; |
| 1971 | Map->FirstDiagnostic = DD; |
| 1972 | |
| 1973 | return DD; |
| 1974 | } |
| 1975 | |