Distinguish Global variables from functions

Hey all…

I was writing a Function pass to print all the functions using runonFunction() method .but it is printing one global variable “x” at the same time which i just dont know how is getting there.how can i avoid “x” from printing?? . Here is the framgment of code of my pass

namespace {
// Hello - The first implementation, without getAnalysisUsage.
struct Test2 : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
Test2() : FunctionPass (&ID) {}

virtual bool runOnFunction(Function &BB) {
errs() << “Test1: “<<BB.getName()<<” “;
if (BB.empty())
errs()<<“true”<<”\n”;
else
errs()<<“false”<<“\n”;
return false;
}
};
}

Hi RAHUL GOYAL,

I was writing a Function pass to print all the functions using
runonFunction() method .but it is printing one global variable "x" at
the same time which i just dont know how is getting there.how can i
avoid "x" from printing?? .

it would be helpful to see the bitcode you are running this on.

Ciao,

Duncan.

hii

Please find attached herewith the “hello.cpp” file. also one interesting point is that if i declare the global variable “x” after any function declaration then it is not printed .

Rahul

hello.cpp (186 Bytes)

Hi Rahul,

Please find attached herewith the "hello.cpp" file.

this is not bitcode.

Ciao,

Duncan.