AsmParser: restore LLVM IR compatibility for linker_private{,_weak}

This restores the linker_private and linker_private_weak lexemes to permit
translation of the deprecated lexmes.  The behaviour is identical to the bitcode
handling: linker_private and linker_private_weak are handled as if private had
been specified.  This enables compatibility with IR generated by LLVM 3.4.

Reported on IRC by ki9a!

llvm-svn: 205675
This commit is contained in:
Saleem Abdulrasool 2014-04-05 20:51:58 +00:00
parent 6425696818
commit c12813576c
4 changed files with 25 additions and 0 deletions

View File

@ -481,6 +481,8 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(private);
KEYWORD(internal);
KEYWORD(linker_private); // NOTE: deprecated, for parser compatibility
KEYWORD(linker_private_weak); // NOTE: deprecated, for parser compatibility
KEYWORD(available_externally);
KEYWORD(linkonce);
KEYWORD(linkonce_odr);

View File

@ -247,6 +247,8 @@ bool LLParser::ParseTopLevelEntities() {
// ('constant'|'global') ...
case lltok::kw_private: // OptionalLinkage
case lltok::kw_internal: // OptionalLinkage
case lltok::kw_linker_private: // Obsolete OptionalLinkage
case lltok::kw_linker_private_weak: // Obsolete OptionalLinkage
case lltok::kw_weak: // OptionalLinkage
case lltok::kw_weak_odr: // OptionalLinkage
case lltok::kw_linkonce: // OptionalLinkage
@ -1286,6 +1288,10 @@ bool LLParser::ParseOptionalReturnAttrs(AttrBuilder &B) {
/// ::= 'common'
/// ::= 'extern_weak'
/// ::= 'external'
///
/// Deprecated Values:
/// ::= 'linker_private'
/// ::= 'linker_private_weak'
bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) {
HasLinkage = false;
switch (Lex.getKind()) {
@ -1303,6 +1309,13 @@ bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) {
case lltok::kw_common: Res = GlobalValue::CommonLinkage; break;
case lltok::kw_extern_weak: Res = GlobalValue::ExternalWeakLinkage; break;
case lltok::kw_external: Res = GlobalValue::ExternalLinkage; break;
case lltok::kw_linker_private:
case lltok::kw_linker_private_weak:
Lex.Lex();
// treat linker_private and linker_private_weak as PrivateLinkage
Res = GlobalValue::PrivateLinkage;
return false;
}
Lex.Lex();
HasLinkage = true;

View File

@ -39,6 +39,8 @@ namespace lltok {
kw_private,
kw_internal,
kw_linker_private, // NOTE: deprecated, for parser compatibility
kw_linker_private_weak, // NOTE: deprecated, for parser compatibility
kw_linkonce, kw_linkonce_odr,
kw_weak, kw_weak_odr, kw_appending,
kw_dllimport, kw_dllexport, kw_common, kw_available_externally,

View File

@ -0,0 +1,8 @@
; RUN: llvm-as -o - %s | llvm-dis | FileCheck %s
@.linker_private = linker_private unnamed_addr constant [15 x i8] c"linker_private\00", align 64
@.linker_private_weak = linker_private_weak unnamed_addr constant [20 x i8] c"linker_private_weak\00", align 64
; CHECK: @.linker_private = private unnamed_addr constant [15 x i8] c"linker_private\00", align 64
; CHECK: @.linker_private_weak = private unnamed_addr constant [20 x i8] c"linker_private_weak\00", align 64