[analyzer] Refactoring: Move stuff into namespace 'GR'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122423 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/GR/AggExprVisitor.cpp b/lib/GR/AggExprVisitor.cpp
index b8ec92f..7f873bc 100644
--- a/lib/GR/AggExprVisitor.cpp
+++ b/lib/GR/AggExprVisitor.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/StmtVisitor.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 /// AggExprVisitor is designed after AggExprEmitter of the CodeGen module.  It
diff --git a/lib/GR/AnalysisConsumer.cpp b/lib/GR/AnalysisConsumer.cpp
index 850a440..0b28451 100644
--- a/lib/GR/AnalysisConsumer.cpp
+++ b/lib/GR/AnalysisConsumer.cpp
@@ -43,6 +43,7 @@
 #include "llvm/ADT/OwningPtr.h"
 
 using namespace clang;
+using namespace GR;
 
 static ExplodedNode::Auditor* CreateUbiViz();
 
@@ -473,7 +474,7 @@
 // AnalysisConsumer creation.
 //===----------------------------------------------------------------------===//
 
-ASTConsumer* clang::CreateAnalysisConsumer(const Preprocessor& pp,
+ASTConsumer* GR::CreateAnalysisConsumer(const Preprocessor& pp,
                                            const std::string& OutDir,
                                            const AnalyzerOptions& Opts) {
   llvm::OwningPtr<AnalysisConsumer> C(new AnalysisConsumer(pp, OutDir, Opts));
diff --git a/lib/GR/AnalysisManager.cpp b/lib/GR/AnalysisManager.cpp
index 736cf1d..b0942e1 100644
--- a/lib/GR/AnalysisManager.cpp
+++ b/lib/GR/AnalysisManager.cpp
@@ -12,6 +12,7 @@
 #include "clang/Index/Indexer.h"
 
 using namespace clang;
+using namespace GR;
 
 AnalysisContext *
 AnalysisManager::getAnalysisContextInAnotherTU(const Decl *D) {
diff --git a/lib/GR/AnalyzerStatsChecker.cpp b/lib/GR/AnalyzerStatsChecker.cpp
index 2aa1515..cc9fcb7 100644
--- a/lib/GR/AnalyzerStatsChecker.cpp
+++ b/lib/GR/AnalyzerStatsChecker.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class AnalyzerStatsChecker : public CheckerVisitor<AnalyzerStatsChecker> {
@@ -37,7 +38,7 @@
   return &x;
 }
 
-void clang::RegisterAnalyzerStatsChecker(GRExprEngine &Eng) {
+void GR::RegisterAnalyzerStatsChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new AnalyzerStatsChecker());
 }
 
diff --git a/lib/GR/BasicConstraintManager.cpp b/lib/GR/BasicConstraintManager.cpp
index 0166968..ac289b8 100644
--- a/lib/GR/BasicConstraintManager.cpp
+++ b/lib/GR/BasicConstraintManager.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
+using namespace GR;
 
 
 namespace { class ConstNotEq {}; }
@@ -31,6 +32,7 @@
 static int ConstNotEqIndex = 0;
 
 namespace clang {
+namespace GR {
 template<>
 struct GRStateTrait<ConstNotEq> : public GRStatePartialTrait<ConstNotEqTy> {
   static inline void* GDMIndex() { return &ConstNotEqIndex; }
@@ -41,6 +43,7 @@
   static inline void* GDMIndex() { return &ConstEqIndex; }
 };
 }
+}
 
 namespace {
 // BasicConstraintManager only tracks equality and inequality constraints of
@@ -95,7 +98,7 @@
 
 } // end anonymous namespace
 
-ConstraintManager* clang::CreateBasicConstraintManager(GRStateManager& statemgr,
+ConstraintManager* GR::CreateBasicConstraintManager(GRStateManager& statemgr,
                                                        GRSubEngine &subengine) {
   return new BasicConstraintManager(statemgr, subengine);
 }
diff --git a/lib/GR/BasicStore.cpp b/lib/GR/BasicStore.cpp
index e9e85b9..2a673e2 100644
--- a/lib/GR/BasicStore.cpp
+++ b/lib/GR/BasicStore.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/ImmutableMap.h"
 
 using namespace clang;
+using namespace GR;
 
 typedef llvm::ImmutableMap<const MemRegion*,SVal> BindingsTy;
 
@@ -103,7 +104,7 @@
 } // end anonymous namespace
 
 
-StoreManager* clang::CreateBasicStoreManager(GRStateManager& StMgr) {
+StoreManager* GR::CreateBasicStoreManager(GRStateManager& StMgr) {
   return new BasicStoreManager(StMgr);
 }
 
diff --git a/lib/GR/BasicValueFactory.cpp b/lib/GR/BasicValueFactory.cpp
index 9352816..6e94a2a 100644
--- a/lib/GR/BasicValueFactory.cpp
+++ b/lib/GR/BasicValueFactory.cpp
@@ -16,6 +16,7 @@
 #include "clang/GR/PathSensitive/BasicValueFactory.h"
 
 using namespace clang;
+using namespace GR;
 
 void CompoundValData::Profile(llvm::FoldingSetNodeID& ID, QualType T,
                               llvm::ImmutableList<SVal> L) {
diff --git a/lib/GR/BugReporter.cpp b/lib/GR/BugReporter.cpp
index 41381d7..4321823 100644
--- a/lib/GR/BugReporter.cpp
+++ b/lib/GR/BugReporter.cpp
@@ -30,6 +30,7 @@
 #include <queue>
 
 using namespace clang;
+using namespace GR;
 
 BugReporterVisitor::~BugReporterVisitor() {}
 BugReporterContext::~BugReporterContext() {
diff --git a/lib/GR/BugReporterVisitors.cpp b/lib/GR/BugReporterVisitors.cpp
index 6641006..f56d053 100644
--- a/lib/GR/BugReporterVisitors.cpp
+++ b/lib/GR/BugReporterVisitors.cpp
@@ -20,12 +20,13 @@
 #include "clang/GR/PathSensitive/GRState.h"
 
 using namespace clang;
+using namespace GR;
 
 //===----------------------------------------------------------------------===//
 // Utility functions.
 //===----------------------------------------------------------------------===//
 
-const Stmt *clang::bugreporter::GetDerefExpr(const ExplodedNode *N) {
+const Stmt *bugreporter::GetDerefExpr(const ExplodedNode *N) {
   // Pattern match for a few useful cases (do something smarter later):
   //   a[0], p->f, *p
   const Stmt *S = N->getLocationAs<PostStmt>()->getStmt();
@@ -46,16 +47,14 @@
   return NULL;
 }
 
-const Stmt*
-clang::bugreporter::GetDenomExpr(const ExplodedNode *N) {
+const Stmt *bugreporter::GetDenomExpr(const ExplodedNode *N) {
   const Stmt *S = N->getLocationAs<PreStmt>()->getStmt();
   if (const BinaryOperator *BE = dyn_cast<BinaryOperator>(S))
     return BE->getRHS();
   return NULL;
 }
 
-const Stmt*
-clang::bugreporter::GetCalleeExpr(const ExplodedNode *N) {
+const Stmt *bugreporter::GetCalleeExpr(const ExplodedNode *N) {
   // Callee is checked as a PreVisit to the CallExpr.
   const Stmt *S = N->getLocationAs<PreStmt>()->getStmt();
   if (const CallExpr *CE = dyn_cast<CallExpr>(S))
@@ -63,8 +62,7 @@
   return NULL;
 }
 
-const Stmt*
-clang::bugreporter::GetRetValExpr(const ExplodedNode *N) {
+const Stmt *bugreporter::GetRetValExpr(const ExplodedNode *N) {
   const Stmt *S = N->getLocationAs<PostStmt>()->getStmt();
   if (const ReturnStmt *RS = dyn_cast<ReturnStmt>(S))
     return RS->getRetValue();
@@ -306,9 +304,9 @@
   BRC.addVisitor(new TrackConstraintBRVisitor(Constraint, Assumption));
 }
 
-void clang::bugreporter::registerTrackNullOrUndefValue(BugReporterContext& BRC,
-                                                       const void *data,
-                                                       const ExplodedNode* N) {
+void bugreporter::registerTrackNullOrUndefValue(BugReporterContext& BRC,
+                                                const void *data,
+                                                const ExplodedNode* N) {
 
   const Stmt *S = static_cast<const Stmt*>(data);
 
@@ -354,9 +352,9 @@
   }
 }
 
-void clang::bugreporter::registerFindLastStore(BugReporterContext& BRC,
-                                               const void *data,
-                                               const ExplodedNode* N) {
+void bugreporter::registerFindLastStore(BugReporterContext& BRC,
+                                        const void *data,
+                                        const ExplodedNode* N) {
 
   const MemRegion *R = static_cast<const MemRegion*>(data);
 
@@ -417,12 +415,12 @@
 };
 } // end anonymous namespace
 
-void clang::bugreporter::registerNilReceiverVisitor(BugReporterContext &BRC) {
+void bugreporter::registerNilReceiverVisitor(BugReporterContext &BRC) {
   BRC.addVisitor(new NilReceiverVisitor());
 }
 
 // Registers every VarDecl inside a Stmt with a last store vistor.
-void clang::bugreporter::registerVarDeclsLastStore(BugReporterContext &BRC,
+void bugreporter::registerVarDeclsLastStore(BugReporterContext &BRC,
                                                    const void *stmt,
                                                    const ExplodedNode *N) {
   const Stmt *S = static_cast<const Stmt *>(stmt);
diff --git a/lib/GR/CFRefCount.cpp b/lib/GR/CFRefCount.cpp
index 211c265..55d11a5 100644
--- a/lib/GR/CFRefCount.cpp
+++ b/lib/GR/CFRefCount.cpp
@@ -34,6 +34,7 @@
 #include <stdarg.h>
 
 using namespace clang;
+using namespace GR;
 using llvm::StringRef;
 using llvm::StrInStrNoCase;
 
@@ -396,6 +397,7 @@
 typedef llvm::ImmutableMap<SymbolRef, RefVal> RefBindings;
 
 namespace clang {
+namespace GR {
   template<>
   struct GRStateTrait<RefBindings> : public GRStatePartialTrait<RefBindings> {
     static void* GDMIndex() {
@@ -404,6 +406,7 @@
     }
   };
 }
+}
 
 //===----------------------------------------------------------------------===//
 // Summaries
@@ -1576,6 +1579,7 @@
 namespace { class AutoreleaseStack {}; }
 
 namespace clang {
+namespace GR {
 template<> struct GRStateTrait<AutoreleaseStack>
   : public GRStatePartialTrait<ARStack> {
   static inline void* GDMIndex() { return &AutoRBIndex; }
@@ -1585,6 +1589,7 @@
   : public GRStatePartialTrait<ARPoolContents> {
   static inline void* GDMIndex() { return &AutoRCIndex; }
 };
+} // end GR namespace
 } // end clang namespace
 
 static SymbolRef GetCurrentAutoreleasePool(const GRState* state) {
@@ -3489,7 +3494,7 @@
   Eng.registerCheck(new RetainReleaseChecker(this));
 }
 
-GRTransferFuncs* clang::MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled,
+GRTransferFuncs* GR::MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled,
                                          const LangOptions& lopts) {
   return new CFRefCount(Ctx, GCEnabled, lopts);
 }
diff --git a/lib/GR/Checker.cpp b/lib/GR/Checker.cpp
index 00976db..521d9e2 100644
--- a/lib/GR/Checker.cpp
+++ b/lib/GR/Checker.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/GR/PathSensitive/Checker.h"
 using namespace clang;
+using namespace GR;
 
 Checker::~Checker() {}
 
diff --git a/lib/GR/CheckerHelpers.cpp b/lib/GR/CheckerHelpers.cpp
index 3819ed3..23144a3 100644
--- a/lib/GR/CheckerHelpers.cpp
+++ b/lib/GR/CheckerHelpers.cpp
@@ -15,7 +15,7 @@
 #include "clang/AST/Expr.h"
 
 // Recursively find any substatements containing macros
-bool clang::containsMacro(const Stmt *S) {
+bool clang::GR::containsMacro(const Stmt *S) {
   if (S->getLocStart().isMacroID())
     return true;
 
@@ -32,7 +32,7 @@
 }
 
 // Recursively find any substatements containing enum constants
-bool clang::containsEnum(const Stmt *S) {
+bool clang::GR::containsEnum(const Stmt *S) {
   const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(S);
 
   if (DR && isa<EnumConstantDecl>(DR->getDecl()))
@@ -48,7 +48,7 @@
 }
 
 // Recursively find any substatements containing static vars
-bool clang::containsStaticLocal(const Stmt *S) {
+bool clang::GR::containsStaticLocal(const Stmt *S) {
   const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(S);
 
   if (DR)
@@ -66,7 +66,7 @@
 }
 
 // Recursively find any substatements containing __builtin_offsetof
-bool clang::containsBuiltinOffsetOf(const Stmt *S) {
+bool clang::GR::containsBuiltinOffsetOf(const Stmt *S) {
   if (isa<OffsetOfExpr>(S))
     return true;
 
diff --git a/lib/GR/Checkers/AdjustedReturnValueChecker.cpp b/lib/GR/Checkers/AdjustedReturnValueChecker.cpp
index 281d74f..d9cfd3c 100644
--- a/lib/GR/Checkers/AdjustedReturnValueChecker.cpp
+++ b/lib/GR/Checkers/AdjustedReturnValueChecker.cpp
@@ -19,6 +19,7 @@
 #include "clang/GR/PathSensitive/CheckerVisitor.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class AdjustedReturnValueChecker : 
@@ -34,7 +35,7 @@
 };
 }
 
-void clang::RegisterAdjustedReturnValueChecker(GRExprEngine &Eng) {
+void GR::RegisterAdjustedReturnValueChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new AdjustedReturnValueChecker());
 }
 
diff --git a/lib/GR/Checkers/ArrayBoundChecker.cpp b/lib/GR/Checkers/ArrayBoundChecker.cpp
index a36e13e..f97adf3 100644
--- a/lib/GR/Checkers/ArrayBoundChecker.cpp
+++ b/lib/GR/Checkers/ArrayBoundChecker.cpp
@@ -18,6 +18,7 @@
 #include "clang/GR/PathSensitive/GRExprEngine.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class ArrayBoundChecker : 
@@ -30,7 +31,7 @@
 };
 }
 
-void clang::RegisterArrayBoundChecker(GRExprEngine &Eng) {
+void GR::RegisterArrayBoundChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new ArrayBoundChecker());
 }
 
diff --git a/lib/GR/Checkers/AttrNonNullChecker.cpp b/lib/GR/Checkers/AttrNonNullChecker.cpp
index 5be1278..baf209e 100644
--- a/lib/GR/Checkers/AttrNonNullChecker.cpp
+++ b/lib/GR/Checkers/AttrNonNullChecker.cpp
@@ -17,6 +17,7 @@
 #include "clang/GR/PathSensitive/CheckerVisitor.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class AttrNonNullChecker
@@ -32,7 +33,7 @@
 };
 } // end anonymous namespace
 
-void clang::RegisterAttrNonNullChecker(GRExprEngine &Eng) {
+void GR::RegisterAttrNonNullChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new AttrNonNullChecker());
 }
 
diff --git a/lib/GR/Checkers/BasicObjCFoundationChecks.cpp b/lib/GR/Checkers/BasicObjCFoundationChecks.cpp
index dc53695..93c8bab 100644
--- a/lib/GR/Checkers/BasicObjCFoundationChecks.cpp
+++ b/lib/GR/Checkers/BasicObjCFoundationChecks.cpp
@@ -29,6 +29,7 @@
 #include "clang/AST/ASTContext.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class APIMisuse : public BugType {
@@ -510,7 +511,7 @@
 // Check registration.
 //===----------------------------------------------------------------------===//
   
-void clang::RegisterAppleChecks(GRExprEngine& Eng, const Decl &D) {
+void GR::RegisterAppleChecks(GRExprEngine& Eng, const Decl &D) {
   Eng.registerCheck(new NilArgChecker());
   Eng.registerCheck(new CFNumberCreateChecker());
   RegisterNSErrorChecks(Eng.getBugReporter(), Eng, D);
diff --git a/lib/GR/Checkers/BasicObjCFoundationChecks.h b/lib/GR/Checkers/BasicObjCFoundationChecks.h
index 6ad850b..7fdccdc 100644
--- a/lib/GR/Checkers/BasicObjCFoundationChecks.h
+++ b/lib/GR/Checkers/BasicObjCFoundationChecks.h
@@ -13,19 +13,24 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_ANALYSIS_BASICOBJCFOUNDATIONCHECKS
-#define LLVM_CLANG_ANALYSIS_BASICOBJCFOUNDATIONCHECKS
+#ifndef LLVM_CLANG_GR_BASICOBJCFOUNDATIONCHECKS
+#define LLVM_CLANG_GR_BASICOBJCFOUNDATIONCHECKS
 
 namespace clang {
 
 class ASTContext;
-class BugReporter;
 class Decl;
+
+namespace GR {
+
+class BugReporter;
 class GRExprEngine;
 
 void RegisterNSErrorChecks(BugReporter& BR, GRExprEngine &Eng, const Decl &D);
 void RegisterNSAutoreleasePoolChecks(GRExprEngine &Eng);
 
+} // end GR namespace
+
 } // end clang namespace
 
 #endif
diff --git a/lib/GR/Checkers/BuiltinFunctionChecker.cpp b/lib/GR/Checkers/BuiltinFunctionChecker.cpp
index 08fcbd6..dc55a65 100644
--- a/lib/GR/Checkers/BuiltinFunctionChecker.cpp
+++ b/lib/GR/Checkers/BuiltinFunctionChecker.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/Builtins.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 
@@ -27,7 +28,7 @@
 
 }
 
-void clang::RegisterBuiltinFunctionChecker(GRExprEngine &Eng) {
+void GR::RegisterBuiltinFunctionChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new BuiltinFunctionChecker());
 }
 
diff --git a/lib/GR/Checkers/CStringChecker.cpp b/lib/GR/Checkers/CStringChecker.cpp
index db4d86f..da0bba3 100644
--- a/lib/GR/Checkers/CStringChecker.cpp
+++ b/lib/GR/Checkers/CStringChecker.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringSwitch.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class CStringChecker : public CheckerVisitor<CStringChecker> {
@@ -99,14 +100,16 @@
 } //end anonymous namespace
 
 namespace clang {
+namespace GR {
   template <>
   struct GRStateTrait<CStringLength> 
     : public GRStatePartialTrait<CStringLength::EntryMap> {
     static void *GDMIndex() { return CStringChecker::getTag(); }
   };
 }
+}
 
-void clang::RegisterCStringChecker(GRExprEngine &Eng) {
+void GR::RegisterCStringChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new CStringChecker());
 }
 
diff --git a/lib/GR/Checkers/CallAndMessageChecker.cpp b/lib/GR/Checkers/CallAndMessageChecker.cpp
index e68569c..8b8f75f 100644
--- a/lib/GR/Checkers/CallAndMessageChecker.cpp
+++ b/lib/GR/Checkers/CallAndMessageChecker.cpp
@@ -19,6 +19,7 @@
 #include "clang/GR/PathSensitive/CheckerVisitor.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class CallAndMessageChecker
@@ -61,7 +62,7 @@
 };
 } // end anonymous namespace
 
-void clang::RegisterCallAndMessageChecker(GRExprEngine &Eng) {
+void GR::RegisterCallAndMessageChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new CallAndMessageChecker());
 }
 
diff --git a/lib/GR/Checkers/CastSizeChecker.cpp b/lib/GR/Checkers/CastSizeChecker.cpp
index 1248d12..bcbb894 100644
--- a/lib/GR/Checkers/CastSizeChecker.cpp
+++ b/lib/GR/Checkers/CastSizeChecker.cpp
@@ -17,6 +17,7 @@
 #include "GRExprEngineInternalChecks.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class CastSizeChecker : public CheckerVisitor<CastSizeChecker> {
@@ -85,6 +86,6 @@
 }
 
 
-void clang::RegisterCastSizeChecker(GRExprEngine &Eng) {
+void GR::RegisterCastSizeChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new CastSizeChecker());
 }
diff --git a/lib/GR/Checkers/CastToStructChecker.cpp b/lib/GR/Checkers/CastToStructChecker.cpp
index 2a010b2..0bcba28 100644
--- a/lib/GR/Checkers/CastToStructChecker.cpp
+++ b/lib/GR/Checkers/CastToStructChecker.cpp
@@ -18,6 +18,7 @@
 #include "GRExprEngineInternalChecks.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class CastToStructChecker 
@@ -73,6 +74,6 @@
   }
 }
 
-void clang::RegisterCastToStructChecker(GRExprEngine &Eng) {
+void GR::RegisterCastToStructChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new CastToStructChecker());
 }
diff --git a/lib/GR/Checkers/CheckDeadStores.cpp b/lib/GR/Checkers/CheckDeadStores.cpp
index 7e90781..44fdb3a 100644
--- a/lib/GR/Checkers/CheckDeadStores.cpp
+++ b/lib/GR/Checkers/CheckDeadStores.cpp
@@ -24,6 +24,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 
@@ -280,7 +281,7 @@
 } // end anonymous namespace
 
 
-void clang::CheckDeadStores(CFG &cfg, LiveVariables &L, ParentMap &pmap, 
+void GR::CheckDeadStores(CFG &cfg, LiveVariables &L, ParentMap &pmap, 
                             BugReporter& BR) {
   FindEscaped FS(&cfg);
   FS.getCFG().VisitBlockStmts(FS);
diff --git a/lib/GR/Checkers/CheckObjCDealloc.cpp b/lib/GR/Checkers/CheckObjCDealloc.cpp
index c3d511b..f8ec7f6 100644
--- a/lib/GR/Checkers/CheckObjCDealloc.cpp
+++ b/lib/GR/Checkers/CheckObjCDealloc.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
+using namespace GR;
 
 static bool scan_dealloc(Stmt* S, Selector Dealloc) {
 
@@ -93,8 +94,8 @@
   return false;
 }
 
-void clang::CheckObjCDealloc(const ObjCImplementationDecl* D,
-                             const LangOptions& LOpts, BugReporter& BR) {
+void GR::CheckObjCDealloc(const ObjCImplementationDecl* D,
+                          const LangOptions& LOpts, BugReporter& BR) {
 
   assert (LOpts.getGCMode() != LangOptions::GCOnly);
 
diff --git a/lib/GR/Checkers/CheckObjCInstMethSignature.cpp b/lib/GR/Checkers/CheckObjCInstMethSignature.cpp
index 2b83d13..b2be375 100644
--- a/lib/GR/Checkers/CheckObjCInstMethSignature.cpp
+++ b/lib/GR/Checkers/CheckObjCInstMethSignature.cpp
@@ -24,6 +24,7 @@
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
+using namespace GR;
 
 static bool AreTypesCompatible(QualType Derived, QualType Ancestor,
                                ASTContext& C) {
@@ -69,8 +70,8 @@
   }
 }
 
-void clang::CheckObjCInstMethSignature(const ObjCImplementationDecl* ID,
-                                       BugReporter& BR) {
+void GR::CheckObjCInstMethSignature(const ObjCImplementationDecl* ID,
+                                    BugReporter& BR) {
 
   const ObjCInterfaceDecl* D = ID->getClassInterface();
   const ObjCInterfaceDecl* C = D->getSuperClass();
diff --git a/lib/GR/Checkers/CheckSecuritySyntaxOnly.cpp b/lib/GR/Checkers/CheckSecuritySyntaxOnly.cpp
index bdf18ca..ea658e3 100644
--- a/lib/GR/Checkers/CheckSecuritySyntaxOnly.cpp
+++ b/lib/GR/Checkers/CheckSecuritySyntaxOnly.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
+using namespace GR;
 
 static bool isArc4RandomAvailable(const ASTContext &Ctx) {
   const llvm::Triple &T = Ctx.Target.getTriple();
@@ -496,7 +497,7 @@
 // Entry point for check.
 //===----------------------------------------------------------------------===//
 
-void clang::CheckSecuritySyntaxOnly(const Decl *D, BugReporter &BR) {
+void GR::CheckSecuritySyntaxOnly(const Decl *D, BugReporter &BR) {
   WalkAST walker(BR);
   walker.Visit(D->getBody());
 }
diff --git a/lib/GR/Checkers/CheckSizeofPointer.cpp b/lib/GR/Checkers/CheckSizeofPointer.cpp
index 4cf5eb7..696dce2 100644
--- a/lib/GR/Checkers/CheckSizeofPointer.cpp
+++ b/lib/GR/Checkers/CheckSizeofPointer.cpp
@@ -17,6 +17,7 @@
 #include "clang/GR/Checkers/LocalCheckers.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class WalkAST : public StmtVisitor<WalkAST> {
@@ -65,7 +66,7 @@
   }
 }
 
-void clang::CheckSizeofPointer(const Decl *D, BugReporter &BR) {
+void GR::CheckSizeofPointer(const Decl *D, BugReporter &BR) {
   WalkAST walker(BR);
   walker.Visit(D->getBody());
 }
diff --git a/lib/GR/Checkers/ChrootChecker.cpp b/lib/GR/Checkers/ChrootChecker.cpp
index 2108094..f93ee7b 100644
--- a/lib/GR/Checkers/ChrootChecker.cpp
+++ b/lib/GR/Checkers/ChrootChecker.cpp
@@ -19,6 +19,7 @@
 #include "clang/GR/PathSensitive/SymbolManager.h"
 #include "llvm/ADT/ImmutableMap.h"
 using namespace clang;
+using namespace GR;
 
 namespace {
 
@@ -58,7 +59,7 @@
 
 } // end anonymous namespace
 
-void clang::RegisterChrootChecker(GRExprEngine &Eng) {
+void GR::RegisterChrootChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new ChrootChecker());
 }
 
diff --git a/lib/GR/Checkers/DereferenceChecker.cpp b/lib/GR/Checkers/DereferenceChecker.cpp
index 72c88b1..62b1f86 100644
--- a/lib/GR/Checkers/DereferenceChecker.cpp
+++ b/lib/GR/Checkers/DereferenceChecker.cpp
@@ -19,6 +19,7 @@
 #include "clang/GR/PathSensitive/GRExprEngine.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class DereferenceChecker : public Checker {
@@ -42,12 +43,12 @@
 };
 } // end anonymous namespace
 
-void clang::RegisterDereferenceChecker(GRExprEngine &Eng) {
+void GR::RegisterDereferenceChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new DereferenceChecker());
 }
 
 std::pair<ExplodedNode * const *, ExplodedNode * const *>
-clang::GetImplicitNullDereferences(GRExprEngine &Eng) {
+GR::GetImplicitNullDereferences(GRExprEngine &Eng) {
   DereferenceChecker *checker = Eng.getChecker<DereferenceChecker>();
   if (!checker)
     return std::make_pair((ExplodedNode * const *) 0,
diff --git a/lib/GR/Checkers/DivZeroChecker.cpp b/lib/GR/Checkers/DivZeroChecker.cpp
index e76d846..a4cb1a4 100644
--- a/lib/GR/Checkers/DivZeroChecker.cpp
+++ b/lib/GR/Checkers/DivZeroChecker.cpp
@@ -17,6 +17,7 @@
 #include "clang/GR/PathSensitive/CheckerVisitor.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class DivZeroChecker : public CheckerVisitor<DivZeroChecker> {
@@ -28,7 +29,7 @@
 };  
 } // end anonymous namespace
 
-void clang::RegisterDivZeroChecker(GRExprEngine &Eng) {
+void GR::RegisterDivZeroChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new DivZeroChecker());
 }
 
diff --git a/lib/GR/Checkers/FixedAddressChecker.cpp b/lib/GR/Checkers/FixedAddressChecker.cpp
index ede6b55..4c7086f 100644
--- a/lib/GR/Checkers/FixedAddressChecker.cpp
+++ b/lib/GR/Checkers/FixedAddressChecker.cpp
@@ -18,6 +18,7 @@
 #include "clang/GR/PathSensitive/CheckerVisitor.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class FixedAddressChecker 
@@ -66,6 +67,6 @@
   }
 }
 
-void clang::RegisterFixedAddressChecker(GRExprEngine &Eng) {
+void GR::RegisterFixedAddressChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new FixedAddressChecker());
 }
diff --git a/lib/GR/Checkers/GRExprEngineExperimentalChecks.cpp b/lib/GR/Checkers/GRExprEngineExperimentalChecks.cpp
index f1acc65..fd9bf5d 100644
--- a/lib/GR/Checkers/GRExprEngineExperimentalChecks.cpp
+++ b/lib/GR/Checkers/GRExprEngineExperimentalChecks.cpp
@@ -17,8 +17,9 @@
 #include "clang/GR/Checkers/LocalCheckers.h"
 
 using namespace clang;
+using namespace GR;
 
-void clang::RegisterExperimentalChecks(GRExprEngine &Eng) {
+void GR::RegisterExperimentalChecks(GRExprEngine &Eng) {
   // These are checks that never belong as internal checks
   // within GRExprEngine.
   RegisterCStringChecker(Eng);
@@ -29,7 +30,7 @@
   RegisterUnreachableCodeChecker(Eng);
 }
 
-void clang::RegisterExperimentalInternalChecks(GRExprEngine &Eng) {
+void GR::RegisterExperimentalInternalChecks(GRExprEngine &Eng) {
   // These are internal checks that should eventually migrate to
   // RegisterInternalChecks() once they have been further tested.
   
diff --git a/lib/GR/Checkers/GRExprEngineExperimentalChecks.h b/lib/GR/Checkers/GRExprEngineExperimentalChecks.h
index 3380031..54a6125 100644
--- a/lib/GR/Checkers/GRExprEngineExperimentalChecks.h
+++ b/lib/GR/Checkers/GRExprEngineExperimentalChecks.h
@@ -12,11 +12,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_GREXPRENGINE_EXPERIMENTAL_CHECKS
-#define LLVM_CLANG_GREXPRENGINE_EXPERIMENTAL_CHECKS
+#ifndef LLVM_CLANG_GR_GREXPRENGINE_EXPERIMENTAL_CHECKS
+#define LLVM_CLANG_GR_GREXPRENGINE_EXPERIMENTAL_CHECKS
 
 namespace clang {
 
+namespace GR {
+
 class GRExprEngine;
 
 void RegisterAnalyzerStatsChecker(GRExprEngine &Eng);
@@ -28,5 +30,8 @@
 void RegisterStreamChecker(GRExprEngine &Eng);
 void RegisterUnreachableCodeChecker(GRExprEngine &Eng);
 
+} // end GR namespace
+
 } // end clang namespace
+
 #endif
diff --git a/lib/GR/Checkers/GRExprEngineInternalChecks.h b/lib/GR/Checkers/GRExprEngineInternalChecks.h
index 740a914..cba419a 100644
--- a/lib/GR/Checkers/GRExprEngineInternalChecks.h
+++ b/lib/GR/Checkers/GRExprEngineInternalChecks.h
@@ -12,11 +12,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_GREXPRENGINE_INTERNAL_CHECKS
-#define LLVM_CLANG_GREXPRENGINE_INTERNAL_CHECKS
+#ifndef LLVM_CLANG_GR_GREXPRENGINE_INTERNAL_CHECKS
+#define LLVM_CLANG_GR_GREXPRENGINE_INTERNAL_CHECKS
 
 namespace clang {
 
+namespace GR {
+
 class GRExprEngine;
 
 // Foundational checks that handle basic semantics.
@@ -49,5 +51,8 @@
 void RegisterOSAtomicChecker(GRExprEngine &Eng);
 void RegisterUnixAPIChecker(GRExprEngine &Eng);
 
+} // end GR namespace
+
 } // end clang namespace
+
 #endif
diff --git a/lib/GR/Checkers/IdempotentOperationChecker.cpp b/lib/GR/Checkers/IdempotentOperationChecker.cpp
index e6f0e5d..b28edc3 100644
--- a/lib/GR/Checkers/IdempotentOperationChecker.cpp
+++ b/lib/GR/Checkers/IdempotentOperationChecker.cpp
@@ -58,6 +58,7 @@
 #include <deque>
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class IdempotentOperationChecker
@@ -129,7 +130,7 @@
   return &x;
 }
 
-void clang::RegisterIdempotentOperationChecker(GRExprEngine &Eng) {
+void GR::RegisterIdempotentOperationChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new IdempotentOperationChecker());
 }
 
diff --git a/lib/GR/Checkers/LLVMConventionsChecker.cpp b/lib/GR/Checkers/LLVMConventionsChecker.cpp
index e97074e..655e756 100644
--- a/lib/GR/Checkers/LLVMConventionsChecker.cpp
+++ b/lib/GR/Checkers/LLVMConventionsChecker.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/StringRef.h"
 
 using namespace clang;
+using namespace GR;
 
 //===----------------------------------------------------------------------===//
 // Generic type checking routines.
@@ -305,7 +306,7 @@
   }
 }
 
-void clang::CheckLLVMConventions(TranslationUnitDecl &TU,
+void GR::CheckLLVMConventions(TranslationUnitDecl &TU,
                                  BugReporter &BR) {
   ScanCodeDecls(&TU, BR);
 }
diff --git a/lib/GR/Checkers/MacOSXAPIChecker.cpp b/lib/GR/Checkers/MacOSXAPIChecker.cpp
index c798cb2..316e37a 100644
--- a/lib/GR/Checkers/MacOSXAPIChecker.cpp
+++ b/lib/GR/Checkers/MacOSXAPIChecker.cpp
@@ -25,6 +25,7 @@
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class MacOSXAPIChecker : public CheckerVisitor<MacOSXAPIChecker> {
@@ -44,7 +45,7 @@
 };
 } //end anonymous namespace
 
-void clang::RegisterMacOSXAPIChecker(GRExprEngine &Eng) {
+void GR::RegisterMacOSXAPIChecker(GRExprEngine &Eng) {
   if (Eng.getContext().Target.getTriple().getVendor() == llvm::Triple::Apple)
     Eng.registerCheck(new MacOSXAPIChecker());
 }
diff --git a/lib/GR/Checkers/MallocChecker.cpp b/lib/GR/Checkers/MallocChecker.cpp
index 367ac24..cd5f636 100644
--- a/lib/GR/Checkers/MallocChecker.cpp
+++ b/lib/GR/Checkers/MallocChecker.cpp
@@ -20,6 +20,7 @@
 #include "clang/GR/PathSensitive/SymbolManager.h"
 #include "llvm/ADT/ImmutableMap.h"
 using namespace clang;
+using namespace GR;
 
 namespace {
 
@@ -116,14 +117,16 @@
 typedef llvm::ImmutableMap<SymbolRef, RefState> RegionStateTy;
 
 namespace clang {
+namespace GR {
   template <>
   struct GRStateTrait<RegionState> 
     : public GRStatePartialTrait<RegionStateTy> {
     static void *GDMIndex() { return MallocChecker::getTag(); }
   };
 }
+}
 
-void clang::RegisterMallocChecker(GRExprEngine &Eng) {
+void GR::RegisterMallocChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new MallocChecker());
 }
 
diff --git a/lib/GR/Checkers/NSAutoreleasePoolChecker.cpp b/lib/GR/Checkers/NSAutoreleasePoolChecker.cpp
index d8225a7..d6701c7 100644
--- a/lib/GR/Checkers/NSAutoreleasePoolChecker.cpp
+++ b/lib/GR/Checkers/NSAutoreleasePoolChecker.cpp
@@ -23,6 +23,7 @@
 #include "clang/AST/Decl.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class NSAutoreleasePoolChecker
@@ -44,7 +45,7 @@
 } // end anonymous namespace
 
 
-void clang::RegisterNSAutoreleasePoolChecks(GRExprEngine &Eng) {
+void GR::RegisterNSAutoreleasePoolChecks(GRExprEngine &Eng) {
   ASTContext &Ctx = Eng.getContext();
   if (Ctx.getLangOptions().getGCMode() != LangOptions::NonGC) {    
     Eng.registerCheck(new NSAutoreleasePoolChecker(GetNullarySelector("release",
diff --git a/lib/GR/Checkers/NSErrorChecker.cpp b/lib/GR/Checkers/NSErrorChecker.cpp
index 73caf77..44715bf 100644
--- a/lib/GR/Checkers/NSErrorChecker.cpp
+++ b/lib/GR/Checkers/NSErrorChecker.cpp
@@ -25,6 +25,7 @@
 #include "llvm/ADT/SmallVector.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class NSErrorChecker : public BugType {
@@ -62,7 +63,7 @@
 
 } // end anonymous namespace
 
-void clang::RegisterNSErrorChecks(BugReporter& BR, GRExprEngine &Eng,
+void GR::RegisterNSErrorChecks(BugReporter& BR, GRExprEngine &Eng,
                                   const Decl &D) {
   BR.Register(new NSErrorChecker(D, true, Eng));
   BR.Register(new NSErrorChecker(D, false, Eng));
diff --git a/lib/GR/Checkers/NoReturnFunctionChecker.cpp b/lib/GR/Checkers/NoReturnFunctionChecker.cpp
index fdd2849..739460f 100644
--- a/lib/GR/Checkers/NoReturnFunctionChecker.cpp
+++ b/lib/GR/Checkers/NoReturnFunctionChecker.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringSwitch.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 
@@ -28,7 +29,7 @@
 
 }
 
-void clang::RegisterNoReturnFunctionChecker(GRExprEngine &Eng) {
+void GR::RegisterNoReturnFunctionChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new NoReturnFunctionChecker());
 }
 
diff --git a/lib/GR/Checkers/OSAtomicChecker.cpp b/lib/GR/Checkers/OSAtomicChecker.cpp
index 36b5335..7df7a9e 100644
--- a/lib/GR/Checkers/OSAtomicChecker.cpp
+++ b/lib/GR/Checkers/OSAtomicChecker.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/Builtins.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 
@@ -30,7 +31,7 @@
 
 }
 
-void clang::RegisterOSAtomicChecker(GRExprEngine &Eng) {
+void GR::RegisterOSAtomicChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new OSAtomicChecker());
 }
 
diff --git a/lib/GR/Checkers/ObjCAtSyncChecker.cpp b/lib/GR/Checkers/ObjCAtSyncChecker.cpp
index c95df4e..a393862 100644
--- a/lib/GR/Checkers/ObjCAtSyncChecker.cpp
+++ b/lib/GR/Checkers/ObjCAtSyncChecker.cpp
@@ -19,6 +19,7 @@
 #include "clang/GR/PathSensitive/GRExprEngine.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class ObjCAtSyncChecker : public CheckerVisitor<ObjCAtSyncChecker> {
@@ -32,7 +33,7 @@
 };
 } // end anonymous namespace
 
-void clang::RegisterObjCAtSyncChecker(GRExprEngine &Eng) {
+void GR::RegisterObjCAtSyncChecker(GRExprEngine &Eng) {
   // @synchronized is an Objective-C 2 feature.
   if (Eng.getContext().getLangOptions().ObjC2)
     Eng.registerCheck(new ObjCAtSyncChecker());
diff --git a/lib/GR/Checkers/ObjCUnusedIVarsChecker.cpp b/lib/GR/Checkers/ObjCUnusedIVarsChecker.cpp
index e3f5d56..611914f 100644
--- a/lib/GR/Checkers/ObjCUnusedIVarsChecker.cpp
+++ b/lib/GR/Checkers/ObjCUnusedIVarsChecker.cpp
@@ -23,6 +23,7 @@
 #include "clang/Basic/SourceManager.h"
 
 using namespace clang;
+using namespace GR;
 
 enum IVarState { Unused, Used };
 typedef llvm::DenseMap<const ObjCIvarDecl*,IVarState> IvarUsageMap;
@@ -97,7 +98,7 @@
     }
 }
 
-void clang::CheckObjCUnusedIvar(const ObjCImplementationDecl *D,
+void GR::CheckObjCUnusedIvar(const ObjCImplementationDecl *D,
                                 BugReporter &BR) {
 
   const ObjCInterfaceDecl* ID = D->getClassInterface();
diff --git a/lib/GR/Checkers/PointerArithChecker.cpp b/lib/GR/Checkers/PointerArithChecker.cpp
index 0517140..485144a 100644
--- a/lib/GR/Checkers/PointerArithChecker.cpp
+++ b/lib/GR/Checkers/PointerArithChecker.cpp
@@ -17,6 +17,7 @@
 #include "clang/GR/PathSensitive/CheckerVisitor.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class PointerArithChecker 
@@ -66,6 +67,6 @@
   }
 }
 
-void clang::RegisterPointerArithChecker(GRExprEngine &Eng) {
+void GR::RegisterPointerArithChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new PointerArithChecker());
 }
diff --git a/lib/GR/Checkers/PointerSubChecker.cpp b/lib/GR/Checkers/PointerSubChecker.cpp
index 24f839d..44e3d9f 100644
--- a/lib/GR/Checkers/PointerSubChecker.cpp
+++ b/lib/GR/Checkers/PointerSubChecker.cpp
@@ -18,6 +18,7 @@
 #include "clang/GR/PathSensitive/CheckerVisitor.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class PointerSubChecker 
@@ -73,6 +74,6 @@
   }
 }
 
-void clang::RegisterPointerSubChecker(GRExprEngine &Eng) {
+void GR::RegisterPointerSubChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new PointerSubChecker());
 }
diff --git a/lib/GR/Checkers/PthreadLockChecker.cpp b/lib/GR/Checkers/PthreadLockChecker.cpp
index 32f2f57..d880b06 100644
--- a/lib/GR/Checkers/PthreadLockChecker.cpp
+++ b/lib/GR/Checkers/PthreadLockChecker.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/ImmutableSet.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class PthreadLockChecker
@@ -44,13 +45,15 @@
 // GDM Entry for tracking lock state.
 namespace { class LockSet {}; }
 namespace clang {
+namespace GR {
 template <> struct GRStateTrait<LockSet> :
   public GRStatePartialTrait<llvm::ImmutableSet<const MemRegion*> > {
     static void* GDMIndex() { return PthreadLockChecker::getTag(); }
 };
+} // end GR namespace
 } // end clang namespace
 
-void clang::RegisterPthreadLockChecker(GRExprEngine &Eng) {
+void GR::RegisterPthreadLockChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new PthreadLockChecker());
 }
 
diff --git a/lib/GR/Checkers/ReturnPointerRangeChecker.cpp b/lib/GR/Checkers/ReturnPointerRangeChecker.cpp
index a2a9473..98b4ea5 100644
--- a/lib/GR/Checkers/ReturnPointerRangeChecker.cpp
+++ b/lib/GR/Checkers/ReturnPointerRangeChecker.cpp
@@ -18,6 +18,7 @@
 #include "clang/GR/PathSensitive/GRExprEngine.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class ReturnPointerRangeChecker : 
@@ -30,7 +31,7 @@
 };
 }
 
-void clang::RegisterReturnPointerRangeChecker(GRExprEngine &Eng) {
+void GR::RegisterReturnPointerRangeChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new ReturnPointerRangeChecker());
 }
 
diff --git a/lib/GR/Checkers/ReturnUndefChecker.cpp b/lib/GR/Checkers/ReturnUndefChecker.cpp
index f5e417a..addae5b 100644
--- a/lib/GR/Checkers/ReturnUndefChecker.cpp
+++ b/lib/GR/Checkers/ReturnUndefChecker.cpp
@@ -19,6 +19,7 @@
 #include "clang/GR/PathSensitive/GRExprEngine.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class ReturnUndefChecker : 
@@ -31,7 +32,7 @@
 };
 }
 
-void clang::RegisterReturnUndefChecker(GRExprEngine &Eng) {
+void GR::RegisterReturnUndefChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new ReturnUndefChecker());
 }
 
diff --git a/lib/GR/Checkers/StackAddrLeakChecker.cpp b/lib/GR/Checkers/StackAddrLeakChecker.cpp
index 1852e24..87f5819 100644
--- a/lib/GR/Checkers/StackAddrLeakChecker.cpp
+++ b/lib/GR/Checkers/StackAddrLeakChecker.cpp
@@ -19,6 +19,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/SmallString.h"
 using namespace clang;
+using namespace GR;
 
 namespace {
 class StackAddrLeakChecker : public CheckerVisitor<StackAddrLeakChecker> {
@@ -40,7 +41,7 @@
 };
 }
 
-void clang::RegisterStackAddrLeakChecker(GRExprEngine &Eng) {
+void GR::RegisterStackAddrLeakChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new StackAddrLeakChecker());
 }
 
diff --git a/lib/GR/Checkers/StreamChecker.cpp b/lib/GR/Checkers/StreamChecker.cpp
index dc7bd62..01186b5 100644
--- a/lib/GR/Checkers/StreamChecker.cpp
+++ b/lib/GR/Checkers/StreamChecker.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/ImmutableMap.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 
@@ -104,14 +105,16 @@
 } // end anonymous namespace
 
 namespace clang {
+namespace GR {
   template <>
   struct GRStateTrait<StreamState> 
     : public GRStatePartialTrait<llvm::ImmutableMap<SymbolRef, StreamState> > {
     static void *GDMIndex() { return StreamChecker::getTag(); }
   };
 }
+}
 
-void clang::RegisterStreamChecker(GRExprEngine &Eng) {
+void GR::RegisterStreamChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new StreamChecker());
 }
 
diff --git a/lib/GR/Checkers/UndefBranchChecker.cpp b/lib/GR/Checkers/UndefBranchChecker.cpp
index ebeb7a4..fa3dfa5 100644
--- a/lib/GR/Checkers/UndefBranchChecker.cpp
+++ b/lib/GR/Checkers/UndefBranchChecker.cpp
@@ -17,6 +17,7 @@
 #include "clang/GR/PathSensitive/Checker.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 
@@ -55,7 +56,7 @@
 
 }
 
-void clang::RegisterUndefBranchChecker(GRExprEngine &Eng) {
+void GR::RegisterUndefBranchChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new UndefBranchChecker());
 }
 
diff --git a/lib/GR/Checkers/UndefCapturedBlockVarChecker.cpp b/lib/GR/Checkers/UndefCapturedBlockVarChecker.cpp
index 78b8394..8a1c285 100644
--- a/lib/GR/Checkers/UndefCapturedBlockVarChecker.cpp
+++ b/lib/GR/Checkers/UndefCapturedBlockVarChecker.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class UndefCapturedBlockVarChecker
@@ -31,7 +32,7 @@
 };
 } // end anonymous namespace
 
-void clang::RegisterUndefCapturedBlockVarChecker(GRExprEngine &Eng) {
+void GR::RegisterUndefCapturedBlockVarChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new UndefCapturedBlockVarChecker());
 }
 
diff --git a/lib/GR/Checkers/UndefResultChecker.cpp b/lib/GR/Checkers/UndefResultChecker.cpp
index df3ad3e..f4d3035 100644
--- a/lib/GR/Checkers/UndefResultChecker.cpp
+++ b/lib/GR/Checkers/UndefResultChecker.cpp
@@ -18,6 +18,7 @@
 #include "clang/GR/PathSensitive/GRExprEngine.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class UndefResultChecker 
@@ -32,7 +33,7 @@
 };
 } // end anonymous namespace
 
-void clang::RegisterUndefResultChecker(GRExprEngine &Eng) {
+void GR::RegisterUndefResultChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new UndefResultChecker());
 }
 
diff --git a/lib/GR/Checkers/UndefinedArraySubscriptChecker.cpp b/lib/GR/Checkers/UndefinedArraySubscriptChecker.cpp
index 8ef3986..8946de3 100644
--- a/lib/GR/Checkers/UndefinedArraySubscriptChecker.cpp
+++ b/lib/GR/Checkers/UndefinedArraySubscriptChecker.cpp
@@ -17,6 +17,7 @@
 #include "clang/GR/PathSensitive/CheckerVisitor.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class UndefinedArraySubscriptChecker
@@ -33,7 +34,7 @@
 };
 } // end anonymous namespace
 
-void clang::RegisterUndefinedArraySubscriptChecker(GRExprEngine &Eng) {
+void GR::RegisterUndefinedArraySubscriptChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new UndefinedArraySubscriptChecker());
 }
 
diff --git a/lib/GR/Checkers/UndefinedAssignmentChecker.cpp b/lib/GR/Checkers/UndefinedAssignmentChecker.cpp
index 4273f0c..b1eb387 100644
--- a/lib/GR/Checkers/UndefinedAssignmentChecker.cpp
+++ b/lib/GR/Checkers/UndefinedAssignmentChecker.cpp
@@ -17,6 +17,7 @@
 #include "clang/GR/PathSensitive/CheckerVisitor.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class UndefinedAssignmentChecker
@@ -30,7 +31,7 @@
 };
 }
 
-void clang::RegisterUndefinedAssignmentChecker(GRExprEngine &Eng){
+void GR::RegisterUndefinedAssignmentChecker(GRExprEngine &Eng){
   Eng.registerCheck(new UndefinedAssignmentChecker());
 }
 
diff --git a/lib/GR/Checkers/UnixAPIChecker.cpp b/lib/GR/Checkers/UnixAPIChecker.cpp
index 4f1b25f..f4c75f7 100644
--- a/lib/GR/Checkers/UnixAPIChecker.cpp
+++ b/lib/GR/Checkers/UnixAPIChecker.cpp
@@ -21,6 +21,7 @@
 #include <fcntl.h>
 
 using namespace clang;
+using namespace GR;
 using llvm::Optional;
 
 namespace {
@@ -45,7 +46,7 @@
 };
 } //end anonymous namespace
 
-void clang::RegisterUnixAPIChecker(GRExprEngine &Eng) {
+void GR::RegisterUnixAPIChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new UnixAPIChecker());
 }
 
diff --git a/lib/GR/Checkers/UnreachableCodeChecker.cpp b/lib/GR/Checkers/UnreachableCodeChecker.cpp
index 5f8b229..0ab97c2 100644
--- a/lib/GR/Checkers/UnreachableCodeChecker.cpp
+++ b/lib/GR/Checkers/UnreachableCodeChecker.cpp
@@ -29,6 +29,7 @@
 #define DEFAULT_CFGBLOCKS 256
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class UnreachableCodeChecker : public Checker {
@@ -53,7 +54,7 @@
   return &x;
 }
 
-void clang::RegisterUnreachableCodeChecker(GRExprEngine &Eng) {
+void GR::RegisterUnreachableCodeChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new UnreachableCodeChecker());
 }
 
diff --git a/lib/GR/Checkers/VLASizeChecker.cpp b/lib/GR/Checkers/VLASizeChecker.cpp
index 8c4d903..d4e9d35 100644
--- a/lib/GR/Checkers/VLASizeChecker.cpp
+++ b/lib/GR/Checkers/VLASizeChecker.cpp
@@ -21,6 +21,7 @@
 #include "clang/GR/PathSensitive/GRExprEngine.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class VLASizeChecker : public CheckerVisitor<VLASizeChecker> {
@@ -34,7 +35,7 @@
 };
 } // end anonymous namespace
 
-void clang::RegisterVLASizeChecker(GRExprEngine &Eng) {
+void GR::RegisterVLASizeChecker(GRExprEngine &Eng) {
   Eng.registerCheck(new VLASizeChecker());
 }
 
diff --git a/lib/GR/Environment.cpp b/lib/GR/Environment.cpp
index 5846d6a..74ac7f2 100644
--- a/lib/GR/Environment.cpp
+++ b/lib/GR/Environment.cpp
@@ -16,6 +16,7 @@
 #include "clang/GR/PathSensitive/GRState.h"
 
 using namespace clang;
+using namespace GR;
 
 SVal Environment::lookupExpr(const Stmt* E) const {
   const SVal* X = ExprBindings.lookup(E);
diff --git a/lib/GR/ExplodedGraph.cpp b/lib/GR/ExplodedGraph.cpp
index 6890ebf..fc46813 100644
--- a/lib/GR/ExplodedGraph.cpp
+++ b/lib/GR/ExplodedGraph.cpp
@@ -21,6 +21,7 @@
 #include <vector>
 
 using namespace clang;
+using namespace GR;
 
 //===----------------------------------------------------------------------===//
 // Node auditing.
diff --git a/lib/GR/FlatStore.cpp b/lib/GR/FlatStore.cpp
index 6e70f61..d4bd4b8 100644
--- a/lib/GR/FlatStore.cpp
+++ b/lib/GR/FlatStore.cpp
@@ -12,6 +12,7 @@
 #include "llvm/Support/ErrorHandling.h"
 
 using namespace clang;
+using namespace GR;
 using llvm::Interval;
 
 // The actual store type.
@@ -83,7 +84,7 @@
 };
 } // end anonymous namespace
 
-StoreManager *clang::CreateFlatStoreManager(GRStateManager &StMgr) {
+StoreManager *GR::CreateFlatStoreManager(GRStateManager &StMgr) {
   return new FlatStoreManager(StMgr);
 }
 
diff --git a/lib/GR/FrontendActions.cpp b/lib/GR/FrontendActions.cpp
index e3ef60b..2097657 100644
--- a/lib/GR/FrontendActions.cpp
+++ b/lib/GR/FrontendActions.cpp
@@ -11,6 +11,7 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/GR/AnalysisConsumer.h"
 using namespace clang;
+using namespace GR;
 
 ASTConsumer *AnalysisAction::CreateASTConsumer(CompilerInstance &CI,
                                                llvm::StringRef InFile) {
diff --git a/lib/GR/GRBlockCounter.cpp b/lib/GR/GRBlockCounter.cpp
index 6a19917..8a026b1 100644
--- a/lib/GR/GRBlockCounter.cpp
+++ b/lib/GR/GRBlockCounter.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/ImmutableMap.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 
diff --git a/lib/GR/GRCXXExprEngine.cpp b/lib/GR/GRCXXExprEngine.cpp
index 73b8b27..2462955 100644
--- a/lib/GR/GRCXXExprEngine.cpp
+++ b/lib/GR/GRCXXExprEngine.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/DeclCXX.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class CallExprWLItem {
diff --git a/lib/GR/GRCoreEngine.cpp b/lib/GR/GRCoreEngine.cpp
index 9f34e89..092cb46 100644
--- a/lib/GR/GRCoreEngine.cpp
+++ b/lib/GR/GRCoreEngine.cpp
@@ -25,12 +25,15 @@
 using llvm::cast;
 using llvm::isa;
 using namespace clang;
+using namespace GR;
 
 // This should be removed in the future.
 namespace clang {
+namespace GR {
 GRTransferFuncs* MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled,
                                   const LangOptions& lopts);
 }
+}
 
 //===----------------------------------------------------------------------===//
 // Worklist classes for exploration of reachable states.
diff --git a/lib/GR/GRExprEngine.cpp b/lib/GR/GRExprEngine.cpp
index 8743f71..d6086c7 100644
--- a/lib/GR/GRExprEngine.cpp
+++ b/lib/GR/GRExprEngine.cpp
@@ -37,6 +37,7 @@
 #endif
 
 using namespace clang;
+using namespace GR;
 using llvm::dyn_cast;
 using llvm::dyn_cast_or_null;
 using llvm::cast;
diff --git a/lib/GR/GRState.cpp b/lib/GR/GRState.cpp
index 164cd8c..993fa1a 100644
--- a/lib/GR/GRState.cpp
+++ b/lib/GR/GRState.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
+using namespace GR;
 
 // Give the vtable for ConstraintManager somewhere to live.
 // FIXME: Move this elsewhere.
diff --git a/lib/GR/HTMLDiagnostics.cpp b/lib/GR/HTMLDiagnostics.cpp
index 0db63c7..0c059ff 100644
--- a/lib/GR/HTMLDiagnostics.cpp
+++ b/lib/GR/HTMLDiagnostics.cpp
@@ -26,6 +26,7 @@
 #include "llvm/Support/Path.h"
 
 using namespace clang;
+using namespace GR;
 
 //===----------------------------------------------------------------------===//
 // Boilerplate.
@@ -77,7 +78,7 @@
 }
 
 PathDiagnosticClient*
-clang::createHTMLDiagnosticClient(const std::string& prefix,
+GR::createHTMLDiagnosticClient(const std::string& prefix,
                                   const Preprocessor &PP) {
   return new HTMLDiagnostics(prefix, PP);
 }
diff --git a/lib/GR/ManagerRegistry.cpp b/lib/GR/ManagerRegistry.cpp
index b1920e1..ab3a0a1 100644
--- a/lib/GR/ManagerRegistry.cpp
+++ b/lib/GR/ManagerRegistry.cpp
@@ -14,6 +14,7 @@
 #include "clang/GR/ManagerRegistry.h"
 
 using namespace clang;
+using namespace GR;
 
 StoreManagerCreator ManagerRegistry::StoreMgrCreator = 0;
 
diff --git a/lib/GR/MemRegion.cpp b/lib/GR/MemRegion.cpp
index a1dee53..1ae9ccf 100644
--- a/lib/GR/MemRegion.cpp
+++ b/lib/GR/MemRegion.cpp
@@ -22,6 +22,7 @@
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
+using namespace GR;
 
 //===----------------------------------------------------------------------===//
 // MemRegion Construction.
diff --git a/lib/GR/PathDiagnostic.cpp b/lib/GR/PathDiagnostic.cpp
index 1710643..b496560 100644
--- a/lib/GR/PathDiagnostic.cpp
+++ b/lib/GR/PathDiagnostic.cpp
@@ -20,6 +20,7 @@
 #include "llvm/Support/Casting.h"
 
 using namespace clang;
+using namespace GR;
 using llvm::dyn_cast;
 using llvm::isa;
 
diff --git a/lib/GR/PlistDiagnostics.cpp b/lib/GR/PlistDiagnostics.cpp
index 5b91f6e..35a46bf 100644
--- a/lib/GR/PlistDiagnostics.cpp
+++ b/lib/GR/PlistDiagnostics.cpp
@@ -21,6 +21,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 using namespace clang;
+using namespace GR;
 using llvm::cast;
 
 typedef llvm::DenseMap<FileID, unsigned> FIDMap;
@@ -97,7 +98,7 @@
   : OutputFile(output), LangOpts(LO), SubPD(subPD), flushed(false) {}
 
 PathDiagnosticClient*
-clang::createPlistDiagnosticClient(const std::string& s, const Preprocessor &PP,
+GR::createPlistDiagnosticClient(const std::string& s, const Preprocessor &PP,
                                    PathDiagnosticClient *subPD) {
   return new PlistDiagnostics(s, PP.getLangOptions(), subPD);
 }
diff --git a/lib/GR/RangeConstraintManager.cpp b/lib/GR/RangeConstraintManager.cpp
index 423777e..378cb6e 100644
--- a/lib/GR/RangeConstraintManager.cpp
+++ b/lib/GR/RangeConstraintManager.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace { class ConstraintRange {}; }
 static int ConstraintRangeIndex = 0;
@@ -194,12 +195,14 @@
 typedef llvm::ImmutableMap<SymbolRef,RangeSet> ConstraintRangeTy;
 
 namespace clang {
+namespace GR {
 template<>
 struct GRStateTrait<ConstraintRange>
   : public GRStatePartialTrait<ConstraintRangeTy> {
   static inline void* GDMIndex() { return &ConstraintRangeIndex; }
 };
 }
+}
 
 namespace {
 class RangeConstraintManager : public SimpleConstraintManager{
@@ -251,8 +254,8 @@
 
 } // end anonymous namespace
 
-ConstraintManager* clang::CreateRangeConstraintManager(GRStateManager&,
-                                                       GRSubEngine &subeng) {
+ConstraintManager* GR::CreateRangeConstraintManager(GRStateManager&,
+                                                    GRSubEngine &subeng) {
   return new RangeConstraintManager(subeng);
 }
 
diff --git a/lib/GR/RegionStore.cpp b/lib/GR/RegionStore.cpp
index a310b19..f2c4737 100644
--- a/lib/GR/RegionStore.cpp
+++ b/lib/GR/RegionStore.cpp
@@ -29,6 +29,7 @@
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
+using namespace GR;
 using llvm::Optional;
 
 //===----------------------------------------------------------------------===//
@@ -403,12 +404,12 @@
 // RegionStore creation.
 //===----------------------------------------------------------------------===//
 
-StoreManager *clang::CreateRegionStoreManager(GRStateManager& StMgr) {
+StoreManager *GR::CreateRegionStoreManager(GRStateManager& StMgr) {
   RegionStoreFeatures F = maximal_features_tag();
   return new RegionStoreManager(StMgr, F);
 }
 
-StoreManager *clang::CreateFieldsOnlyRegionStoreManager(GRStateManager &StMgr) {
+StoreManager *GR::CreateFieldsOnlyRegionStoreManager(GRStateManager &StMgr) {
   RegionStoreFeatures F = minimal_features_tag();
   F.enableFields(true);
   return new RegionStoreManager(StMgr, F);
diff --git a/lib/GR/SValBuilder.cpp b/lib/GR/SValBuilder.cpp
index 95829c2..daff8dd 100644
--- a/lib/GR/SValBuilder.cpp
+++ b/lib/GR/SValBuilder.cpp
@@ -19,6 +19,7 @@
 #include "clang/GR/PathSensitive/BasicValueFactory.h"
 
 using namespace clang;
+using namespace GR;
 
 //===----------------------------------------------------------------------===//
 // Basic SVal creation.
diff --git a/lib/GR/SVals.cpp b/lib/GR/SVals.cpp
index deccc4b..6040d5e 100644
--- a/lib/GR/SVals.cpp
+++ b/lib/GR/SVals.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/IdentifierTable.h"
 
 using namespace clang;
+using namespace GR;
 using llvm::dyn_cast;
 using llvm::cast;
 using llvm::APSInt;
diff --git a/lib/GR/SimpleConstraintManager.cpp b/lib/GR/SimpleConstraintManager.cpp
index 7c246e4..991d0e8 100644
--- a/lib/GR/SimpleConstraintManager.cpp
+++ b/lib/GR/SimpleConstraintManager.cpp
@@ -19,6 +19,8 @@
 
 namespace clang {
 
+namespace GR {
+
 SimpleConstraintManager::~SimpleConstraintManager() {}
 
 bool SimpleConstraintManager::canReasonAbout(SVal X) const {
@@ -296,4 +298,6 @@
   } // end switch
 }
 
-}  // end of namespace clang
+} // end of namespace GR
+
+} // end of namespace clang
diff --git a/lib/GR/SimpleConstraintManager.h b/lib/GR/SimpleConstraintManager.h
index 45742eb..442f0ca 100644
--- a/lib/GR/SimpleConstraintManager.h
+++ b/lib/GR/SimpleConstraintManager.h
@@ -11,14 +11,16 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_ANALYSIS_SIMPLE_CONSTRAINT_MANAGER_H
-#define LLVM_CLANG_ANALYSIS_SIMPLE_CONSTRAINT_MANAGER_H
+#ifndef LLVM_CLANG_GR_SIMPLE_CONSTRAINT_MANAGER_H
+#define LLVM_CLANG_GR_SIMPLE_CONSTRAINT_MANAGER_H
 
 #include "clang/GR/PathSensitive/ConstraintManager.h"
 #include "clang/GR/PathSensitive/GRState.h"
 
 namespace clang {
 
+namespace GR {
+
 class SimpleConstraintManager : public ConstraintManager {
   GRSubEngine &SU;
 public:
@@ -84,6 +86,8 @@
   const GRState *assumeAux(const GRState *state, NonLoc Cond, bool Assumption);
 };
 
-}  // end clang namespace
+} // end GR namespace
+
+} // end clang namespace
 
 #endif
diff --git a/lib/GR/SimpleSValBuilder.cpp b/lib/GR/SimpleSValBuilder.cpp
index 1beb055..03f8e30 100644
--- a/lib/GR/SimpleSValBuilder.cpp
+++ b/lib/GR/SimpleSValBuilder.cpp
@@ -15,6 +15,7 @@
 #include "clang/GR/PathSensitive/GRState.h"
 
 using namespace clang;
+using namespace GR;
 
 namespace {
 class SimpleSValBuilder : public SValBuilder {
@@ -46,7 +47,7 @@
 };
 } // end anonymous namespace
 
-SValBuilder *clang::createSimpleSValBuilder(llvm::BumpPtrAllocator &alloc,
+SValBuilder *GR::createSimpleSValBuilder(llvm::BumpPtrAllocator &alloc,
                                             ASTContext &context,
                                             GRStateManager &stateMgr) {
   return new SimpleSValBuilder(alloc, context, stateMgr);
diff --git a/lib/GR/Store.cpp b/lib/GR/Store.cpp
index df13ab4..99c06e4 100644
--- a/lib/GR/Store.cpp
+++ b/lib/GR/Store.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/CharUnits.h"
 
 using namespace clang;
+using namespace GR;
 
 StoreManager::StoreManager(GRStateManager &stateMgr)
   : svalBuilder(stateMgr.getSValBuilder()), StateMgr(stateMgr),
diff --git a/lib/GR/SymbolManager.cpp b/lib/GR/SymbolManager.cpp
index 8dcdb14..95df307 100644
--- a/lib/GR/SymbolManager.cpp
+++ b/lib/GR/SymbolManager.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
+using namespace GR;
 
 void SymExpr::dump() const {
   dumpToStream(llvm::errs());
diff --git a/lib/GR/TextPathDiagnostics.cpp b/lib/GR/TextPathDiagnostics.cpp
index 343b211..c7a9f56 100644
--- a/lib/GR/TextPathDiagnostics.cpp
+++ b/lib/GR/TextPathDiagnostics.cpp
@@ -16,6 +16,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace clang;
+using namespace GR;
 using namespace llvm;
 
 namespace {
@@ -47,7 +48,7 @@
 } // end anonymous namespace
 
 PathDiagnosticClient*
-clang::createTextPathDiagnosticClient(const std::string& out,
+GR::createTextPathDiagnosticClient(const std::string& out,
                                       const Preprocessor &PP) {
   return new TextPathDiagnostics(out, PP.getDiagnostics());
 }