[PATCH] D20734: [clang-format] insert new #includes into correct blocks when cleaning up Replacement with cleanupAroundReplacements().
    Eric Liu via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Tue May 31 03:33:58 PDT 2016
    
    
  
ioeric added inline comments.
================
Comment at: unittests/Format/CleanupTest.cpp:310
@@ +309,3 @@
+
+  Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
----------------
djasper wrote:
> I'd pull out a lot of these environment setup things into abstractions in the test fixture. Maybe all you need is two functions like:
> 
>   insert(Code, Replaces);
> 
> and
> 
>   insertAndFormat(Code, Replaces);
> 
> ?
I had tried to pull out the environment setup...but it didn't seem to save much code without sacrificing flexibility.
In some test cases, we also need to add replacements other than header insertions, and those replacements construction uses `FileID`, so `createInMemoryFile` needs to stay in test functions.
`FormatStyle` differs among test cases, so it has to stay.
All we save might just be the two lines which could be either cleanup or cleanup+format.\
Any better ideas?
http://reviews.llvm.org/D20734
    
    
More information about the cfe-commits
mailing list