[cfe-commits] r128780 - in /cfe/trunk: lib/Analysis/ReachableCode.cpp lib/Sema/SemaDeclCXX.cpp test/SemaCXX/warn-using-namespace-in-header.cpp test/SemaCXX/warn-using-namespace-in-header.h
Nico Weber
nicolasweber at gmx.de
Sat Apr 2 12:45:15 PDT 2011
Author: nico
Date: Sat Apr 2 14:45:15 2011
New Revision: 128780
URL: http://llvm.org/viewvc/llvm-project?rev=128780&view=rev
Log:
Make -Wheader-hygiene not complain about USING_NAMESPACE_THROUGH_MACRO in a non-header file.
Modified:
cfe/trunk/lib/Analysis/ReachableCode.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/warn-using-namespace-in-header.cpp
cfe/trunk/test/SemaCXX/warn-using-namespace-in-header.h
Modified: cfe/trunk/lib/Analysis/ReachableCode.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ReachableCode.cpp?rev=128780&r1=128779&r2=128780&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ReachableCode.cpp (original)
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp Sat Apr 2 14:45:15 2011
@@ -193,7 +193,7 @@
unsigned count = 0;
llvm::SmallVector<const CFGBlock*, 32> WL;
- // Prep work queue
+ // Prep work queue
Reachable.set(Start.getBlockID());
++count;
WL.push_back(&Start);
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=128780&r1=128779&r2=128780&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Apr 2 14:45:15 2011
@@ -3927,7 +3927,7 @@
IdentLoc, Named, CommonAncestor);
if (IsUsingDirectiveInToplevelContext(CurContext) &&
- !SourceMgr.isFromMainFile(IdentLoc)) {
+ !SourceMgr.isFromMainFile(SourceMgr.getInstantiationLoc(IdentLoc))) {
Diag(IdentLoc, diag::warn_using_directive_in_header);
}
Modified: cfe/trunk/test/SemaCXX/warn-using-namespace-in-header.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-using-namespace-in-header.cpp?rev=128780&r1=128779&r2=128780&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-using-namespace-in-header.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-using-namespace-in-header.cpp Sat Apr 2 14:45:15 2011
@@ -25,3 +25,30 @@
// expected-warning {{using namespace directive in global context in header}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// expected-warning {{using namespace directive in global context in header}}
+
+// |using namespace| through a macro shouldn't warn if the instantiation is in a
+// cc file.
+USING_MACRO
Modified: cfe/trunk/test/SemaCXX/warn-using-namespace-in-header.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-using-namespace-in-header.h?rev=128780&r1=128779&r2=128780&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-using-namespace-in-header.h (original)
+++ cfe/trunk/test/SemaCXX/warn-using-namespace-in-header.h Sat Apr 2 14:45:15 2011
@@ -40,3 +40,11 @@
inline void foo() {
using namespace warn_in_header_in_global_context;
}
+
+
+namespace macronamespace {}
+#define USING_MACRO using namespace macronamespace;
+
+// |using namespace| through a macro should warn if the instantiation is in a
+// header.
+USING_MACRO
More information about the cfe-commits
mailing list