Change indenting for case/compound statements to conform to the rest of clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84498 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Steve Naroff 2009-10-19 13:41:39 +00:00
Родитель c5a9e9511e
Коммит bade7de59d
1 изменённых файлов: 26 добавлений и 39 удалений

Просмотреть файл

@ -507,43 +507,38 @@ const char *clang_getCursorSpelling(CXCursor C)
if (clang_isReference(C.kind)) { if (clang_isReference(C.kind)) {
switch (C.kind) { switch (C.kind) {
case CXCursor_ObjCSuperClassRef: case CXCursor_ObjCSuperClassRef: {
{
ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND); ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND);
assert(OID && "clang_getCursorLine(): Missing interface decl"); assert(OID && "clang_getCursorLine(): Missing interface decl");
return OID->getSuperClass()->getIdentifier()->getNameStart(); return OID->getSuperClass()->getIdentifier()->getNameStart();
} }
case CXCursor_ObjCClassRef: case CXCursor_ObjCClassRef: {
{
if (ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND)) { if (ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND)) {
return OID->getIdentifier()->getNameStart(); return OID->getIdentifier()->getNameStart();
} }
ObjCCategoryDecl *OID = dyn_cast<ObjCCategoryDecl>(ND); ObjCCategoryDecl *OID = dyn_cast<ObjCCategoryDecl>(ND);
assert(OID && "clang_getCursorLine(): Missing category decl"); assert(OID && "clang_getCursorLine(): Missing category decl");
return OID->getClassInterface()->getIdentifier()->getNameStart(); return OID->getClassInterface()->getIdentifier()->getNameStart();
} }
case CXCursor_ObjCProtocolRef: case CXCursor_ObjCProtocolRef: {
{
ObjCProtocolDecl *OID = dyn_cast<ObjCProtocolDecl>(ND); ObjCProtocolDecl *OID = dyn_cast<ObjCProtocolDecl>(ND);
assert(OID && "clang_getCursorLine(): Missing protocol decl"); assert(OID && "clang_getCursorLine(): Missing protocol decl");
return OID->getIdentifier()->getNameStart(); return OID->getIdentifier()->getNameStart();
} }
case CXCursor_ObjCSelectorRef: case CXCursor_ObjCSelectorRef: {
{
ObjCMessageExpr *OME = dyn_cast<ObjCMessageExpr>( ObjCMessageExpr *OME = dyn_cast<ObjCMessageExpr>(
static_cast<Stmt *>(C.stmt)); static_cast<Stmt *>(C.stmt));
assert(OME && "clang_getCursorLine(): Missing message expr"); assert(OME && "clang_getCursorLine(): Missing message expr");
return OME->getSelector().getAsString().c_str(); return OME->getSelector().getAsString().c_str();
} }
case CXCursor_VarRef: case CXCursor_VarRef:
case CXCursor_FunctionRef: case CXCursor_FunctionRef:
case CXCursor_EnumConstantRef: case CXCursor_EnumConstantRef: {
{
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>( DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(
static_cast<Stmt *>(C.stmt)); static_cast<Stmt *>(C.stmt));
assert(DRE && "clang_getCursorLine(): Missing decl ref expr"); assert(DRE && "clang_getCursorLine(): Missing decl ref expr");
return DRE->getDecl()->getIdentifier()->getNameStart(); return DRE->getDecl()->getIdentifier()->getNameStart();
} }
default: default:
return "<not implemented>"; return "<not implemented>";
} }
@ -745,8 +740,7 @@ static SourceLocation getLocationFromCursor(CXCursor C,
NamedDecl *ND) { NamedDecl *ND) {
if (clang_isReference(C.kind)) { if (clang_isReference(C.kind)) {
switch (C.kind) { switch (C.kind) {
case CXCursor_ObjCClassRef: case CXCursor_ObjCClassRef: {
{
if (isa<ObjCInterfaceDecl>(ND)) { if (isa<ObjCInterfaceDecl>(ND)) {
// FIXME: This is a hack (storing the parent decl in the stmt slot). // FIXME: This is a hack (storing the parent decl in the stmt slot).
NamedDecl *parentDecl = static_cast<NamedDecl *>(C.stmt); NamedDecl *parentDecl = static_cast<NamedDecl *>(C.stmt);
@ -755,56 +749,49 @@ static SourceLocation getLocationFromCursor(CXCursor C,
ObjCCategoryDecl *OID = dyn_cast<ObjCCategoryDecl>(ND); ObjCCategoryDecl *OID = dyn_cast<ObjCCategoryDecl>(ND);
assert(OID && "clang_getCursorLine(): Missing category decl"); assert(OID && "clang_getCursorLine(): Missing category decl");
return OID->getClassInterface()->getLocation(); return OID->getClassInterface()->getLocation();
} }
case CXCursor_ObjCSuperClassRef: case CXCursor_ObjCSuperClassRef: {
{
ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND); ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND);
assert(OID && "clang_getCursorLine(): Missing interface decl"); assert(OID && "clang_getCursorLine(): Missing interface decl");
return OID->getSuperClassLoc(); return OID->getSuperClassLoc();
} }
case CXCursor_ObjCProtocolRef: case CXCursor_ObjCProtocolRef: {
{
ObjCProtocolDecl *OID = dyn_cast<ObjCProtocolDecl>(ND); ObjCProtocolDecl *OID = dyn_cast<ObjCProtocolDecl>(ND);
assert(OID && "clang_getCursorLine(): Missing protocol decl"); assert(OID && "clang_getCursorLine(): Missing protocol decl");
return OID->getLocation(); return OID->getLocation();
} }
case CXCursor_ObjCSelectorRef: case CXCursor_ObjCSelectorRef: {
{
ObjCMessageExpr *OME = dyn_cast<ObjCMessageExpr>( ObjCMessageExpr *OME = dyn_cast<ObjCMessageExpr>(
static_cast<Stmt *>(C.stmt)); static_cast<Stmt *>(C.stmt));
assert(OME && "clang_getCursorLine(): Missing message expr"); assert(OME && "clang_getCursorLine(): Missing message expr");
return OME->getLeftLoc(); /* FIXME: should be a range */ return OME->getLeftLoc(); /* FIXME: should be a range */
} }
case CXCursor_VarRef: case CXCursor_VarRef:
case CXCursor_FunctionRef: case CXCursor_FunctionRef:
case CXCursor_EnumConstantRef: case CXCursor_EnumConstantRef: {
{
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>( DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(
static_cast<Stmt *>(C.stmt)); static_cast<Stmt *>(C.stmt));
assert(DRE && "clang_getCursorLine(): Missing decl ref expr"); assert(DRE && "clang_getCursorLine(): Missing decl ref expr");
return DRE->getLocation(); return DRE->getLocation();
} }
default: default:
return SourceLocation(); return SourceLocation();
} }
} else { // We have a declaration or a definition. } else { // We have a declaration or a definition.
SourceLocation SLoc; SourceLocation SLoc;
switch (ND->getKind()) { switch (ND->getKind()) {
case Decl::ObjCInterface: case Decl::ObjCInterface: {
{
SLoc = dyn_cast<ObjCInterfaceDecl>(ND)->getClassLoc(); SLoc = dyn_cast<ObjCInterfaceDecl>(ND)->getClassLoc();
break; break;
} }
case Decl::ObjCProtocol: case Decl::ObjCProtocol: {
{
SLoc = ND->getLocation(); /* FIXME: need to get the name location. */ SLoc = ND->getLocation(); /* FIXME: need to get the name location. */
break; break;
} }
default: default: {
{
SLoc = ND->getLocation(); SLoc = ND->getLocation();
break; break;
} }
} }
if (SLoc.isInvalid()) if (SLoc.isInvalid())
return SourceLocation(); return SourceLocation();