Make -Wheader-hygiene not complain about USING_NAMESPACE_THROUGH_MACRO in a non-header file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128780 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/ReachableCode.cpp b/lib/Analysis/ReachableCode.cpp
index 9659e9e..9ac456f 100644
--- a/lib/Analysis/ReachableCode.cpp
+++ b/lib/Analysis/ReachableCode.cpp
@@ -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);
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 7ae104a..67396be 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -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);
}
diff --git a/test/SemaCXX/warn-using-namespace-in-header.cpp b/test/SemaCXX/warn-using-namespace-in-header.cpp
index e040ca7..72c2552 100644
--- a/test/SemaCXX/warn-using-namespace-in-header.cpp
+++ b/test/SemaCXX/warn-using-namespace-in-header.cpp
@@ -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
diff --git a/test/SemaCXX/warn-using-namespace-in-header.h b/test/SemaCXX/warn-using-namespace-in-header.h
index 57bb5d9..b544c54 100644
--- a/test/SemaCXX/warn-using-namespace-in-header.h
+++ b/test/SemaCXX/warn-using-namespace-in-header.h
@@ -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