aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/TypeLoc.h5
-rw-r--r--lib/Sema/SemaType.cpp3
-rw-r--r--test/Index/index-invalid-code.m8
3 files changed, 11 insertions, 5 deletions
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h
index 1c750965ae..aab87be7c4 100644
--- a/include/clang/AST/TypeLoc.h
+++ b/include/clang/AST/TypeLoc.h
@@ -572,8 +572,9 @@ public:
/// \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());
}
};
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 505cc8f769..919faa0a3c 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -766,9 +766,6 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
ElaboratedTypeKeyword Keyword
= ElaboratedType::getKeywordForTypeSpec(DS.getTypeSpecType());
Result = S.getElaboratedType(Keyword, DS.getTypeSpecScope(), Result);
-
- if (D->isInvalidDecl())
- declarator.setInvalidType(true);
break;
}
case DeclSpec::TST_typename: {
diff --git a/test/Index/index-invalid-code.m b/test/Index/index-invalid-code.m
new file mode 100644
index 0000000000..90845330b1
--- /dev/null
+++ b/test/Index/index-invalid-code.m
@@ -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 |