From efa31a9831951de6222b65594f3c48bd36d28f9f Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sat, 5 Apr 2014 22:42:53 +0000 Subject: [PATCH] AsmParser: add a warning for compatibility parsing This adds a warning when linker_private or linker_private_weak is provided and we handle it in a compatible manner. Suggested by Chris Lattner! llvm-svn: 205681 --- llvm/lib/AsmParser/LLLexer.cpp | 4 ++++ llvm/lib/AsmParser/LLLexer.h | 4 ++++ llvm/lib/AsmParser/LLParser.cpp | 2 ++ .../deprecated-linker_private-linker_private_weak.ll | 9 +++++++++ 4 files changed, 19 insertions(+) diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index 4fec7e60fa6e..c717a53f3a96 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -34,6 +34,10 @@ bool LLLexer::Error(LocTy ErrorLoc, const Twine &Msg) const { return true; } +void LLLexer::Warning(LocTy WarningLoc, const Twine &Msg) const { + SM.PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg); +} + //===----------------------------------------------------------------------===// // Helper functions. //===----------------------------------------------------------------------===// diff --git a/llvm/lib/AsmParser/LLLexer.h b/llvm/lib/AsmParser/LLLexer.h index 85703c766b09..ad11d49b2594 100644 --- a/llvm/lib/AsmParser/LLLexer.h +++ b/llvm/lib/AsmParser/LLLexer.h @@ -63,6 +63,10 @@ namespace llvm { bool Error(LocTy L, const Twine &Msg) const; bool Error(const Twine &Msg) const { return Error(getLoc(), Msg); } + + void Warning(LocTy WarningLoc, const Twine &Msg) const; + void Warning(const Twine &Msg) const { return Warning(getLoc(), Msg); } + std::string getFilename() const; private: diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index b53b4ce7c0e0..b5c7f16ea2b8 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -1312,6 +1312,8 @@ bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) { case lltok::kw_linker_private: case lltok::kw_linker_private_weak: + Lex.Warning("'" + Lex.getStrVal() + "' is deprecated, treating as" + " PrivateLinkage"); Lex.Lex(); // treat linker_private and linker_private_weak as PrivateLinkage Res = GlobalValue::PrivateLinkage; diff --git a/llvm/test/Bitcode/deprecated-linker_private-linker_private_weak.ll b/llvm/test/Bitcode/deprecated-linker_private-linker_private_weak.ll index 538f6419a14d..12a527c7738f 100644 --- a/llvm/test/Bitcode/deprecated-linker_private-linker_private_weak.ll +++ b/llvm/test/Bitcode/deprecated-linker_private-linker_private_weak.ll @@ -1,4 +1,5 @@ ; RUN: llvm-as -o - %s | llvm-dis | FileCheck %s +; RUN: llvm-as -o /dev/null %s 2>&1 | FileCheck %s -check-prefix CHECK-WARNINGS @.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 @@ -6,3 +7,11 @@ ; 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 +; CHECK-WARNINGS: warning: '.linker_private' is deprecated, treating as PrivateLinkage +; CHECK-WARNINGS: @.linker_private = linker_private unnamed_addr constant [15 x i8] c"linker_private\00", align 64 +; CHECK-WARNINGS: ^ + +; CHECK-WARNINGS: warning: '.linker_private_weak' is deprecated, treating as PrivateLinkage +; CHECK-WARNINGS: @.linker_private_weak = linker_private_weak unnamed_addr constant [20 x i8] c"linker_private_weak\00", align 64 +; CHECK-WARNINGS: ^ +