|
29 | 29 | #include "clang/AST/Type.h"
|
30 | 30 | #include "clang/Basic/IdentifierTable.h"
|
31 | 31 | #include "clang/Basic/LLVM.h"
|
| 32 | +#include "clang/Basic/LangOptions.h" |
32 | 33 | #include "clang/Basic/Module.h"
|
33 | 34 | #include "clang/Basic/ObjCRuntime.h"
|
34 | 35 | #include "clang/Basic/PartialDiagnostic.h"
|
@@ -410,81 +411,6 @@ bool Decl::isFileContextDecl() const {
|
410 | 411 | return DC && DC->isFileContext();
|
411 | 412 | }
|
412 | 413 |
|
413 |
| -bool Decl::isFlexibleArrayMemberLike( |
414 |
| - ASTContext &Ctx, const Decl *D, QualType Ty, |
415 |
| - LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel, |
416 |
| - bool IgnoreTemplateOrMacroSubstitution) { |
417 |
| - // For compatibility with existing code, we treat arrays of length 0 or |
418 |
| - // 1 as flexible array members. |
419 |
| - const auto *CAT = Ctx.getAsConstantArrayType(Ty); |
420 |
| - if (CAT) { |
421 |
| - using FAMKind = LangOptions::StrictFlexArraysLevelKind; |
422 |
| - |
423 |
| - llvm::APInt Size = CAT->getSize(); |
424 |
| - FAMKind StrictFlexArraysLevel = |
425 |
| - Ctx.getLangOpts().getStrictFlexArraysLevel(); |
426 |
| - |
427 |
| - if (StrictFlexArraysLevel == FAMKind::IncompleteOnly) |
428 |
| - return false; |
429 |
| - |
430 |
| - // GCC extension, only allowed to represent a FAM. |
431 |
| - if (Size.isZero()) |
432 |
| - return true; |
433 |
| - |
434 |
| - if (StrictFlexArraysLevel == FAMKind::ZeroOrIncomplete && Size.uge(1)) |
435 |
| - return false; |
436 |
| - |
437 |
| - if (StrictFlexArraysLevel == FAMKind::OneZeroOrIncomplete && Size.uge(2)) |
438 |
| - return false; |
439 |
| - } else if (!Ctx.getAsIncompleteArrayType(Ty)) { |
440 |
| - return false; |
441 |
| - } |
442 |
| - |
443 |
| - if (const auto *OID = dyn_cast_if_present<ObjCIvarDecl>(D)) |
444 |
| - return OID->getNextIvar() == nullptr; |
445 |
| - |
446 |
| - const auto *FD = dyn_cast_if_present<FieldDecl>(D); |
447 |
| - if (!FD) |
448 |
| - return false; |
449 |
| - |
450 |
| - if (CAT) { |
451 |
| - // GCC treats an array memeber of a union as an FAM if the size is one or |
452 |
| - // zero. |
453 |
| - llvm::APInt Size = CAT->getSize(); |
454 |
| - if (FD->getParent()->isUnion() && (Size.isZero() || Size.isOne())) |
455 |
| - return true; |
456 |
| - } |
457 |
| - |
458 |
| - // Don't consider sizes resulting from macro expansions or template argument |
459 |
| - // substitution to form C89 tail-padded arrays. |
460 |
| - if (IgnoreTemplateOrMacroSubstitution) { |
461 |
| - TypeSourceInfo *TInfo = FD->getTypeSourceInfo(); |
462 |
| - while (TInfo) { |
463 |
| - TypeLoc TL = TInfo->getTypeLoc(); |
464 |
| - |
465 |
| - // Look through typedefs. |
466 |
| - if (TypedefTypeLoc TTL = TL.getAsAdjusted<TypedefTypeLoc>()) { |
467 |
| - const TypedefNameDecl *TDL = TTL.getTypedefNameDecl(); |
468 |
| - TInfo = TDL->getTypeSourceInfo(); |
469 |
| - continue; |
470 |
| - } |
471 |
| - |
472 |
| - if (auto CTL = TL.getAs<ConstantArrayTypeLoc>()) { |
473 |
| - const Expr *SizeExpr = dyn_cast<IntegerLiteral>(CTL.getSizeExpr()); |
474 |
| - if (!SizeExpr || SizeExpr->getExprLoc().isMacroID()) |
475 |
| - return false; |
476 |
| - } |
477 |
| - |
478 |
| - break; |
479 |
| - } |
480 |
| - } |
481 |
| - |
482 |
| - // Test that the field is the last in the structure. |
483 |
| - RecordDecl::field_iterator FI( |
484 |
| - DeclContext::decl_iterator(const_cast<FieldDecl *>(FD))); |
485 |
| - return ++FI == FD->getParent()->field_end(); |
486 |
| -} |
487 |
| - |
488 | 414 | TranslationUnitDecl *Decl::getTranslationUnitDecl() {
|
489 | 415 | if (auto *TUD = dyn_cast<TranslationUnitDecl>(this))
|
490 | 416 | return TUD;
|
|
0 commit comments