r219855 - Avoid having "using namespace" for both "clang" and "llvm" namespaces.

Alexey Samsonov vonosmas at gmail.com
Wed Oct 15 15:00:40 PDT 2014


Author: samsonov
Date: Wed Oct 15 17:00:40 2014
New Revision: 219855

URL: http://llvm.org/viewvc/llvm-project?rev=219855&view=rev
Log:
Avoid having "using namespace" for both "clang" and "llvm" namespaces.
This is fragile, as there are classes with the same name in both
namespaces (e.g. llvm::Module and clang::Module).

Modified:
    cfe/trunk/unittests/Lex/PPCallbacksTest.cpp

Modified: cfe/trunk/unittests/Lex/PPCallbacksTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PPCallbacksTest.cpp?rev=219855&r1=219854&r2=219855&view=diff
==============================================================================
--- cfe/trunk/unittests/Lex/PPCallbacksTest.cpp (original)
+++ cfe/trunk/unittests/Lex/PPCallbacksTest.cpp Wed Oct 15 17:00:40 2014
@@ -27,8 +27,6 @@
 #include "llvm/Support/Path.h"
 #include "gtest/gtest.h"
 
-using namespace llvm;
-using namespace llvm::sys;
 using namespace clang;
 
 namespace {
@@ -142,7 +140,7 @@ protected:
       FileMgr.getVirtualFile(HeaderPath, 0, 0);
 
       // Add header's parent path to search path.
-      StringRef SearchPath = path::parent_path(HeaderPath);
+      StringRef SearchPath = llvm::sys::path::parent_path(HeaderPath);
       const DirectoryEntry *DE = FileMgr.getDirectory(SearchPath);
       DirectoryLookup DL(DE, SrcMgr::C_User, false);
       HeaderInfo.AddSearchPath(DL, IsSystemHeader);
@@ -160,7 +158,8 @@ protected:
   // the InclusionDirective callback.
   CharSourceRange InclusionDirectiveFilenameRange(const char* SourceText, 
       const char* HeaderPath, bool SystemHeader) {
-    std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(SourceText);
+    std::unique_ptr<llvm::MemoryBuffer> Buf =
+        llvm::MemoryBuffer::getMemBuffer(SourceText);
     SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
 
     VoidModuleLoader ModLoader;
@@ -197,8 +196,8 @@ protected:
     LangOptions OpenCLLangOpts;
     OpenCLLangOpts.OpenCL = 1;
 
-    std::unique_ptr<MemoryBuffer> SourceBuf =
-        MemoryBuffer::getMemBuffer(SourceText, "test.cl");
+    std::unique_ptr<llvm::MemoryBuffer> SourceBuf =
+        llvm::MemoryBuffer::getMemBuffer(SourceText, "test.cl");
     SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf)));
 
     VoidModuleLoader ModLoader;





More information about the cfe-commits mailing list