Commit a313a121 by Karl Schimpf

Add correction message to bad linkage error.

Adds message to use "-allow-externally-defined-symbols" on bad linkage errors. Also cleans up code by defining common reporting routine. BUG=None R=stichnot@chromium.org Review URL: https://codereview.chromium.org/1392273002 .
parent 3e53dc99
...@@ -1309,7 +1309,7 @@ void TargetX86Base<Machine>::lowerArithmetic(const InstArithmetic *Inst) { ...@@ -1309,7 +1309,7 @@ void TargetX86Base<Machine>::lowerArithmetic(const InstArithmetic *Inst) {
++SwapCount; ++SwapCount;
} }
assert(SwapCount <= 1); assert(SwapCount <= 1);
(void) SwapCount; (void)SwapCount;
} }
if (!Traits::Is64Bit && Dest->getType() == IceType_i64) { if (!Traits::Is64Bit && Dest->getType() == IceType_i64) {
// These x86-32 helper-call-involved instructions are lowered in this // These x86-32 helper-call-involved instructions are lowered in this
......
...@@ -473,18 +473,23 @@ private: ...@@ -473,18 +473,23 @@ private:
} }
} }
// Converts function declarations into constant value IDs. void reportLinkageError(const char *Kind,
void createValueIDsForFunctions() { const Ice::GlobalDeclaration &Decl) {
Ice::GlobalContext *Ctx = getTranslator().getContext();
for (const Ice::FunctionDeclaration *Func : FunctionDeclarations) {
if (!Func->verifyLinkageCorrect(Ctx)) {
std::string Buffer; std::string Buffer;
raw_string_ostream StrBuf(Buffer); raw_string_ostream StrBuf(Buffer);
StrBuf << "Function " << Func->getName() StrBuf << Kind << " " << Decl.getName()
<< " has incorrect linkage: " << Func->getLinkageName(); << " has incorrect linkage: " << Decl.getLinkageName();
if (Decl.isExternal())
StrBuf << "\n Use flag -allow-externally-defined-symbols to override";
Error(StrBuf.str()); Error(StrBuf.str());
continue;
} }
// Converts function declarations into constant value IDs.
void createValueIDsForFunctions() {
Ice::GlobalContext *Ctx = getTranslator().getContext();
for (const Ice::FunctionDeclaration *Func : FunctionDeclarations) {
if (!Func->verifyLinkageCorrect(Ctx))
reportLinkageError("Function", *Func);
Ice::Constant *C = nullptr; Ice::Constant *C = nullptr;
if (!isIRGenerationDisabled()) { if (!isIRGenerationDisabled()) {
C = getConstantSym(Func->getName(), Func->getSuppressMangling(), C = getConstantSym(Func->getName(), Func->getSuppressMangling(),
...@@ -498,13 +503,8 @@ private: ...@@ -498,13 +503,8 @@ private:
void createValueIDsForGlobalVars() { void createValueIDsForGlobalVars() {
Ice::GlobalContext *Ctx = getTranslator().getContext(); Ice::GlobalContext *Ctx = getTranslator().getContext();
for (const Ice::VariableDeclaration *Decl : *VariableDeclarations) { for (const Ice::VariableDeclaration *Decl : *VariableDeclarations) {
if (!Decl->verifyLinkageCorrect(Ctx)) { if (!Decl->verifyLinkageCorrect(Ctx))
std::string Buffer; reportLinkageError("Global", *Decl);
raw_string_ostream StrBuf(Buffer);
StrBuf << "Global " << Decl->getName()
<< " has incorrect linkage: " << Decl->getLinkageName();
Error(StrBuf.str());
}
Ice::Constant *C = nullptr; Ice::Constant *C = nullptr;
if (!isIRGenerationDisabled()) { if (!isIRGenerationDisabled()) {
C = getConstantSym(Decl->getName(), Decl->getSuppressMangling(), C = getConstantSym(Decl->getName(), Decl->getSuppressMangling(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment