#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
-#include "llvm/Support/Atomic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/YAMLParser.h"
+#include <atomic>
using namespace clang;
using namespace clang::vfs;
}
UniqueID vfs::getNextVirtualUniqueID() {
- static volatile sys::cas_flag UID = 0;
- sys::cas_flag ID = llvm::sys::AtomicIncrement(&UID);
+ static std::atomic<unsigned> UID;
+ unsigned ID = ++UID;
// The following assumes that uint64_t max will never collide with a real
// dev_t value from the OS.
return UniqueID(std::numeric_limits<uint64_t>::max(), ID);
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h"
-#include "llvm/Support/Atomic.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
+#include <atomic>
#include <cstdio>
#include <cstdlib>
#include <sys/stat.h>
/// \brief Tracks the number of ASTUnit objects that are currently active.
///
/// Used for debugging purposes only.
-static llvm::sys::cas_flag ActiveASTUnitObjects;
+static std::atomic<unsigned> ActiveASTUnitObjects;
ASTUnit::ASTUnit(bool _MainFileIsAST)
: Reader(0), HadModuleLoaderFatalFailure(false),
PreambleTopLevelHashValue(0),
CurrentTopLevelHashValue(0),
UnsafeToFree(false) {
- if (getenv("LIBCLANG_OBJTRACKING")) {
- llvm::sys::AtomicIncrement(&ActiveASTUnitObjects);
- fprintf(stderr, "+++ %d translation units\n", (int)ActiveASTUnitObjects);
- }
+ if (getenv("LIBCLANG_OBJTRACKING"))
+ fprintf(stderr, "+++ %u translation units\n", ++ActiveASTUnitObjects);
}
ASTUnit::~ASTUnit() {
ClearCachedCompletionResults();
- if (getenv("LIBCLANG_OBJTRACKING")) {
- llvm::sys::AtomicDecrement(&ActiveASTUnitObjects);
- fprintf(stderr, "--- %d translation units\n", (int)ActiveASTUnitObjects);
- }
+ if (getenv("LIBCLANG_OBJTRACKING"))
+ fprintf(stderr, "--- %u translation units\n", --ActiveASTUnitObjects);
}
void ASTUnit::setPreprocessor(Preprocessor *pp) { PP = pp; }
#include "llvm/Option/ArgList.h"
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
-#include "llvm/Support/Atomic.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/system_error.h"
+#include <atomic>
#include <sys/stat.h>
using namespace clang;
// is what we want in such case.
static const size_t kGraveYardMaxSize = 16;
LLVM_ATTRIBUTE_UNUSED static const void *GraveYard[kGraveYardMaxSize];
- static llvm::sys::cas_flag GraveYardSize;
- llvm::sys::cas_flag Idx = llvm::sys::AtomicIncrement(&GraveYardSize) - 1;
+ static std::atomic<unsigned> GraveYardSize;
+ unsigned Idx = GraveYardSize++;
if (Idx >= kGraveYardMaxSize)
return;
GraveYard[Idx] = Ptr;
#include "clang/Sema/Sema.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
-#include "llvm/Support/Atomic.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
+#include <atomic>
#include <cstdio>
#include <cstdlib>
#include <string>
/// currently active.
///
/// Used for debugging purposes only.
-static llvm::sys::cas_flag CodeCompletionResultObjects;
+static std::atomic<unsigned> CodeCompletionResultObjects;
AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults(
const FileSystemOptions& FileSystemOpts)
ContainerKind(CXCursor_InvalidCode),
ContainerIsIncomplete(1)
{
- if (getenv("LIBCLANG_OBJTRACKING")) {
- llvm::sys::AtomicIncrement(&CodeCompletionResultObjects);
- fprintf(stderr, "+++ %d completion results\n", CodeCompletionResultObjects);
- }
+ if (getenv("LIBCLANG_OBJTRACKING"))
+ fprintf(stderr, "+++ %u completion results\n",
+ ++CodeCompletionResultObjects);
}
AllocatedCXCodeCompleteResults::~AllocatedCXCodeCompleteResults() {
for (unsigned I = 0, N = TemporaryBuffers.size(); I != N; ++I)
delete TemporaryBuffers[I];
- if (getenv("LIBCLANG_OBJTRACKING")) {
- llvm::sys::AtomicDecrement(&CodeCompletionResultObjects);
- fprintf(stderr, "--- %d completion results\n", CodeCompletionResultObjects);
- }
+ if (getenv("LIBCLANG_OBJTRACKING"))
+ fprintf(stderr, "--- %u completion results\n",
+ --CodeCompletionResultObjects);
}
} // end extern "C"