On Dec 18, 2012, at 4:29 PM, Douglas Gregor <[email protected]> wrote:

> 
> On Dec 18, 2012, at 3:23 PM, Dmitri Gribenko <[email protected]> wrote:
> 
>> Hi Fariborz,
>> 
>> On Wed, Dec 19, 2012 at 1:03 AM, Fariborz Jahanian <[email protected]> 
>> wrote:
>>> Author: fjahanian
>>> Date: Tue Dec 18 17:02:59 2012
>>> New Revision: 170467
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=170467&view=rev
>>> Log:
>>> This is the libclang patch providing minimal API to
>>> use clang's formatter. Currently, formatter is used
>>> to format declaration tags for xml comments. Since formatter
>>> is in flux and its change will break several of the clang comment
>>> tests, only a single tests is formatted using this facility.
>>> Doug has reviewed and approved it for check-in.
>>> 
>>> 
>>> +  ASTContext &Context = FC->getDeclInfo()->CurrentDecl->getASTContext();
>>>  CXTranslationUnit TU = CXC.TranslationUnit;
>>>  SourceManager &SM = static_cast<ASTUnit *>(TU->TUData)->getSourceManager();
>>> +
>>> +  SimpleFormatContext *SFC =
>>> +    static_cast<SimpleFormatContext*>(TU->FormatContext);
>>> +  if (!SFC) {
>>> +    SFC = new SimpleFormatContext(Context.getLangOpts());
>>> +    TU->FormatContext = SFC;
>>> +  }
>>> +  else if ((TU->FormatInMemoryUniqueId % 10) == 0) {
>> 
>> Please put 'else' on the same line as '}'.
>> 
>>> +    delete SFC;
>>> +    SFC = new SimpleFormatContext(Context.getLangOpts());
>>> +    TU->FormatContext = SFC;
>>> +  }
>> 
>> I don't understand the reason for doing this 'delete'/'new'.  Could
>> you add a comment, please?  Are we holding off freeing lots of memory
>> until destruction?
> 
> The SourceManager and FileManager in the SimpleFormatContext will grow with 
> each thing we're formatting. To keep it from getting too large with stale 
> data, we're just recreating it every once in a while. Every 10 times is 
> probably excessive, though; it should be more like 1000.

Kept it small for testing. Increased to 1000 in r170481.
- fariborz


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to