[cfe-dev] Where to put upcoming refcatoring tools

Stephen Kelly steveire at gmail.com
Tue Apr 24 08:42:24 PDT 2012


Manuel Klimek wrote:
>>>> Did anything come of this? I'm trying to find out how to write a clang
>>>> C++ rewriting tool.
>>>
>>> Not yet. Currently the majority of the refactoring infrastructure
>>> (besides the basic tooling support) is in a branch in
>>> ^cfe/branches/tooling. There are ways to write rewrite tools based on
>>> what's in mainline, it just requires a little more busy work on your
>>> side.
>>
>> That doesn't seem to be in the git repo as far as I can tell. However, I
>> checked out an old revision which has the ReplaceCStrCalls tool, and I
>> read through the MatchFinder API yesterday. I haven't tried it out yet
>> though. I presume that's what's in the branch?
> 
> The MatchFinder API and the RefactoringTool API
> (include/clang/Tooling/Refactoring.h).
> 
> The MatchFinder API would be useful in your case to find the cases you
> want to rewrite. The RefactoringTool API makes it possible to run over
> many TUs in one process and reply all the edits after deduplicating
> them, leaving your repository in a compilable state.
> 
> The ReplaceCStrCalls example is definitely the best one we currently
> have for refactorings.
> 

I tried building this branch with llvm trunk and got this error:

                                                                           
Linking CXX static library 
../../../../../lib/libclangStaticAnalyzerFrontend.a                                                                                                                                     
[ 89%] Built target clangStaticAnalyzerFrontend                                                                                                                                                                    
[ 89%] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/clangCodeGen.dir/CGDebugInfo.cpp.o
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp: In 
member function 'llvm::DIType clang::CodeGen::CGDebugInfo::CreateType(const 
clang::BuiltinType*)':                                          
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:354:40: 
error: no matching function for call to 
'llvm::DIBuilder::createForwardDecl(llvm::dwarf::dwarf_constants, const char 
[11], llvm::DIFile, int)'
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:354:40: 
note: candidate is:
/home/stephen/dev/src/llvm/include/llvm/Analysis/DIBuilder.h:351:12: note: 
llvm::DIType llvm::DIBuilder::createForwardDecl(unsigned int, 
llvm::StringRef, llvm::DIDescriptor, llvm::DIFile, unsigned int, unsigned 
int)
/home/stephen/dev/src/llvm/include/llvm/Analysis/DIBuilder.h:351:12: note:   
candidate expects 6 arguments, 4 provided
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:365:35: 
error: no matching function for call to 
'llvm::DIBuilder::createForwardDecl(llvm::dwarf::dwarf_constants, const char 
[11], llvm::DIFile, int)'
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:365:35: 
note: candidate is:
/home/stephen/dev/src/llvm/include/llvm/Analysis/DIBuilder.h:351:12: note: 
llvm::DIType llvm::DIBuilder::createForwardDecl(unsigned int, 
llvm::StringRef, llvm::DIDescriptor, llvm::DIFile, unsigned int, unsigned 
int)
/home/stephen/dev/src/llvm/include/llvm/Analysis/DIBuilder.h:351:12: note:   
candidate expects 6 arguments, 4 provided
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:386:35: 
error: no matching function for call to 
'llvm::DIBuilder::createForwardDecl(llvm::dwarf::dwarf_constants, const char 
[14], llvm::DIFile, int)'
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:386:35: 
note: candidate is:
/home/stephen/dev/src/llvm/include/llvm/Analysis/DIBuilder.h:351:12: note: 
llvm::DIType llvm::DIBuilder::createForwardDecl(unsigned int, 
llvm::StringRef, llvm::DIDescriptor, llvm::DIFile, unsigned int, unsigned 
int)
/home/stephen/dev/src/llvm/include/llvm/Analysis/DIBuilder.h:351:12: note:   
candidate expects 6 arguments, 4 provided
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp: In 
member function 'llvm::DIType 
clang::CodeGen::CGDebugInfo::createRecordFwdDecl(const clang::RecordDecl*, 
llvm::DIDescriptor)':
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:517:63: 
error: no matching function for call to 
'llvm::DIBuilder::createForwardDecl(unsigned int&, llvm::StringRef&, 
llvm::DIFile&, unsigned int&)'
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:517:63: 
note: candidate is:
/home/stephen/dev/src/llvm/include/llvm/Analysis/DIBuilder.h:351:12: note: 
llvm::DIType llvm::DIBuilder::createForwardDecl(unsigned int, 
llvm::StringRef, llvm::DIDescriptor, llvm::DIFile, unsigned int, unsigned 
int)
/home/stephen/dev/src/llvm/include/llvm/Analysis/DIBuilder.h:351:12: note:   
candidate expects 6 arguments, 4 provided
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp: In 
member function 'llvm::DIType clang::CodeGen::CGDebugInfo::CreateType(const 
clang::ObjCInterfaceType*, llvm::DIFile)':
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:1291:17: 
error: no matching function for call to 
'llvm::DIBuilder::createForwardDecl(llvm::dwarf::dwarf_constants, 
llvm::StringRef, llvm::DIFile&, unsigned int&, unsigned int&)'
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:1291:17: 
note: candidate is:
/home/stephen/dev/src/llvm/include/llvm/Analysis/DIBuilder.h:351:12: note: 
llvm::DIType llvm::DIBuilder::createForwardDecl(unsigned int, 
llvm::StringRef, llvm::DIDescriptor, llvm::DIFile, unsigned int, unsigned 
int)
/home/stephen/dev/src/llvm/include/llvm/Analysis/DIBuilder.h:351:12: note:   
no known conversion for argument 4 from 'unsigned int' to 'llvm::DIFile'
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp: In 
member function 'llvm::DIType 
clang::CodeGen::CGDebugInfo::createRecordFwdDecl(const clang::RecordDecl*, 
llvm::DIDescriptor)':
/home/stephen/dev/src/llvm/tools/clang/lib/CodeGen/CGDebugInfo.cpp:518:1: 
warning: control reaches end of non-void function [-Wreturn-type]
make[2]: *** 
[tools/clang/lib/CodeGen/CMakeFiles/clangCodeGen.dir/CGDebugInfo.cpp.o] 
Error 1
make[1]: *** [tools/clang/lib/CodeGen/CMakeFiles/clangCodeGen.dir/all] Error 
2
make: *** [all] Error 2


Could you give me a llvm commit I'd be able to build against? Or a patch to 
make it build again (I guess the extra needed arguments have to come from 
somewhere)?

Thanks,

Steve.





More information about the cfe-dev mailing list