to judge whether a function it is a C/C++ standard library function or not

hello,everyone
I want to judge whether a function it is a C/C++ standard library function
or not,that is to say,I want to distinguish a function is a C/C++ standard
library function or written by users in his program.which clang API can I
use? thank you!

Rambo

Hi,

The simplest is to check whether the function is in the std:: namespace - although this only works for C++ headers.
A better method might be to get the SourceLocation of the FunctionDecl (e.g. with getLocStart()) and then use SourceManager :: isInSystemHeader and isInExternCSystemHeader.

Gabor

The simplest is to check whether the function is in the std:: namespace
- although this only works for C++ headers.

But note that user code can add certain template specializations to namespace std.

Stephan

I got it,thank you very much!

Rambo