diff options
-rw-r--r-- | include/clang/Basic/DiagnosticFrontendKinds.td | 5 | ||||
-rw-r--r-- | lib/Frontend/CodeGenAction.cpp | 25 |
2 files changed, 21 insertions, 9 deletions
diff --git a/include/clang/Basic/DiagnosticFrontendKinds.td b/include/clang/Basic/DiagnosticFrontendKinds.td index c7cad7395c..50937790d8 100644 --- a/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/include/clang/Basic/DiagnosticFrontendKinds.td @@ -18,7 +18,10 @@ def err_fe_invalid_ast_action : Error<"invalid action for AST input">, DefaultFatal; // Error generated by the backend. def err_fe_inline_asm : Error<"%0">, CatInlineAsm; -def note_fe_inline_asm_here : Note<"generated from here">; +def note_fe_inline_asm_here : Note<"instantated into assembly here">; + + + def err_fe_invalid_code_complete_file : Error< "cannot locate code-completion file %0">, DefaultFatal; def err_fe_stdout_binary : Error<"unable to change standard output to binary">, diff --git a/lib/Frontend/CodeGenAction.cpp b/lib/Frontend/CodeGenAction.cpp index 22b3bd416d..dce9f3d216 100644 --- a/lib/Frontend/CodeGenAction.cpp +++ b/lib/Frontend/CodeGenAction.cpp @@ -200,19 +200,28 @@ void BackendConsumer::InlineAsmDiagHandler2(const llvm::SMDiagnostic &D, if (Message.startswith("error: ")) Message = Message.substr(7); - // There are two cases: the SMDiagnostic could have a inline asm source - // location or it might not. If it does, translate the location. + // If the SMDiagnostic has an inline asm source location, translate it. FullSourceLoc Loc; if (D.getLoc() != SMLoc()) Loc = ConvertBackendLocation(D, Context->getSourceManager()); - Diags.Report(Loc, diag::err_fe_inline_asm).AddString(Message); + - // This could be a problem with no clang-level source location information. - // In this case, LocCookie is invalid. If there is source level information, - // print an "generated from" note. - if (LocCookie.isValid()) + // If this problem has clang-level source location information, report the + // issue as being an error in the source with a note showing the instantiated + // code. + if (LocCookie.isValid()) { Diags.Report(FullSourceLoc(LocCookie, Context->getSourceManager()), - diag::note_fe_inline_asm_here); + diag::err_fe_inline_asm).AddString(Message); + + if (D.getLoc().isValid()) + Diags.Report(Loc, diag::note_fe_inline_asm_here); + return; + } + + // Otherwise, report the backend error as occuring in the generated .s file. + // If Loc is invalid, we still need to report the error, it just gets no + // location info. + Diags.Report(Loc, diag::err_fe_inline_asm).AddString(Message); } // |