[PATCH] D33207: Fix an assertion failure in FormatASTNodeDiagnosticArgument.

2017-05-17 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303325: Fix an assertion failure in 
FormatASTNodeDiagnosticArgument. (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D33207?vs=99112=99386#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33207

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCXX/warn-shadow.cpp


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6935,7 +6935,7 @@
 }
 }
 
-  DeclContext *OldDC = ShadowedDecl->getDeclContext();
+  DeclContext *OldDC = ShadowedDecl->getDeclContext()->getRedeclContext();
 
   unsigned WarningDiag = diag::warn_decl_shadow;
   SourceLocation CaptureLoc;
Index: cfe/trunk/test/SemaCXX/warn-shadow.cpp
===
--- cfe/trunk/test/SemaCXX/warn-shadow.cpp
+++ cfe/trunk/test/SemaCXX/warn-shadow.cpp
@@ -206,3 +206,10 @@
 }
 
 }
+
+extern "C" {
+typedef int externC; // expected-note {{previous declaration is here}}
+}
+void handleLinkageSpec() {
+  typedef void externC; // expected-warning {{declaration shadows a typedef in 
the global namespace}}
+}


Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6935,7 +6935,7 @@
 }
 }
 
-  DeclContext *OldDC = ShadowedDecl->getDeclContext();
+  DeclContext *OldDC = ShadowedDecl->getDeclContext()->getRedeclContext();
 
   unsigned WarningDiag = diag::warn_decl_shadow;
   SourceLocation CaptureLoc;
Index: cfe/trunk/test/SemaCXX/warn-shadow.cpp
===
--- cfe/trunk/test/SemaCXX/warn-shadow.cpp
+++ cfe/trunk/test/SemaCXX/warn-shadow.cpp
@@ -206,3 +206,10 @@
 }
 
 }
+
+extern "C" {
+typedef int externC; // expected-note {{previous declaration is here}}
+}
+void handleLinkageSpec() {
+  typedef void externC; // expected-warning {{declaration shadows a typedef in the global namespace}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33207: Fix an assertion failure in FormatASTNodeDiagnosticArgument.

2017-05-17 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


https://reviews.llvm.org/D33207



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33207: Fix an assertion failure in FormatASTNodeDiagnosticArgument.

2017-05-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: test/SemaCXX/warn-shadow.cpp:214
+void handleLinkageSpec() {
+  typedef void externC; // expected-warning {{declaration shadows a typedef in 
linkage specification}}
+}

rsmith wrote:
> We should be producing a diagnostic talking about the enclosing namespace / 
> TU scope, not the linkage specification. Whoever is emitting the diagnostic 
> seems to be missing a call to `getRedeclContext()` -- although perhaps we 
> could do that in the diagnostic code instead.
I tried skipping transparent declaration contexts in 
`FormatASTNodeDiagnosticArgument`, but this causes three tests fail due to 
skipped enumeration names:
  error: 'error' diagnostics expected but not seen: 
File /src/tools/clang/test/Modules/Inputs/odr/b.h Line 5 (directive at 
/src/tools/clang/test/Modules/odr.cpp:21): 'E::e2' from module 'b' is not 
present in definition of 'E' in module 'a'
  error: 'error' diagnostics seen but not expected: 
File /src/tools/clang/test/Modules/Inputs/odr/b.h Line 5: 'E::e2' from 
module 'b' is not present in definition of the global namespace in module 'a'

  error: 'error' diagnostics expected but not seen: 
File /src/tools/clang/test/SemaCXX/nested-name-spec.cpp Line 434: no member 
named 'X2' in 'PR16951::enumerator_2'
  error: 'error' diagnostics seen but not expected: 
File /src/tools/clang/test/SemaCXX/nested-name-spec.cpp Line 434: no member 
named 'X2' in namespace 'PR16951'

  error: 'error' diagnostics expected but not seen: 
File /src/tools/clang/test/SemaTemplate/instantiate-non-dependent-types.cpp 
Line 26 (directive at 
/src/tools/clang/test/SemaTemplate/instantiate-non-dependent-types.cpp:25): no 
member named '~Colors' in 'Colors'
  error: 'error' diagnostics seen but not expected: 
File /src/tools/clang/test/SemaTemplate/instantiate-non-dependent-types.cpp 
Line 26: no member named '~Colors' in the global namespace

This doesn't seem right, so I changed the code emitting `-Wshadow` to use 
`getRedeclContext()` instead. PTAL


https://reviews.llvm.org/D33207



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33207: Fix an assertion failure in FormatASTNodeDiagnosticArgument.

2017-05-16 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh updated this revision to Diff 99112.
alexfh added a comment.
Herald added a subscriber: krytarowski.

Instead of handling LinkageSpecDecl, use getRedeclContext() when issuing 
-Wshadow diagnostic.


https://reviews.llvm.org/D33207

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-shadow.cpp


Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -206,3 +206,10 @@
 }
 
 }
+
+extern "C" {
+typedef int externC; // expected-note {{previous declaration is here}}
+}
+void handleLinkageSpec() {
+  typedef void externC; // expected-warning {{declaration shadows a typedef in 
the global namespace}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6942,7 +6942,7 @@
 }
 }
 
-  DeclContext *OldDC = ShadowedDecl->getDeclContext();
+  DeclContext *OldDC = ShadowedDecl->getDeclContext()->getRedeclContext();
 
   unsigned WarningDiag = diag::warn_decl_shadow;
   SourceLocation CaptureLoc;


Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -206,3 +206,10 @@
 }
 
 }
+
+extern "C" {
+typedef int externC; // expected-note {{previous declaration is here}}
+}
+void handleLinkageSpec() {
+  typedef void externC; // expected-warning {{declaration shadows a typedef in the global namespace}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6942,7 +6942,7 @@
 }
 }
 
-  DeclContext *OldDC = ShadowedDecl->getDeclContext();
+  DeclContext *OldDC = ShadowedDecl->getDeclContext()->getRedeclContext();
 
   unsigned WarningDiag = diag::warn_decl_shadow;
   SourceLocation CaptureLoc;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33207: Fix an assertion failure in FormatASTNodeDiagnosticArgument.

2017-05-15 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: test/SemaCXX/warn-shadow.cpp:214
+void handleLinkageSpec() {
+  typedef void externC; // expected-warning {{declaration shadows a typedef in 
linkage specification}}
+}

We should be producing a diagnostic talking about the enclosing namespace / TU 
scope, not the linkage specification. Whoever is emitting the diagnostic seems 
to be missing a call to `getRedeclContext()` -- although perhaps we could do 
that in the diagnostic code instead.


https://reviews.llvm.org/D33207



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33207: Fix an assertion failure in FormatASTNodeDiagnosticArgument.

2017-05-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

The patch is trivial, I'm mostly wondering about the wording and whether we 
want to expand the "linkage specification" to specify whether it is `extern 
"C"` or `extern "C++"`, for example.


https://reviews.llvm.org/D33207



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33207: Fix an assertion failure in FormatASTNodeDiagnosticArgument.

2017-05-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.

The test being added in this patch used to cause an assertion failure:

/build/./bin/clang -cc1 -internal-isystem /build/lib/clang/5.0.0/include 
-nostdsysteminc -verify -fsyntax-only -std=c++11 -Wshadow-all 
/src/tools/clang/test/SemaCXX/warn-shadow.cpp


Exit Code: 134

Command Output (stderr):


clang: /src/tools/clang/lib/AST/ASTDiagnostic.cpp:424: void 
clang::FormatASTNodeDiagnosticArgument(DiagnosticsEngine::ArgumentKind, 
intptr_t, llvm::StringRef, llvm::StringRef, 
ArrayRef, SmallVectorImpl &, void *, 
ArrayRef): Assertion `isa(DC) && "Expected a NamedDecl"' 
failed.
Stack dump:
0.  Program arguments: /build/./bin/clang -cc1 -internal-isystem 
/build/lib/clang/5.0.0/include -nostdsysteminc -verify -fsyntax-only -std=c++11 
-Wshadow-all /src/tools/clang/test/SemaCXX/warn-shadow.cpp

1. /src/tools/clang/test/SemaCXX/warn-shadow.cpp:214:23: current parser token 
';'
2. /src/tools/clang/test/SemaCXX/warn-shadow.cpp:213:26: parsing function body 
'handleLinkageSpec'
3. /src/tools/clang/test/SemaCXX/warn-shadow.cpp:213:26: in compound statement 
('{}')

/build/tools/clang/test/SemaCXX/Output/warn-shadow.cpp.script: line 1: 15595 
Aborted (core dumped) /build/./bin/clang -cc1 -internal-isystem 
/build/lib/clang/5.0.0/include -nostdsysteminc -verify -fsyntax-only -std=c++11 
-Wshadow-all /src/tools/clang/test/SemaCXX/warn-shadow.cpp


https://reviews.llvm.org/D33207

Files:
  lib/AST/ASTDiagnostic.cpp
  test/SemaCXX/warn-shadow.cpp


Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -206,3 +206,10 @@
 }
 
 }
+
+extern "C" {
+typedef int externC; // expected-note {{previous declaration is here}}
+}
+void handleLinkageSpec() {
+  typedef void externC; // expected-warning {{declaration shadows a typedef in 
linkage specification}}
+}
Index: lib/AST/ASTDiagnostic.cpp
===
--- lib/AST/ASTDiagnostic.cpp
+++ lib/AST/ASTDiagnostic.cpp
@@ -420,6 +420,8 @@
 OS << ConvertTypeToDiagnosticString(Context,
 Context.getTypeDeclType(Type),
 PrevArgs, QualTypeVals);
+  } else if (const auto *LS = dyn_cast(DC)) {
+OS << "linkage specification";
   } else {
 assert(isa(DC) && "Expected a NamedDecl");
 NamedDecl *ND = cast(DC);


Index: test/SemaCXX/warn-shadow.cpp
===
--- test/SemaCXX/warn-shadow.cpp
+++ test/SemaCXX/warn-shadow.cpp
@@ -206,3 +206,10 @@
 }
 
 }
+
+extern "C" {
+typedef int externC; // expected-note {{previous declaration is here}}
+}
+void handleLinkageSpec() {
+  typedef void externC; // expected-warning {{declaration shadows a typedef in linkage specification}}
+}
Index: lib/AST/ASTDiagnostic.cpp
===
--- lib/AST/ASTDiagnostic.cpp
+++ lib/AST/ASTDiagnostic.cpp
@@ -420,6 +420,8 @@
 OS << ConvertTypeToDiagnosticString(Context,
 Context.getTypeDeclType(Type),
 PrevArgs, QualTypeVals);
+  } else if (const auto *LS = dyn_cast(DC)) {
+OS << "linkage specification";
   } else {
 assert(isa(DC) && "Expected a NamedDecl");
 NamedDecl *ND = cast(DC);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits