[llvm-commits] [PATCH] Enhance TableGen with ranges and fixits

Sean Silva silvas at purdue.edu
Mon Jan 7 17:13:13 PST 2013


+  // Add any fix-its.
+  // FIXME: Handle multibyte characters (see Clang's TextDiagnostic).
+  std::string FixItInsertionLine;
+  if (!FixIts.empty()) {

+  // Print out the replacement line, matching tabs in the source line.
+  if (!FixItInsertionLine.empty()) {

Use early returns to decrease the nesting caused by both of these.
<http://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code>.

Also, what about testing the better diagnosticsi?

-- Sean Silva

On Mon, Jan 7, 2013 at 2:31 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> Second pass at this. TableGen and SMDiagnostic are being modified to
>
> (a) Track anonymous definitions.
> (b) Save source ranges for superclass references (for the fixits).
> (c) Actually emit fixits (only support here; fixits happening in clang-tblgen)
>
> This should be better than the previous scheme ranges should appear once per superclass per Record, which will not bloat TableGen's memory usage nearly as much as saving ranges on every DefInit. (I would have liked to do it only first the first time a superclass is mentioned, but TableGen represents multiple levels of inheritance by just copying the grandparent into the child as another superclass.) The fixits are a little worse but that's fine.
>
> Again, I'll post the Clang side on cfe-commits soon.
>
> Thanks!
> Jordan
>
>
>
>
>
> On Dec 11, 2012, at 9:44 , Jordan Rose <jordan_rose at apple.com> wrote:
>
>> Hi, Jakob et al. I've been working on adding a warning to Clang-side TableGen, and realized everyone would hate it if it didn't have fixits. So I went in and added the necessary information to TableGen so that it can (a) track anonymous definitions, (b) save source ranges for DefInits (for the fixit), and (c) actually emit fixits.
>>
>> The fixit work is fine, I think; it's added to SMDiagnostic, so actually any LLVM-level diagnostics could take advantage of it. My main worry is about the range-tracking info. TableGen currently doesn't do any memory management, but it does unique identical definitions. Once we're tracking source info, though, that uniquing isn't possible. Do we care, or is it okay because it's TableGen and it only runs once and then exits?
>>
>> I'll post the Clang side of the patch on cfe-commits soon.
>>
>> Thanks!
>> Jordan
>>
>> <0001-TableGen-record-anonymous-instantiations-of-classes.patch><0002-TableGen-save-source-ranges-for-DefInits.patch><0003-Add-basic-fix-its-to-SMDiagnostic.patch>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list