mirror of
https://github.com/nasa/trick.git
synced 2025-01-30 16:13:55 +00:00
Is Trick ICG missing some uses of TRICK_ICG #608
Yes, it is, it's missing all of them. Any clang/llvm version 3.5 and above. So it's been broken for a while. We inherit from a clang class that processes preprocessing statements. If we override virtual functions of a certain signature, we can inject our code into the preprocessing process. In this case we're looking for the use of TRICK_ICG. Clang changed the function signature in version 3.5. From 3.5 on our functions were never called, so we never would find TRICK_ICG. I created new signatures for the functions post 3.5 so they will work again.
This commit is contained in:
parent
c44239a382
commit
f412125715
@ -35,7 +35,12 @@ void FindTrickICG::FileChanged(clang::SourceLocation Loc, FileChangeReason Reaso
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) {
|
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
||||||
|
void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue)
|
||||||
|
#else
|
||||||
|
void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
if ( ConditionRange.isValid() ) {
|
if ( ConditionRange.isValid() ) {
|
||||||
// Get the full text of the if statement into a string
|
// Get the full text of the if statement into a string
|
||||||
clang::FullSourceLoc fsl_begin(ConditionRange.getBegin() , ci.getSourceManager()) ;
|
clang::FullSourceLoc fsl_begin(ConditionRange.getBegin() , ci.getSourceManager()) ;
|
||||||
@ -67,12 +72,22 @@ void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRan
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindTrickICG::ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) {
|
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
||||||
|
void FindTrickICG::ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue)
|
||||||
|
#else
|
||||||
|
void FindTrickICG::ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
// Do the same processing for an #elif statement as an #if statement.
|
// Do the same processing for an #elif statement as an #if statement.
|
||||||
If(Loc,ConditionRange,ConditionValue) ;
|
If(Loc,ConditionRange,ConditionValue) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) {
|
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
||||||
|
void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD)
|
||||||
|
#else
|
||||||
|
void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
// Get the token name that is being tested.
|
// Get the token name that is being tested.
|
||||||
std::string name = MacroNameTok.getIdentifierInfo()->getName().str() ;
|
std::string name = MacroNameTok.getIdentifierInfo()->getName().str() ;
|
||||||
if ( ! name.compare("TRICK_ICG") ) {
|
if ( ! name.compare("TRICK_ICG") ) {
|
||||||
@ -94,7 +109,12 @@ void FindTrickICG::Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNam
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindTrickICG::Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) {
|
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
||||||
|
void FindTrickICG::Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD)
|
||||||
|
#else
|
||||||
|
void FindTrickICG::Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
// Get the token name that is being tested.
|
// Get the token name that is being tested.
|
||||||
std::string name = MacroNameTok.getIdentifierInfo()->getName().str() ;
|
std::string name = MacroNameTok.getIdentifierInfo()->getName().str() ;
|
||||||
if ( ! name.compare("TRICK_ICG") ) {
|
if ( ! name.compare("TRICK_ICG") ) {
|
||||||
|
@ -21,10 +21,17 @@ class FindTrickICG : public clang::PPCallbacks {
|
|||||||
clang::FileID PrevFID = clang::FileID()) ;
|
clang::FileID PrevFID = clang::FileID()) ;
|
||||||
|
|
||||||
// callbacks called when the preprocessor directives of types are processed.
|
// callbacks called when the preprocessor directives of types are processed.
|
||||||
|
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
||||||
|
virtual void If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue) ;
|
||||||
|
virtual void ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, clang::PPCallbacks::ConditionValueKind ConditionValue) ;
|
||||||
|
virtual void Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) ;
|
||||||
|
virtual void Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDefinition &MD) ;
|
||||||
|
#else
|
||||||
virtual void If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) ;
|
virtual void If(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) ;
|
||||||
virtual void ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) ;
|
virtual void ElIf(clang::SourceLocation Loc, clang::SourceRange ConditionRange, bool ConditionValue) ;
|
||||||
virtual void Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) ;
|
virtual void Ifdef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) ;
|
||||||
virtual void Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) ;
|
virtual void Ifndef(clang::SourceLocation Loc, const clang::Token &MacroNameTok, const clang::MacroDirective *MD) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
// print a warning about using TRICK_ICG.
|
// print a warning about using TRICK_ICG.
|
||||||
void print_header() ;
|
void print_header() ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user