Skip to content

Commit

Permalink
Merge branch 'main' into fscale-neon
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukacma authored Sep 25, 2024
2 parents 940a7ba + 808c498 commit 2352988
Show file tree
Hide file tree
Showing 631 changed files with 49,905 additions and 17,404 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ static std::string getNameOfNamespace(const CXXRecordDecl *Decl) {
std::string Ns;
llvm::raw_string_ostream OStream(Ns);
NsDecl->printQualifiedName(OStream);
OStream.flush();
return Ns.empty() ? "(global)" : Ns;
}

Expand Down
5 changes: 0 additions & 5 deletions clang-tools-extra/clangd/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ std::string printQualifiedName(const NamedDecl &ND) {
// In clangd, context is usually available and paths are mostly noise.
Policy.AnonymousTagLocations = false;
ND.printQualifiedName(OS, Policy);
OS.flush();
assert(!StringRef(QName).starts_with("::"));
return QName;
}
Expand Down Expand Up @@ -270,7 +269,6 @@ std::string printTemplateSpecializationArgs(const NamedDecl &ND) {
// location information.
printTemplateArgumentList(OS, Cls->getTemplateArgs().asArray(), Policy);
}
OS.flush();
return TemplateArgs;
}

Expand Down Expand Up @@ -303,7 +301,6 @@ std::string printObjCMethod(const ObjCMethodDecl &Method) {
OS << ", ...";

OS << ']';
OS.flush();
return Name;
}

Expand All @@ -314,15 +311,13 @@ std::string printObjCContainer(const ObjCContainerDecl &C) {
const ObjCInterfaceDecl *Class = Category->getClassInterface();
OS << getNameOrErrForObjCInterface(Class) << '(' << Category->getName()
<< ')';
OS.flush();
return Name;
}
if (const ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(&C)) {
std::string Name;
llvm::raw_string_ostream OS(Name);
const ObjCInterfaceDecl *Class = CID->getClassInterface();
OS << getNameOrErrForObjCInterface(Class) << '(' << CID->getName() << ')';
OS.flush();
return Name;
}
return C.getNameAsString();
Expand Down
2 changes: 0 additions & 2 deletions clang-tools-extra/clangd/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ std::string mainMessage(const Diag &D, const ClangdDiagnosticOptions &Opts) {
OS << "\n\n";
printDiag(OS, Note);
}
OS.flush();
return capitalize(std::move(Result));
}

Expand All @@ -335,7 +334,6 @@ std::string noteMessage(const Diag &Main, const DiagBase &Note,
OS << "\n\n";
printDiag(OS, Main);
}
OS.flush();
return capitalize(std::move(Result));
}

Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clangd/FindSymbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ std::string getSymbolName(ASTContext &Ctx, const NamedDecl &ND) {
OS << (Method->isInstanceMethod() ? '-' : '+');
Method->getSelector().print(OS);

OS.flush();
return Name;
}
return printName(Ctx, ND);
Expand Down
4 changes: 0 additions & 4 deletions clang-tools-extra/clangd/Hover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ std::string printDefinition(const Decl *D, PrintingPolicy PP,
std::string Definition;
llvm::raw_string_ostream OS(Definition);
D->print(OS, PP);
OS.flush();
return Definition;
}

Expand Down Expand Up @@ -179,7 +178,6 @@ HoverInfo::PrintedType printType(QualType QT, ASTContext &ASTCtx,
OS << TT->getDecl()->getKindName() << " ";
}
QT.print(OS, PP);
OS.flush();

const Config &Cfg = Config::current();
if (!QT.isNull() && Cfg.Hover.ShowAKA) {
Expand Down Expand Up @@ -229,7 +227,6 @@ HoverInfo::PrintedType printType(const TemplateTemplateParmDecl *TTP,
// FIXME: TemplateTemplateParameter doesn't store the info on whether this
// param was a "typename" or "class".
OS << "> class";
OS.flush();
return Result;
}

Expand Down Expand Up @@ -821,7 +818,6 @@ std::string typeAsDefinition(const HoverInfo::PrintedType &PType) {
OS << PType.Type;
if (PType.AKA)
OS << " // aka: " << *PType.AKA;
OS.flush();
return Result;
}

Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clangd/Preamble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,6 @@ PreamblePatch PreamblePatch::create(llvm::StringRef FileName,
PP.PatchedMarks = std::move(ModifiedScan->Marks);
PP.PatchedMacros = std::move(ModifiedScan->Macros);
dlog("Created preamble patch: {0}", Patch.str());
Patch.flush();
return PP;
}

Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clangd/Quality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ std::string sortText(float Score, llvm::StringRef Name) {
llvm::write_hex(OS, encodeFloat(-Score), llvm::HexPrintStyle::Lower,
/*Width=*/2 * sizeof(Score));
OS << Name;
OS.flush();
return S;
}

Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clangd/SystemIncludeExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ std::string convertGlobToRegex(llvm::StringRef Glob) {
}
}
RegStream << '$';
RegStream.flush();
return RegText;
}

Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clangd/index/StdLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ std::string buildUmbrella(llvm::StringLiteral Mandatory,
"#endif\n",
Header);
}
OS.flush();
return Result;
}

Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ const NamedDecl &findDeclWithTemplateArgs(ParsedAST &AST,
// Use getNameForDiagnostic() which includes the template
// arguments in the printed name.
ND.getNameForDiagnostic(OS, Policy, /*Qualified=*/true);
OS.flush();
return QName == Query;
});
}
Expand Down
5 changes: 5 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ Changes in existing checks
usages of ``sizeof()``, ``alignof()``, and ``offsetof()`` when adding or
subtracting from a pointer.

- Improved :doc:`bugprone-unchecked-optional-access
<clang-tidy/checks/bugprone/unchecked-optional-access>` to support
`bsl::optional` and `bdlb::NullableValue` from
<https://github.com/bloomberg/bde>_.

- Improved :doc:`cert-flp30-c <clang-tidy/checks/cert/flp30-c>` check to
fix false positive that floating point variable is only used in increment
expression.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ results. Therefore, it may be more resource intensive (RAM, CPU) than the
average clang-tidy check.

This check identifies unsafe accesses to values contained in
``std::optional<T>``, ``absl::optional<T>``, ``base::Optional<T>``, or
``folly::Optional<T>`` objects. Below we will refer to all these types
collectively as ``optional<T>``.
``std::optional<T>``, ``absl::optional<T>``, ``base::Optional<T>``,
``folly::Optional<T>``, ``bsl::optional``, or
``BloombergLP::bdlb::NullableValue`` objects. Below we will refer to all these
types collectively as ``optional<T>``.

An access to the value of an ``optional<T>`` occurs when one of its ``value``,
``operator*``, or ``operator->`` member functions is invoked. To align with
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ TEST_F(PragmaIncludeTest, IWYUExportBlock) {
for (auto &FE : FEs) {
OS << FE.getName() << " ";
}
OS.flush();
return Result;
};
auto Exporters = PI.getExporters(FM.getFile("private1.h").get(), FM);
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/modularize/Modularize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,6 @@ class CollectEntitiesVisitor
std::string Name;
llvm::raw_string_ostream OS(Name);
ND->printQualifiedName(OS);
OS.flush();
if (Name.empty())
return true;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_NULLABLEVALUE_H_
#define LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_NULLABLEVALUE_H_

#include "bsl_optional.h"

/// Mock of `bdlb::NullableValue`.
namespace BloombergLP::bdlb {

template <typename T>
class NullableValue : public bsl::optional<T> {
public:
constexpr NullableValue() noexcept;

constexpr NullableValue(bsl::nullopt_t) noexcept;

NullableValue(const NullableValue &) = default;

NullableValue(NullableValue &&) = default;

const T &value() const &;
T &value() &;

// 'operator bool' is inherited from bsl::optional

constexpr bool isNull() const noexcept;

template <typename U>
constexpr T valueOr(U &&v) const &;

// 'reset' is inherited from bsl::optional

template <typename U> NullableValue &operator=(const U &u);
};


} // namespace BloombergLP::bdlb

#endif // LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_NULLABLEVALUE_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_OPTIONAL_H_
#define LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_OPTIONAL_H_

/// Mock of `bsl::optional`.
namespace bsl {

// clang-format off
template <typename T> struct remove_reference { using type = T; };
template <typename T> struct remove_reference<T&> { using type = T; };
template <typename T> struct remove_reference<T&&> { using type = T; };
// clang-format on

template <typename T>
using remove_reference_t = typename remove_reference<T>::type;

template <typename T>
constexpr T &&forward(remove_reference_t<T> &t) noexcept;

template <typename T>
constexpr T &&forward(remove_reference_t<T> &&t) noexcept;

template <typename T>
constexpr remove_reference_t<T> &&move(T &&x);

struct nullopt_t {
constexpr explicit nullopt_t() {}
};

constexpr nullopt_t nullopt;

template <typename T>
class optional {
public:
constexpr optional() noexcept;

constexpr optional(nullopt_t) noexcept;

optional(const optional &) = default;

optional(optional &&) = default;

const T &operator*() const &;
T &operator*() &;
const T &&operator*() const &&;
T &&operator*() &&;

const T *operator->() const;
T *operator->();

const T &value() const &;
T &value() &;
const T &&value() const &&;
T &&value() &&;

constexpr explicit operator bool() const noexcept;
constexpr bool has_value() const noexcept;

template <typename U>
constexpr T value_or(U &&v) const &;
template <typename U>
T value_or(U &&v) &&;

template <typename... Args>
T &emplace(Args &&...args);

void reset() noexcept;

void swap(optional &rhs) noexcept;

template <typename U> optional &operator=(const U &u);
};

} // namespace bsl

#endif // LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_CHECKERS_INPUTS_BDE_TYPES_OPTIONAL_H_
Loading

0 comments on commit 2352988

Please sign in to comment.