Created
March 12, 2013 21:36
-
-
Save nchaimov/5147298 to your computer and use it in GitHub Desktop.
Code to reproduce problem with getAssociatedFunctionDeclaration in ROSE with EDG 4.4.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "rose.h" | |
class InheritedAttribute { | |
}; | |
class visitorTraversal : public AstTopDownProcessing<InheritedAttribute>{ | |
public: | |
virtual InheritedAttribute evaluateInheritedAttribute(SgNode* n, InheritedAttribute inheritedAttribute); | |
}; | |
InheritedAttribute visitorTraversal::evaluateInheritedAttribute(SgNode* n, InheritedAttribute inheritedAttribute) { SgExprStatement * expr = isSgExprStatement(n); | |
if(expr != NULL) { | |
SgFunctionCallExp * fcall = isSgFunctionCallExp(expr->get_expression()); | |
if(fcall != NULL) { | |
std::cout << "Function call: " << expr->unparseToString() << std::endl; | |
SgFunctionDeclaration * fdecl = fcall->getAssociatedFunctionDeclaration(); | |
if(fdecl != NULL) { | |
std::cout << "Associated function declaration: " << fdecl->get_name() << std::endl; | |
} | |
} | |
} | |
return inheritedAttribute; | |
} | |
int main(int argc, char * argv[]) { | |
SgProject * project = frontend(argc, argv); | |
ROSE_ASSERT(project != NULL); | |
InheritedAttribute inheritedAttribute; | |
visitorTraversal traversal; | |
traversal.traverse(project, inheritedAttribute); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef long unsigned int size_t; | |
template<typename _Tp> void swap(_Tp& __a, _Tp& __b) | |
{ | |
_Tp __tmp = __a; | |
__a = __b; __b = __tmp; | |
} | |
template<typename _Tp, size_t _Nm> void swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | |
{ | |
for (size_t __n = 0; __n < _Nm; ++__n) { | |
swap(__a[__n], __b[__n]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment