[cfe-commits] r152481 - in /cfe/trunk: include/clang/AST/TypeLoc.h lib/Sema/SemaType.cpp test/Index/index-invalid-code.m

Argyrios Kyrtzidis akyrtzi at gmail.com
Fri Mar 9 19:20:58 PST 2012


Author: akirtzidis
Date: Fri Mar  9 21:20:58 2012
New Revision: 152481

URL: http://llvm.org/viewvc/llvm-project?rev=152481&view=rev
Log:
[Sema] A tag decl that is marked as invalid and is used in a decl-spec,
should not impede creating a proper TypeLoc info for the decl-spec.

This improves our semantic error recovery.

Added:
    cfe/trunk/test/Index/index-invalid-code.m
Modified:
    cfe/trunk/include/clang/AST/TypeLoc.h
    cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/AST/TypeLoc.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=152481&r1=152480&r2=152481&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)
+++ cfe/trunk/include/clang/AST/TypeLoc.h Fri Mar  9 21:20:58 2012
@@ -572,8 +572,9 @@
 
   /// \brief True if the tag was defined in this type specifier.
   bool isDefinition() const {
-    return getDecl()->isCompleteDefinition() &&
-         (getNameLoc().isInvalid() || getNameLoc() == getDecl()->getLocation());
+    TagDecl *D = getDecl();
+    return D->isCompleteDefinition() &&
+         (D->getIdentifier() == 0 || D->getLocation() == getNameLoc());
   }
 };
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=152481&r1=152480&r2=152481&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Mar  9 21:20:58 2012
@@ -766,9 +766,6 @@
     ElaboratedTypeKeyword Keyword
       = ElaboratedType::getKeywordForTypeSpec(DS.getTypeSpecType());
     Result = S.getElaboratedType(Keyword, DS.getTypeSpecScope(), Result);
-
-    if (D->isInvalidDecl())
-      declarator.setInvalidType(true);
     break;
   }
   case DeclSpec::TST_typename: {

Added: cfe/trunk/test/Index/index-invalid-code.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-invalid-code.m?rev=152481&view=auto
==============================================================================
--- cfe/trunk/test/Index/index-invalid-code.m (added)
+++ cfe/trunk/test/Index/index-invalid-code.m Fri Mar  9 21:20:58 2012
@@ -0,0 +1,8 @@
+struct S {
+  int {
+};
+typedef struct S S;
+
+// RUN: c-index-test -index-file %s | FileCheck %s
+// CHECK: [indexDeclaration]: kind: struct | name: S |
+// CHECK-NOT: [indexDeclaration]: kind: struct | name: S |





More information about the cfe-commits mailing list