erikjv created this revision. erikjv added reviewers: bkramer, klimek. erikjv added a subscriber: cfe-commits.
Declaration names in DeclSpec had only their start set to a valid location, so when the type specifier was missing, only the carret would be shown at the first character of the name of a member declaration. Now the whole identifier is underlined, which is useful for IDEs using libclang. Also, when the lookup for an identifier-expression failed, the end location for that identifier was invalid. Fixes PR25374. http://reviews.llvm.org/D21075 Files: lib/Sema/SemaExpr.cpp lib/Sema/SemaType.cpp Index: lib/Sema/SemaType.cpp =================================================================== --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -1335,8 +1335,11 @@ // specifiers in each declaration, and in the specifier-qualifier list in // each struct declaration and type name." if (S.getLangOpts().CPlusPlus) { + auto R = DS.getSourceRange(); + if (R.getEnd().isInvalid()) + R.setEnd(R.getBegin()); S.Diag(DeclLoc, diag::err_missing_type_specifier) - << DS.getSourceRange(); + << R; // When this occurs in C++ code, often something is very broken with the // value being declared, poison it as invalid so we don't get chains of Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -2057,7 +2057,9 @@ } // Give up, we can't recover. - Diag(R.getNameLoc(), diagnostic) << Name; + auto Builder = Diag(R.getNameLoc(), diagnostic) << Name; + if (Name.isIdentifier()) + Builder << SourceRange(R.getNameLoc()); return true; }
Index: lib/Sema/SemaType.cpp =================================================================== --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -1335,8 +1335,11 @@ // specifiers in each declaration, and in the specifier-qualifier list in // each struct declaration and type name." if (S.getLangOpts().CPlusPlus) { + auto R = DS.getSourceRange(); + if (R.getEnd().isInvalid()) + R.setEnd(R.getBegin()); S.Diag(DeclLoc, diag::err_missing_type_specifier) - << DS.getSourceRange(); + << R; // When this occurs in C++ code, often something is very broken with the // value being declared, poison it as invalid so we don't get chains of Index: lib/Sema/SemaExpr.cpp =================================================================== --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -2057,7 +2057,9 @@ } // Give up, we can't recover. - Diag(R.getNameLoc(), diagnostic) << Name; + auto Builder = Diag(R.getNameLoc(), diagnostic) << Name; + if (Name.isIdentifier()) + Builder << SourceRange(R.getNameLoc()); return true; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits