[cfe-commits] r121073 - in /cfe/trunk: lib/Frontend/ASTUnit.cpp tools/libclang/CIndexCodeCompletion.cpp
Douglas Gregor
dgregor at apple.com
Mon Dec 6 16:05:48 PST 2010
Author: dgregor
Date: Mon Dec 6 18:05:48 2010
New Revision: 121073
URL: http://llvm.org/viewvc/llvm-project?rev=121073&view=rev
Log:
Use atomic operations for libclang's object count tracking.
Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=121073&r1=121072&r2=121073&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Dec 6 18:05:48 2010
@@ -35,6 +35,7 @@
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/Atomic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Path.h"
@@ -85,7 +86,7 @@
/// \brief Tracks the number of ASTUnit objects that are currently active.
///
/// Used for debugging purposes only.
-static unsigned ActiveASTUnitObjects;
+static llvm::sys::cas_flag ActiveASTUnitObjects;
ASTUnit::ASTUnit(bool _MainFileIsAST)
: CaptureDiagnostics(false), MainFileIsAST(_MainFileIsAST),
@@ -98,7 +99,7 @@
CacheCodeCompletionCoolDown(0),
UnsafeToFree(false) {
if (getenv("LIBCLANG_OBJTRACKING")) {
- ++ActiveASTUnitObjects;
+ llvm::sys::AtomicIncrement(&ActiveASTUnitObjects);
fprintf(stderr, "+++ %d translation units\n", ActiveASTUnitObjects);
}
}
@@ -129,7 +130,7 @@
ClearCachedCompletionResults();
if (getenv("LIBCLANG_OBJTRACKING")) {
- --ActiveASTUnitObjects;
+ llvm::sys::AtomicDecrement(&ActiveASTUnitObjects);
fprintf(stderr, "--- %d translation units\n", ActiveASTUnitObjects);
}
}
Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=121073&r1=121072&r2=121073&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Mon Dec 6 18:05:48 2010
@@ -24,6 +24,7 @@
#include "clang/Sema/CodeCompleteConsumer.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Atomic.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Timer.h"
@@ -256,7 +257,7 @@
/// currently active.
///
/// Used for debugging purposes only.
-static unsigned CodeCompletionResultObjects;
+static llvm::sys::cas_flag CodeCompletionResultObjects;
AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults()
: CXCodeCompleteResults(),
@@ -265,7 +266,7 @@
FileMgr(FileSystemOpts),
SourceMgr(*Diag, FileMgr) {
if (getenv("LIBCLANG_OBJTRACKING")) {
- ++CodeCompletionResultObjects;
+ llvm::sys::AtomicIncrement(&CodeCompletionResultObjects);
fprintf(stderr, "+++ %d completion results\n", CodeCompletionResultObjects);
}
}
@@ -281,7 +282,7 @@
delete TemporaryBuffers[I];
if (getenv("LIBCLANG_OBJTRACKING")) {
- --CodeCompletionResultObjects;
+ llvm::sys::AtomicDecrement(&CodeCompletionResultObjects);
fprintf(stderr, "--- %d completion results\n", CodeCompletionResultObjects);
}
}
More information about the cfe-commits
mailing list