[cfe-dev] libclang unexpected diagnostic
jiyang zhao
zjyzhaojiyang at yahoo.com.cn
Sat Dec 18 02:03:21 PST 2010
hi guys, i write a programme using libclang , as follows
//clang_test.cpp
int main( int argc, char** argv )
{
CXIndex Index = clang_createIndex( 0, 0 );
CXTranslationUnit TU = clang_parseTranslationUnit( Index, 0, argv, argc, 0, 0, CXTranslationUnit_None );
if(TU == NULL)
return -1;
for( unsigned I=0, N=clang_getNumDiagnostics( TU ); I<N; ++I )
{
CXDiagnostic Diag = clang_getDiagnostic( TU, I );
/*
*/
CXString String = clang_formatDiagnostic( Diag, clang_defaultDiagnosticDisplayOptions() );
fprintf( stderr, "Diag: %s\n", clang_getCString( String ) );
clang_disposeString( String );
/*
*/
for( unsigned J=0, M=clang_getDiagnosticNumFixIts( Diag ); J!=M; ++J )
{
CXSourceRange Range;
CXString Str2 = clang_getDiagnosticFixIt( Diag, J, &Range );
const char* str = clang_getCString( Str2 );
if( str!= 0 )
{
fprintf( stderr, "FixIt: %s\n", str );
CXSourceLocation Start = clang_getRangeStart( Range );
CXSourceLocation End = clang_getRangeEnd( Range );
unsigned line = 0;
unsigned column = 0;
clang_getSpellingLocation( Start, 0, &line, &column, 0 );
fprintf( stderr, "Range start: line [%d], column [%d]\n", line, column );
clang_getSpellingLocation( End, 0, &line, &column, 0 );
fprintf( stderr, "Range end: line [%d], column [%d]\n", line, column );
}
clang_disposeString( Str2 );
}
clang_disposeDiagnostic(Diag);
}
clang_disposeTranslationUnit( TU );
clang_disposeIndex( Index );
return 0;
}
//test.cpp
#include <stdio.h>
int PrintExtent( )
{
}
when run ./clang_test test.cpp, it prints
Diag: warning: ./clang_test: 'linker' input unused when '-fsyntax-only' is present
Diag: test.cpp:5:1: warning: control reaches end of non-void function [-Wreturn-type]
My question is why does it print the first message, and how can i forbid it to print this message.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101218/22fab91a/attachment.html>
More information about the cfe-dev
mailing list