diff options
author | Quentin Colombet <qcolombet@apple.com> | 2016-02-03 22:41:00 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2016-02-03 22:41:00 +0000 |
commit | 043406b87f57c37c162352636d93313550c19ab2 (patch) | |
tree | 68820f7823c01f9fdd4c91a5bdddd3d95ed461bc /clang/lib/AST/ASTContext.cpp | |
parent | 460ce9cd9b4f426c4ebc7dd759997fd74f368f27 (diff) | |
download | bcm5719-llvm-043406b87f57c37c162352636d93313550c19ab2.tar.gz bcm5719-llvm-043406b87f57c37c162352636d93313550c19ab2.zip |
Reapply r259624, it is likely not the commit causing the bot failures.
Original message:
Make CF constant string decl visible to name lookup to fix module errors
The return type of the __builtin___*StringMakeConstantString functions
is a pointer to a struct, so we need that struct to be visible to name
lookup so that we will correctly merge multiple declarations of that
type if they come from different modules.
Incidentally, to make this visible to name lookup we need to rename the
type to __NSConstantString, since the real NSConstantString is an
Objective-C interface type. This shouldn't affect anyone outside the
compiler since users of the constant string builtins cast the result
immediately to CFStringRef.
Since this struct type is otherwise implicitly created by the AST
context and cannot access namelookup, we make this a predefined type
and initialize it in Sema.
Note: this issue of builtins that refer to types not visible to name
lookup technically also affects other builtins (e.g. objc_msgSendSuper),
but in all other cases the builtin is a library builtin and the issue
goes away if you include the library that defines the types it uses,
unlike for these constant string builtins.
rdar://problem/24425801
llvm-svn: 259721
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 02b3e51d1de..fc5ff8668e9 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4868,10 +4868,11 @@ int ASTContext::getIntegerTypeOrder(QualType LHS, QualType RHS) const { return 1; } -// getCFConstantStringType - Return the type used for constant CFStrings. -QualType ASTContext::getCFConstantStringType() const { +TagDecl *ASTContext::getCFConstantStringDecl() const { if (!CFConstantStringTypeDecl) { - CFConstantStringTypeDecl = buildImplicitRecord("NSConstantString"); + // This type is designed to be compatible with NSConstantString, but cannot + // use the same name, since NSConstantString is an interface. + CFConstantStringTypeDecl = buildImplicitRecord("__NSConstantString"); CFConstantStringTypeDecl->startDefinition(); QualType FieldTypes[4]; @@ -4901,7 +4902,12 @@ QualType ASTContext::getCFConstantStringType() const { CFConstantStringTypeDecl->completeDefinition(); } - return getTagDeclType(CFConstantStringTypeDecl); + return CFConstantStringTypeDecl; +} + +// getCFConstantStringType - Return the type used for constant CFStrings. +QualType ASTContext::getCFConstantStringType() const { + return getTagDeclType(getCFConstantStringDecl()); } QualType ASTContext::getObjCSuperType() const { |