update for PPCallbacks API changes in Clang3.3
Change-Id: I8493afa8e2264a42fba090c9c72f36f36cb2d165
This commit is contained in:
parent
a0d320096c
commit
b0a650ff8a
2 changed files with 43 additions and 2 deletions
|
@ -32,11 +32,19 @@ class CheckConfigMacros
|
|||
public:
|
||||
explicit CheckConfigMacros( CompilerInstance& compiler );
|
||||
virtual void run() override;
|
||||
#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 2
|
||||
virtual void MacroDefined( const Token& macroToken, const MacroInfo* info ) override;
|
||||
virtual void MacroUndefined( const Token& macroToken , const MacroInfo* info ) override;
|
||||
virtual void MacroUndefined( const Token& macroToken, const MacroInfo* info ) override;
|
||||
virtual void Ifdef( SourceLocation location, const Token& macroToken ) override;
|
||||
virtual void Ifndef( SourceLocation location, const Token& macroToken ) override;
|
||||
virtual void Defined( const Token& macroToken ) override;
|
||||
#else
|
||||
virtual void MacroDefined( const Token& macroToken, const MacroDirective* info ) override;
|
||||
virtual void MacroUndefined( const Token& macroToken, const MacroDirective* info ) override;
|
||||
virtual void Ifdef( SourceLocation location, const Token& macroToken, const MacroDirective* info ) override;
|
||||
virtual void Ifndef( SourceLocation location, const Token& macroToken, const MacroDirective* info ) override;
|
||||
virtual void Defined( const Token& macroToken, const MacroDirective* info ) override;
|
||||
#endif
|
||||
private:
|
||||
void checkMacro( const Token& macroToken, SourceLocation location );
|
||||
std::set< string > configMacros;
|
||||
|
@ -53,9 +61,16 @@ void CheckConfigMacros::run()
|
|||
// nothing, only check preprocessor usage
|
||||
}
|
||||
|
||||
#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 2
|
||||
void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroInfo* info )
|
||||
{
|
||||
const char* filename = compiler.getSourceManager().getPresumedLoc( info->getDefinitionLoc()).getFilename();
|
||||
SourceLocation location = info->getDefinitionLoc();
|
||||
#else
|
||||
void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroDirective* info )
|
||||
{
|
||||
SourceLocation location = info->getLocation();
|
||||
#endif
|
||||
const char* filename = compiler.getSourceManager().getPresumedLoc( location ).getFilename();
|
||||
if( filename != NULL
|
||||
&& ( strncmp( filename, BUILDDIR "/config_host/", strlen( BUILDDIR "/config_host/" )) == 0
|
||||
|| strncmp( filename, BUILDDIR "/config_build/", strlen( BUILDDIR "/config_build/" )) == 0 ))
|
||||
|
@ -65,22 +80,38 @@ void CheckConfigMacros::MacroDefined( const Token& macroToken, const MacroInfo*
|
|||
}
|
||||
}
|
||||
|
||||
#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 2
|
||||
void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroInfo* )
|
||||
#else
|
||||
void CheckConfigMacros::MacroUndefined( const Token& macroToken, const MacroDirective* )
|
||||
#endif
|
||||
{
|
||||
configMacros.erase( macroToken.getIdentifierInfo()->getName());
|
||||
}
|
||||
|
||||
#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 2
|
||||
void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken )
|
||||
#else
|
||||
void CheckConfigMacros::Ifdef( SourceLocation location, const Token& macroToken, const MacroDirective* )
|
||||
#endif
|
||||
{
|
||||
checkMacro( macroToken, location );
|
||||
}
|
||||
|
||||
#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 2
|
||||
void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken )
|
||||
#else
|
||||
void CheckConfigMacros::Ifndef( SourceLocation location, const Token& macroToken, const MacroDirective* )
|
||||
#endif
|
||||
{
|
||||
checkMacro( macroToken, location );
|
||||
}
|
||||
|
||||
#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 2
|
||||
void CheckConfigMacros::Defined( const Token& macroToken )
|
||||
#else
|
||||
void CheckConfigMacros::Defined( const Token& macroToken, const MacroDirective* )
|
||||
#endif
|
||||
{
|
||||
checkMacro( macroToken, macroToken.getLocation());
|
||||
}
|
||||
|
|
|
@ -33,7 +33,12 @@ class RtlConstAsciiMacro
|
|||
bool VisitCXXConstructExpr( CXXConstructExpr* expr );
|
||||
bool VisitCXXTemporaryObjectExpr( CXXTemporaryObjectExpr* expr );
|
||||
bool VisitStringLiteral( const StringLiteral* literal );
|
||||
#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 3
|
||||
virtual void MacroExpands( const Token& macro, const MacroInfo* info, SourceRange range ) override;
|
||||
#else
|
||||
virtual void MacroExpands( const Token& macro, const MacroDirective* directive,
|
||||
SourceRange range, const MacroArgs* args ) override;
|
||||
#endif
|
||||
private:
|
||||
map< SourceLocation, SourceLocation > expansions; // start location -> end location
|
||||
bool searchingForString;
|
||||
|
@ -53,7 +58,12 @@ void RtlConstAsciiMacro::run()
|
|||
}
|
||||
|
||||
|
||||
#if __clang_major__ < 3 || __clang_major__ == 3 && __clang_minor__ < 3
|
||||
void RtlConstAsciiMacro::MacroExpands( const Token& macro, const MacroInfo*, SourceRange range )
|
||||
#else
|
||||
void RtlConstAsciiMacro::MacroExpands( const Token& macro, const MacroDirective*,
|
||||
SourceRange range, const MacroArgs* )
|
||||
#endif
|
||||
{
|
||||
if( macro.getIdentifierInfo()->getName() != "RTL_CONSTASCII_USTRINGPARAM" )
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue