]> granicus.if.org Git - clang/commitdiff
Make -Wheader-hygiene not complain about USING_NAMESPACE_THROUGH_MACRO in a non-heade...
authorNico Weber <nicolasweber@gmx.de>
Sat, 2 Apr 2011 19:45:15 +0000 (19:45 +0000)
committerNico Weber <nicolasweber@gmx.de>
Sat, 2 Apr 2011 19:45:15 +0000 (19:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128780 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ReachableCode.cpp
lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/warn-using-namespace-in-header.cpp
test/SemaCXX/warn-using-namespace-in-header.h

index 9659e9ec3ed62ce1f1a46df3a5e7d39d8075c309..9ac456f53a67478c61e049b176b8af3d2119db46 100644 (file)
@@ -193,7 +193,7 @@ unsigned ScanReachableFromBlock(const CFGBlock &Start,
   unsigned count = 0;
   llvm::SmallVector<const CFGBlock*, 32> WL;
 
-    // Prep work queue
+  // Prep work queue
   Reachable.set(Start.getBlockID());
   ++count;
   WL.push_back(&Start);
index 7ae104a5423cb86acebbf198cc6a04766fa450e2..67396be3b0217d933d0240216ce323e19acde797 100644 (file)
@@ -3927,7 +3927,7 @@ Decl *Sema::ActOnUsingDirective(Scope *S,
                                       IdentLoc, Named, CommonAncestor);
 
     if (IsUsingDirectiveInToplevelContext(CurContext) &&
-        !SourceMgr.isFromMainFile(IdentLoc)) {
+        !SourceMgr.isFromMainFile(SourceMgr.getInstantiationLoc(IdentLoc))) {
       Diag(IdentLoc, diag::warn_using_directive_in_header);
     }
 
index e040ca74cbfc224f7996910c78777e6e024ff56e..72c25529b40f89ce4e173b3a65bcf5c11a83b3f7 100644 (file)
@@ -25,3 +25,30 @@ using namespace dont_warn;
 
 
 // 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
index 57bb5d91be45abac17275f13a44365bbac34237a..b544c548ae9bb11d205b753695ac4ba9828f1313 100644 (file)
@@ -40,3 +40,11 @@ using namespace warn_in_header_in_global_context;
 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