<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>LGTM.</div><div><br></div><div>Thanks Tom.</div><div apple-content-edited="true">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">-Quentin</div>
</div>
<br><div style=""><div>On Apr 15, 2014, at 10:32 AM, Tom Stellard <<a href="mailto:tom@stellard.net">tom@stellard.net</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Quentin,<br><br>Here is an updated patch with the default case. OK to commit?<br><br>Thanks,<br>Tom<br><br>On Fri, Apr 11, 2014 at 09:33:12AM -0700, Quentin Colombet wrote:<br><blockquote type="cite">Hi Tom,<br><br>This LGTM with one comment:<br>+ switch(unwrap(DI)->getSeverity()) {<br>+ case DS_Error:<br>+ severity = LLVMDSError;<br>+ break;<br>+ case DS_Warning:<br>+ severity = LLVMDSWarning;<br>+ break;<br>+ case DS_Remark:<br>+ severity = LLVMDSRemark;<br>+ break;<br>+ case DS_Note:<br>+ severity = LLVMDSNote;<br>+ break;<br>+ }<br><br>You may want to add a default case that default to LLVMDSError in case the header is not in sync with the actual API.<br>That said, I do not know if it can happen.<br><br>One side question, do we have any API_VERSION macro for the LLVM C API?<br>From the client point of view, how can we know that some specific features are available?<br><br>Thanks,<br>-Quentin<br>On Apr 10, 2014, at 7:03 AM, Tom Stellard <<a href="mailto:tom@stellard.net">tom@stellard.net</a>> wrote:<br><br><blockquote type="cite">Hi,<br><br>Here is an updated patch that exposes severity and also adds a comment<br>about using LLVMDisposeMessage.<br><br>-Tom<br><br><br>On Sat, Apr 05, 2014 at 06:02:23AM -0700, Eric Christopher wrote:<br><blockquote type="cite">*shrug* I take a conservative view on the C API, but since so many<br>people want it I'll say OK :)<br><br>-eric<br><br>On Fri, Apr 4, 2014 at 3:04 PM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br><blockquote type="cite">Why not expose severity? That seems like one of the more stable aspects of<br>our diagnostics. Besides, it's just another enum that we promise to keep<br>stable.<br><br><br>On Fri, Apr 4, 2014 at 10:59 AM, Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>><br>wrote:<br><blockquote type="cite"><br>I'd very much prefer not to expose the severity for now. This is a<br>fairly well thought out, but very new interface and we guarantee<br>stability of the C interface so we'd be locking the current severity<br>interface down.<br><br>I'm not, honestly, a huge fan of opening this up to the C API in<br>general - is there a good reason to do so?<br><br>-eric<br><br>On Fri, Apr 4, 2014 at 10:39 AM, Quentin Colombet <<a href="mailto:qcolombet@apple.com">qcolombet@apple.com</a>><br>wrote:<br><blockquote type="cite">Hi Darren,<br><br>This LGTM with two comments:<br>- LLVMPrintDiagInfoToString should state that the string has to be freed<br>(see inline comment).<br>- Should we provide an API to expose the severity as well? What would do<br>the<br>users of LLVMPrintDiagInfoToString if we do not?<br><br>Note that I'm not super familiar with the C API, so you may want to wait<br>for<br>another review.<br><br>Thanks,<br>-Quentin<br><br>On Apr 2, 2014, at 8:32 PM, Tom Stellard <<a href="mailto:tom@stellard.net">tom@stellard.net</a>> wrote:<br><br>From: Darren Powell <<a href="mailto:darren.powell@amd.com">darren.powell@amd.com</a>><br><br>---<br>include/llvm-c/Core.h | 20 ++++++++++++++++++++<br>include/llvm/IR/DiagnosticInfo.h | 3 +++<br>lib/IR/Core.cpp | 20 ++++++++++++++++++++<br>3 files changed, 43 insertions(+)<br><br>diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h<br>index 50c5e3a..17367ff 100644<br>--- a/include/llvm-c/Core.h<br>+++ b/include/llvm-c/Core.h<br>@@ -124,6 +124,12 @@ typedef struct LLVMOpaquePassRegistry<br>*LLVMPassRegistryRef;<br>* @see llvm::Use */<br>typedef struct LLVMOpaqueUse *LLVMUseRef;<br><br>+<br>+/**<br>+ * @see llvm::DiagnosticInfo<br>+ */<br>+typedef struct LLVMOpaqueDiagnosticInfo *LLVMDiagnosticInfoRef;<br>+<br>typedef enum {<br> LLVMZExtAttribute = 1<<0,<br> LLVMSExtAttribute = 1<<1,<br>@@ -453,6 +459,8 @@ void LLVMEnablePrettyStackTrace(void);<br>* @{<br>*/<br><br>+typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *);<br>+<br>/**<br>* Create a new context.<br>*<br>@@ -467,6 +475,13 @@ LLVMContextRef LLVMContextCreate(void);<br>LLVMContextRef LLVMGetGlobalContext(void);<br><br>/**<br>+ * Set the diagnostic handler for this context.<br>+ */<br>+void LLVMContextSetDiagnosticHandler(LLVMContextRef C,<br>+ LLVMDiagnosticHandler Handler,<br>+ void *DiagnosticContext);<br>+<br>+/**<br>* Destroy a context instance.<br>*<br>* This should be called for every call to LLVMContextCreate() or memory<br>@@ -474,6 +489,11 @@ LLVMContextRef LLVMGetGlobalContext(void);<br>*/<br>void LLVMContextDispose(LLVMContextRef C);<br><br>+/**<br>+ * Extract string description from DiagnosticInfo.<br><br><br>Add a comment here saying that the string should be freed using<br>LLVMDisposeMessage.<br><br>+ */<br>+char *LLVMPrintDiagInfoToString(LLVMDiagnosticInfoRef DI);<br>+<br>unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char* Name,<br> unsigned SLen);<br>unsigned LLVMGetMDKindID(const char* Name, unsigned SLen);<br>diff --git a/include/llvm/IR/DiagnosticInfo.h<br>b/include/llvm/IR/DiagnosticInfo.h<br>index de2a9d8..5fd6636 100644<br>--- a/include/llvm/IR/DiagnosticInfo.h<br>+++ b/include/llvm/IR/DiagnosticInfo.h<br>@@ -193,6 +193,9 @@ public:<br> }<br>};<br><br>+// Create wrappers for C Binding types (see CBindingWrapping.h).<br>+DEFINE_SIMPLE_CONVERSION_FUNCTIONS(DiagnosticInfo,<br>LLVMDiagnosticInfoRef)<br>+<br>} // End namespace llvm<br><br>#endif<br>diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp<br>index 4f3d8b1..e3b70c7 100644<br>--- a/lib/IR/Core.cpp<br>+++ b/lib/IR/Core.cpp<br>@@ -17,6 +17,8 @@<br>#include "llvm/IR/Attributes.h"<br>#include "llvm/IR/CallSite.h"<br>#include "llvm/IR/Constants.h"<br>+#include "llvm/IR/DiagnosticInfo.h"<br>+#include "llvm/IR/DiagnosticPrinter.h"<br>#include "llvm/IR/DerivedTypes.h"<br>#include "llvm/IR/GlobalAlias.h"<br>#include "llvm/IR/GlobalVariable.h"<br>@@ -76,6 +78,14 @@ LLVMContextRef LLVMGetGlobalContext() {<br> return wrap(&getGlobalContext());<br>}<br><br>+void LLVMContextSetDiagnosticHandler(LLVMContextRef C,<br>+ LLVMDiagnosticHandler Handler,<br>+ void *DiagnosticContext) {<br>+ unwrap(C)->setDiagnosticHandler(<br>+ LLVM_EXTENSION<br>reinterpret_cast<LLVMContext::DiagnosticHandlerTy>(Handler),<br>+ DiagnosticContext);<br>+}<br>+<br>void LLVMContextDispose(LLVMContextRef C) {<br> delete unwrap(C);<br>}<br>@@ -89,6 +99,16 @@ unsigned LLVMGetMDKindID(const char* Name, unsigned<br>SLen)<br>{<br> return LLVMGetMDKindIDInContext(LLVMGetGlobalContext(), Name, SLen);<br>}<br><br>+char *LLVMPrintDiagInfoToString(LLVMDiagnosticInfoRef DI) {<br>+ std::string MsgStorage;<br>+ raw_string_ostream Stream(MsgStorage);<br>+ DiagnosticPrinterRawOStream DP(Stream);<br>+<br>+ unwrap(DI)->print(DP);<br>+ Stream.flush();<br>+<br>+ return strdup(MsgStorage.c_str());<br>+}<br><br>/*===-- Operations on modules<br>---------------------------------------------===*/<br><br>--<br>1.8.3.2<br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br><br><br><br>_______________________________________________<br>llvm-commits mailing list<br>llvm-commits@cs.uiuc.edu<br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br><br></blockquote>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></blockquote><br><br></blockquote>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></blockquote><0001-VER-2-Added-new-functionality-to-LLVM-C-API-to-use-D.patch><br></blockquote><br></blockquote><span><0001-VER-3-Added-new-functionality-to-LLVM-C-API-to-use-D.patch></span></blockquote></div><br></body></html>