CIndex: move extractUSRSuffix out of extern "C" and simplify it.

llvm-svn: 100773
This commit is contained in:
Benjamin Kramer 2010-04-08 15:54:07 +00:00
parent eadd3cace9
commit 31160e8469
1 changed files with 4 additions and 6 deletions

View File

@ -259,6 +259,10 @@ void USRGenerator::GenObjCProtocol(llvm::StringRef prot) {
// API hooks. // API hooks.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static inline llvm::StringRef extractUSRSuffix(llvm::StringRef s) {
return s.startswith("c:") ? s.substr(2) : "";
}
extern "C" { extern "C" {
CXString clang_getCursorUSR(CXCursor C) { CXString clang_getCursorUSR(CXCursor C) {
@ -276,12 +280,6 @@ CXString clang_getCursorUSR(CXCursor C) {
return createCXString(SUG.str(), true); return createCXString(SUG.str(), true);
} }
static inline llvm::StringRef extractUSRSuffix(llvm::StringRef s) {
if (!(s.size() >= 2 && s[0] == 'c' && s[1] == ':'))
return "";
return s.substr(2);
}
CXString clang_constructUSR_ObjCIvar(const char *name, CXString classUSR) { CXString clang_constructUSR_ObjCIvar(const char *name, CXString classUSR) {
StringUSRGenerator SUG; StringUSRGenerator SUG;
SUG << extractUSRSuffix(clang_getCString(classUSR)); SUG << extractUSRSuffix(clang_getCString(classUSR));