diff options
author | David Chisnall <csdavec@swan.ac.uk> | 2012-02-18 16:12:34 +0000 |
---|---|---|
committer | David Chisnall <csdavec@swan.ac.uk> | 2012-02-18 16:12:34 +0000 |
commit | 5f3c163b7b19a0c7e02509a0984ee1256bca890d (patch) | |
tree | 74dd15cc68de3827d547187dde3c192396bd3bb0 /lib/Sema/SemaDecl.cpp | |
parent | 65005eb83bad26ba406cc5ddcf744c3e3db1694e (diff) |
Implement #pragma redefine_extname.
This fixes PR5172 and allows clang to compile C++ programs on Solaris using the system headers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150881 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 796d2a2bb3..89f22cb72b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4059,6 +4059,13 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, NewVD->addAttr(::new (Context) AsmLabelAttr(SE->getStrTokenLoc(0), Context, Label)); + } else if (!ExtnameUndeclaredIdentifiers.empty()) { + llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I = + ExtnameUndeclaredIdentifiers.find(NewVD->getIdentifier()); + if (I != ExtnameUndeclaredIdentifiers.end()) { + NewVD->addAttr(I->second); + ExtnameUndeclaredIdentifiers.erase(I); + } } // Diagnose shadowed variables before filtering for scope. @@ -5157,6 +5164,13 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, StringLiteral *SE = cast<StringLiteral>(E); NewFD->addAttr(::new (Context) AsmLabelAttr(SE->getStrTokenLoc(0), Context, SE->getString())); + } else if (!ExtnameUndeclaredIdentifiers.empty()) { + llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I = + ExtnameUndeclaredIdentifiers.find(NewFD->getIdentifier()); + if (I != ExtnameUndeclaredIdentifiers.end()) { + NewFD->addAttr(I->second); + ExtnameUndeclaredIdentifiers.erase(I); + } } // Copy the parameter declarations from the declarator D to the function @@ -10152,6 +10166,24 @@ DeclResult Sema::ActOnModuleImport(SourceLocation AtLoc, return Import; } +void Sema::ActOnPragmaRedefineExtname(IdentifierInfo* Name, + IdentifierInfo* AliasName, + SourceLocation PragmaLoc, + SourceLocation NameLoc, + SourceLocation AliasNameLoc) { + Decl *PrevDecl = LookupSingleName(TUScope, Name, NameLoc, + LookupOrdinaryName); + AsmLabelAttr *Attr = + ::new (Context) AsmLabelAttr(AliasNameLoc, Context, AliasName->getName()); + fprintf(stderr, "Alias name: %s\n", AliasName->getName().str().c_str()); + + if (PrevDecl) + PrevDecl->addAttr(Attr); + else + (void)ExtnameUndeclaredIdentifiers.insert( + std::pair<IdentifierInfo*,AsmLabelAttr*>(Name, Attr)); +} + void Sema::ActOnPragmaWeakID(IdentifierInfo* Name, SourceLocation PragmaLoc, SourceLocation NameLoc) { |