diff options
| author | Ted Kremenek <kremenek@apple.com> | 2015-05-14 22:07:25 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2015-05-14 22:07:25 +0000 |
| commit | c004b4d3a14ed14263d813e72009770214fb92c9 (patch) | |
| tree | 5bdbe661c0764285b1e52801930c246fecca3f08 /clang/lib/Sema | |
| parent | bf727ba371e6a39f865a76064cb20a6a8df07cbf (diff) | |
| download | bcm5719-llvm-c004b4d3a14ed14263d813e72009770214fb92c9.tar.gz bcm5719-llvm-c004b4d3a14ed14263d813e72009770214fb92c9.zip | |
Tweak availability checking to look through typedef declarations.
llvm-svn: 237396
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 8dee0eebc51..0c5c23a3e2a 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -104,13 +104,29 @@ DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc, bool ObjCPropertyAccess) { // See if this declaration is unavailable or deprecated. std::string Message; + AvailabilityResult Result = D->getAvailability(&Message); + + // For typedefs, if the typedef declaration appears available look + // to the underlying type to see if it is more restrictive. + while (const TypedefNameDecl *TD = TD = dyn_cast<TypedefNameDecl>(D)) { + if (Result == AR_Available) { + if (const TagType *TT = TD->getUnderlyingType()->getAs<TagType>()) { + D = TT->getDecl(); + Result = D->getAvailability(&Message); + continue; + } + } + break; + } // Forward class declarations get their attributes from their definition. if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(D)) { - if (IDecl->getDefinition()) + if (IDecl->getDefinition()) { D = IDecl->getDefinition(); + Result = D->getAvailability(&Message); + } } - AvailabilityResult Result = D->getAvailability(&Message); + if (const EnumConstantDecl *ECD = dyn_cast<EnumConstantDecl>(D)) if (Result == AR_Available) { const DeclContext *DC = ECD->getDeclContext(); |

