mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
1179e18f0c
This patch applies clang-tidy's bugprone-argument-comment tool to LLVM, clang and lld source trees. Here is how I created this patch: $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project $ mkdir build $ cd build $ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug \ -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra' \ -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_LLD=On \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm $ ninja $ parallel clang-tidy -checks='-*,bugprone-argument-comment' \ -config='{CheckOptions: [{key: StrictMode, value: 1}]}' -fix \ ::: ../llvm/lib/**/*.{cpp,h} ../clang/lib/**/*.{cpp,h} ../lld/**/*.{cpp,h} llvm-svn: 366177
43 lines
1.4 KiB
C++
43 lines
1.4 KiB
C++
//===-- llvm/ADT/APSInt.cpp - Arbitrary Precision Signed Int ---*- C++ -*--===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements the APSInt class, which is a simple class that
|
|
// represents an arbitrary sized integer that knows its signedness.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/ADT/APSInt.h"
|
|
#include "llvm/ADT/FoldingSet.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
using namespace llvm;
|
|
|
|
APSInt::APSInt(StringRef Str) {
|
|
assert(!Str.empty() && "Invalid string length");
|
|
|
|
// (Over-)estimate the required number of bits.
|
|
unsigned NumBits = ((Str.size() * 64) / 19) + 2;
|
|
APInt Tmp(NumBits, Str, /*radix=*/10);
|
|
if (Str[0] == '-') {
|
|
unsigned MinBits = Tmp.getMinSignedBits();
|
|
if (MinBits > 0 && MinBits < NumBits)
|
|
Tmp = Tmp.trunc(MinBits);
|
|
*this = APSInt(Tmp, /*isUnsigned=*/false);
|
|
return;
|
|
}
|
|
unsigned ActiveBits = Tmp.getActiveBits();
|
|
if (ActiveBits > 0 && ActiveBits < NumBits)
|
|
Tmp = Tmp.trunc(ActiveBits);
|
|
*this = APSInt(Tmp, /*isUnsigned=*/true);
|
|
}
|
|
|
|
void APSInt::Profile(FoldingSetNodeID& ID) const {
|
|
ID.AddInteger((unsigned) (IsUnsigned ? 1 : 0));
|
|
APInt::Profile(ID);
|
|
}
|