From: Chandler Carruth Date: Tue, 22 Apr 2014 03:17:02 +0000 (+0000) Subject: [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e5043a88c3d0d7c11178c07d2d436822b959e9a;p=clang [Modules] Fix potential ODR violations by sinking the DEBUG_TYPE definition below all of the header #include lines, clang edition. If you want more details about this, you can see some of the commits to Debug.h in LLVM recently. This is just the clang section of a cleanup I've done for all uses of DEBUG_TYPE in LLVM. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206849 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp index 649ba57bf5..f78f6740d4 100644 --- a/lib/Analysis/CallGraph.cpp +++ b/lib/Analysis/CallGraph.cpp @@ -10,8 +10,6 @@ // This file defines the AST-based CallGraph. // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "CallGraph" - #include "clang/Analysis/CallGraph.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Decl.h" @@ -22,6 +20,8 @@ using namespace clang; +#define DEBUG_TYPE "CallGraph" + STATISTIC(NumObjCCallEdges, "Number of Objective-C method call edges"); STATISTIC(NumBlockCallEdges, "Number of block call edges"); diff --git a/lib/Format/BreakableToken.cpp b/lib/Format/BreakableToken.cpp index 40b53f3026..93cca66634 100644 --- a/lib/Format/BreakableToken.cpp +++ b/lib/Format/BreakableToken.cpp @@ -13,8 +13,6 @@ /// //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "format-token-breaker" - #include "BreakableToken.h" #include "clang/Basic/CharInfo.h" #include "clang/Format/Format.h" @@ -22,6 +20,8 @@ #include "llvm/Support/Debug.h" #include +#define DEBUG_TYPE "format-token-breaker" + namespace clang { namespace format { diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index de2047c458..445fc41ad2 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -12,8 +12,6 @@ /// //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "format-formatter" - #include "BreakableToken.h" #include "ContinuationIndenter.h" #include "WhitespaceManager.h" @@ -23,6 +21,8 @@ #include "llvm/Support/Debug.h" #include +#define DEBUG_TYPE "format-formatter" + namespace clang { namespace format { diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 92b98552ff..3544cff4dd 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -13,8 +13,6 @@ /// //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "format-formatter" - #include "ContinuationIndenter.h" #include "TokenAnnotator.h" #include "UnwrappedLineParser.h" @@ -31,6 +29,8 @@ #include #include +#define DEBUG_TYPE "format-formatter" + using clang::format::FormatStyle; LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index d63b38bcd1..8dd32d5f71 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -13,11 +13,11 @@ /// //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "format-parser" - #include "UnwrappedLineParser.h" #include "llvm/Support/Debug.h" +#define DEBUG_TYPE "format-parser" + namespace clang { namespace format { diff --git a/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp b/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp index 3becdca97d..97887dcd53 100644 --- a/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/AnalyzerStatsChecker.cpp @@ -8,8 +8,6 @@ //===----------------------------------------------------------------------===// // This file reports various statistics about analyzer visitation. //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "StatsChecker" - #include "ClangSACheckers.h" #include "clang/AST/DeclObjC.h" #include "clang/Basic/SourceManager.h" @@ -26,6 +24,8 @@ using namespace clang; using namespace ento; +#define DEBUG_TYPE "StatsChecker" + STATISTIC(NumBlocks, "The # of blocks in top level functions"); STATISTIC(NumBlocksUnreachable, diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index a08a2269c9..ea6af07f34 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -12,8 +12,6 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "BugReporter" - #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" @@ -40,6 +38,8 @@ using namespace clang; using namespace ento; +#define DEBUG_TYPE "BugReporter" + STATISTIC(MaxBugClassSize, "The maximum number of bug reports in the same equivalence class"); STATISTIC(MaxValidBugClassSize, diff --git a/lib/StaticAnalyzer/Core/CoreEngine.cpp b/lib/StaticAnalyzer/Core/CoreEngine.cpp index 897164b608..edba501e6e 100644 --- a/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ b/lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -12,8 +12,6 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "CoreEngine" - #include "clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h" #include "clang/AST/Expr.h" #include "clang/AST/StmtCXX.h" @@ -26,6 +24,8 @@ using namespace clang; using namespace ento; +#define DEBUG_TYPE "CoreEngine" + STATISTIC(NumSteps, "The # of steps executed."); STATISTIC(NumReachedMaxSteps, diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp index e7f49b279c..fd77e710b8 100644 --- a/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -13,8 +13,6 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "ExprEngine" - #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" #include "PrettyStackTraceLocationContext.h" #include "clang/AST/CharUnits.h" @@ -40,6 +38,8 @@ using namespace clang; using namespace ento; using llvm::APSInt; +#define DEBUG_TYPE "ExprEngine" + STATISTIC(NumRemoveDeadBindings, "The # of times RemoveDeadBindings is called"); STATISTIC(NumMaxBlockCountReached, diff --git a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index 72af75dba7..bffae0037c 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -11,8 +11,6 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "ExprEngine" - #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" #include "PrettyStackTraceLocationContext.h" #include "clang/AST/CXXInheritance.h" @@ -28,6 +26,8 @@ using namespace clang; using namespace ento; +#define DEBUG_TYPE "ExprEngine" + STATISTIC(NumOfDynamicDispatchPathSplits, "The # of times we split the path due to imprecise dynamic dispatch info"); diff --git a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index 563924d46e..3ce76e2d7f 100644 --- a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -11,8 +11,6 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "AnalysisConsumer" - #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/DataRecursiveASTVisitor.h" @@ -51,6 +49,8 @@ using namespace clang; using namespace ento; using llvm::SmallPtrSet; +#define DEBUG_TYPE "AnalysisConsumer" + static ExplodedNode::Auditor* CreateUbiViz(); STATISTIC(NumFunctionTopLevel, "The # of functions at top level."); diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 4c74ed61aa..398850c38a 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "format-test" - #include "FormatTestUtils.h" #include "clang/Format/Format.h" #include "llvm/Support/Debug.h" #include "gtest/gtest.h" +#define DEBUG_TYPE "format-test" + namespace clang { namespace format { diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index c0215e7d14..e7ca14f595 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "format-test" - #include "FormatTestUtils.h" #include "clang/Format/Format.h" #include "llvm/Support/Debug.h" #include "gtest/gtest.h" +#define DEBUG_TYPE "format-test" + namespace clang { namespace format { diff --git a/unittests/Format/FormatTestProto.cpp b/unittests/Format/FormatTestProto.cpp index 84d0d7d32e..b3dd354b2c 100644 --- a/unittests/Format/FormatTestProto.cpp +++ b/unittests/Format/FormatTestProto.cpp @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "format-test" - #include "FormatTestUtils.h" #include "clang/Format/Format.h" #include "llvm/Support/Debug.h" #include "gtest/gtest.h" +#define DEBUG_TYPE "format-test" + namespace clang { namespace format {