Skip to content

Instantly share code, notes, and snippets.

@nchaimov
Created March 12, 2013 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nchaimov/5147298 to your computer and use it in GitHub Desktop.
Save nchaimov/5147298 to your computer and use it in GitHub Desktop.
Code to reproduce problem with getAssociatedFunctionDeclaration in ROSE with EDG 4.4.
#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;
}
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