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 .
diff --git a/src/IceTargetLoweringX86BaseImpl.h b/src/IceTargetLoweringX86BaseImpl.h
index 755d9ca..16f2b2f 100644
--- a/src/IceTargetLoweringX86BaseImpl.h
+++ b/src/IceTargetLoweringX86BaseImpl.h
@@ -1309,7 +1309,7 @@
++SwapCount;
}
assert(SwapCount <= 1);
- (void) SwapCount;
+ (void)SwapCount;
}
if (!Traits::Is64Bit && Dest->getType() == IceType_i64) {
// These x86-32 helper-call-involved instructions are lowered in this
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index 7124da0..755971d 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -473,18 +473,23 @@
}
}
+ void reportLinkageError(const char *Kind,
+ const Ice::GlobalDeclaration &Decl) {
+ std::string Buffer;
+ raw_string_ostream StrBuf(Buffer);
+ StrBuf << Kind << " " << Decl.getName()
+ << " has incorrect linkage: " << Decl.getLinkageName();
+ if (Decl.isExternal())
+ StrBuf << "\n Use flag -allow-externally-defined-symbols to override";
+ Error(StrBuf.str());
+ }
+
// Converts function declarations into constant value IDs.
void createValueIDsForFunctions() {
Ice::GlobalContext *Ctx = getTranslator().getContext();
for (const Ice::FunctionDeclaration *Func : FunctionDeclarations) {
- if (!Func->verifyLinkageCorrect(Ctx)) {
- std::string Buffer;
- raw_string_ostream StrBuf(Buffer);
- StrBuf << "Function " << Func->getName()
- << " has incorrect linkage: " << Func->getLinkageName();
- Error(StrBuf.str());
- continue;
- }
+ if (!Func->verifyLinkageCorrect(Ctx))
+ reportLinkageError("Function", *Func);
Ice::Constant *C = nullptr;
if (!isIRGenerationDisabled()) {
C = getConstantSym(Func->getName(), Func->getSuppressMangling(),
@@ -498,13 +503,8 @@
void createValueIDsForGlobalVars() {
Ice::GlobalContext *Ctx = getTranslator().getContext();
for (const Ice::VariableDeclaration *Decl : *VariableDeclarations) {
- if (!Decl->verifyLinkageCorrect(Ctx)) {
- std::string Buffer;
- raw_string_ostream StrBuf(Buffer);
- StrBuf << "Global " << Decl->getName()
- << " has incorrect linkage: " << Decl->getLinkageName();
- Error(StrBuf.str());
- }
+ if (!Decl->verifyLinkageCorrect(Ctx))
+ reportLinkageError("Global", *Decl);
Ice::Constant *C = nullptr;
if (!isIRGenerationDisabled()) {
C = getConstantSym(Decl->getName(), Decl->getSuppressMangling(),