Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/release/14.x' into rustc/14.0-…
Browse files Browse the repository at this point in the history
…2022-02-09
  • Loading branch information
nikic committed Mar 9, 2022
2 parents c03f980 + e879b2b commit c8eccf6
Show file tree
Hide file tree
Showing 773 changed files with 14,449 additions and 8,838 deletions.
2 changes: 1 addition & 1 deletion bolt/tools/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ install(PROGRAMS
${CMAKE_BINARY_DIR}/bin/perf2bolt
${CMAKE_BINARY_DIR}/bin/llvm-boltdiff
${CMAKE_BINARY_DIR}/bin/llvm-bolt-heatmap
TYPE BIN
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT bolt
)
add_llvm_install_targets(install-bolt DEPENDS bolt COMPONENT bolt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,23 +711,28 @@ void SuspiciousCallArgumentCheck::setArgNamesAndTypes(

for (std::size_t I = InitialArgIndex, J = MatchedCallExpr->getNumArgs();
I < J; ++I) {
assert(ArgTypes.size() == I - InitialArgIndex &&
ArgNames.size() == ArgTypes.size() &&
"Every iteration must put an element into the vectors!");

if (const auto *ArgExpr = dyn_cast<DeclRefExpr>(
MatchedCallExpr->getArg(I)->IgnoreUnlessSpelledInSource())) {
if (const auto *Var = dyn_cast<VarDecl>(ArgExpr->getDecl())) {
ArgTypes.push_back(Var->getType());
ArgNames.push_back(Var->getName());
} else if (const auto *FCall =
dyn_cast<FunctionDecl>(ArgExpr->getDecl())) {
ArgTypes.push_back(FCall->getType());
ArgNames.push_back(FCall->getName());
} else {
ArgTypes.push_back(QualType());
ArgNames.push_back(StringRef());
continue;
}
if (const auto *FCall = dyn_cast<FunctionDecl>(ArgExpr->getDecl())) {
if (FCall->getNameInfo().getName().isIdentifier()) {
ArgTypes.push_back(FCall->getType());
ArgNames.push_back(FCall->getName());
continue;
}
}
} else {
ArgTypes.push_back(QualType());
ArgNames.push_back(StringRef());
}

ArgTypes.push_back(QualType());
ArgNames.push_back(StringRef());
}
}

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/unittests/SerializationTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ TEST(SerializationTest, CmdlTest) {
}
}

// rlimit is part of POSIX.
// rlimit is part of POSIX. RLIMIT_AS does not exist in OpenBSD.
// Sanitizers use a lot of address space, so we can't apply strict limits.
#if LLVM_ON_UNIX && !LLVM_ADDRESS_SANITIZER_BUILD && \
#if LLVM_ON_UNIX && defined(RLIMIT_AS) && !LLVM_ADDRESS_SANITIZER_BUILD && \
!LLVM_MEMORY_SANITIZER_BUILD
class ScopedMemoryLimit {
struct rlimit OriginalLimit;
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ Changes in existing checks
return statements associated with ``case``, ``default`` and labeled
statements.

- Fixed a crash in :doc:`readability-suspicious-call-argument
<clang-tidy/checks/readability-suspicious-call-argument>` related to passing
arguments that refer to program elements without a trivial identifier.

Removed checks
^^^^^^^^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,3 +485,32 @@ int main() {

return 0;
}

namespace Issue_54074 {

class T {};
using OperatorTy = int(const T &, const T &);
int operator-(const T &, const T &);

template <typename U>
struct Wrap {
Wrap(U);
};

template <typename V>
void wrapTaker(V, Wrap<OperatorTy>);

template <typename V>
void wrapTaker(V aaaaa, V bbbbb, Wrap<OperatorTy>);

void test() {
wrapTaker(0, operator-);
// NO-WARN. No crash!

int aaaaa = 4, bbbbb = 8;
wrapTaker(bbbbb, aaaaa, operator-);
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 1st argument 'bbbbb' (passed to 'aaaaa') looks like it might be swapped with the 2nd, 'aaaaa' (passed to 'bbbbb')
// CHECK-MESSAGES: :[[@LINE-9]]:6: note: in the call to 'wrapTaker<int>', declared here
}

} // namespace Issue_54074
7 changes: 6 additions & 1 deletion clang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,14 @@ add_definitions( -D_GNU_SOURCE )
option(CLANG_BUILD_TOOLS
"Build the Clang tools. If OFF, just generate build targets." ON)

if(LLVM_ENABLE_PLUGINS OR LLVM_EXPORT_SYMBOLS_FOR_PLUGINS)
set(HAVE_CLANG_PLUGIN_SUPPORT ON)
else()
set(HAVE_CLANG_PLUGIN_SUPPORT OFF)
endif()
CMAKE_DEPENDENT_OPTION(CLANG_PLUGIN_SUPPORT
"Build clang with plugin support" ON
"LLVM_ENABLE_PLUGINS OR LLVM_EXPORT_SYMBOLS_FOR_PLUGINS" OFF)
"HAVE_CLANG_PLUGIN_SUPPORT" OFF)

option(CLANG_ENABLE_ARCMT "Build ARCMT." ON)
option(CLANG_ENABLE_STATIC_ANALYZER
Expand Down
34 changes: 33 additions & 1 deletion clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,21 @@ Major New Features
For more details refer to :ref:`the SPIR-V support section <spir-v>`.
- Completed support of OpenCL C 3.0 and C++ for OpenCL 2021 at experimental
state.
- ...

- Prebuilt AIX7.2 TL5 SP3+ binary available with following notes and
limitations:

- C++ driver modes use the system libc++ headers. These headers are included
in the optional ``libc++.adt.include`` fileset on AIX.
- LTO, although not disabled, is not meaningfully functional for practical
use.
- Shared libraries builds (``-shared``) must use explicit symbol export
options and/or export lists (e.g., with ``-bE:``) on the link step. Clang
currently will not automatically generate symbol export lists as implicit
linker inputs.

- ``float.h`` now exposes (in hosted mode) extensions made available from the
AIX system header.

Improvements to Clang's diagnostics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -76,6 +90,12 @@ Non-comprehensive list of changes in this release
- Configuration file syntax extended with ``<CFGDIR>`` token. This expands to
the base path of the current config file. See :ref:`configuration-files` for
details.
- The ``-E -P`` preprocessor output now always omits blank lines, matching
gcc behaviour. Previously, up to 8 consecutive blank lines could appear
in the output.
- AIX platform-related predefined macros added:
``_ARCH_PPC64``, ``__HOS_AIX__``, ``__PPC``, ``__THW_BIG_ENDIAN__``,
``__THW_PPC__``, and ``__powerpc``

New Compiler Flags
------------------
Expand All @@ -91,6 +111,16 @@ New Compiler Flags
outside of such a region.
- ``-falign-loops=N`` (N is a power of 2) is now supported for non-LTO cases.
(`D106701 <https://reviews.llvm.org/D106701>`_)
- The ``-fminimize-whitespace`` flag allows removing redundant whitespace
from preprocessor output (``-E`` flag). When combined with ``-P``, this
includes newlines. Otherwise, only indention is removed (other horizontal
whitespace is always collapsed).
The motivation is to improve compiler cache hit rate by becoming invariant
to whitespace changes, such as reformatting using clang-format. Patches
for `ccache <https://github.com/ccache/ccache/pull/815>`_ and
`sccache <https://github.com/mozilla/sccache/pull/1055>`_ are under review.

- Clang now accepts "allowlist" spelling for ``-objcmt-allowlist-dir-path``.

Deprecated Compiler Flags
-------------------------
Expand Down Expand Up @@ -158,6 +188,8 @@ Attribute Changes in Clang
attributes, but will now issue an error due to the expansion of the
predefined ``__clang__`` macro.

- Improved handling of ``__attribute__((__aligned__))`` on AIX to match GCC.

Windows Support
---------------

Expand Down
2 changes: 1 addition & 1 deletion clang/examples/AnnotateFunctions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL clang)

if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
if(WIN32 OR CYGWIN)
set(LLVM_LINK_COMPONENTS
Support
)
Expand Down
2 changes: 1 addition & 1 deletion clang/examples/Attribute/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)

if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
if(WIN32 OR CYGWIN)
target_link_libraries(Attribute PRIVATE
clangAST
clangBasic
Expand Down
12 changes: 7 additions & 5 deletions clang/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ if(NOT CLANG_BUILD_EXAMPLES)
set(EXCLUDE_FROM_ALL ON)
endif()

add_subdirectory(PrintFunctionNames)
add_subdirectory(AnnotateFunctions)
add_subdirectory(Attribute)
add_subdirectory(CallSuperAttribute)
add_subdirectory(PluginsOrder)
if(CLANG_PLUGIN_SUPPORT)
add_subdirectory(PrintFunctionNames)
add_subdirectory(AnnotateFunctions)
add_subdirectory(Attribute)
add_subdirectory(CallSuperAttribute)
add_subdirectory(PluginsOrder)
endif()
2 changes: 1 addition & 1 deletion clang/examples/CallSuperAttribute/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_llvm_library(CallSuperAttr MODULE CallSuperAttrInfo.cpp PLUGIN_TOOL clang)

if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
if(WIN32 OR CYGWIN)
set(LLVM_LINK_COMPONENTS
Support
)
Expand Down
2 changes: 1 addition & 1 deletion clang/examples/PluginsOrder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_llvm_library(PluginsOrder MODULE PluginsOrder.cpp PLUGIN_TOOL clang)

if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
if(WIN32 OR CYGWIN)
set(LLVM_LINK_COMPONENTS
Support
)
Expand Down
2 changes: 1 addition & 1 deletion clang/examples/PrintFunctionNames/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif()

add_llvm_library(PrintFunctionNames MODULE PrintFunctionNames.cpp PLUGIN_TOOL clang)

if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
if(WIN32 OR CYGWIN)
set(LLVM_LINK_COMPONENTS
Support
)
Expand Down
6 changes: 3 additions & 3 deletions clang/include/clang/AST/DeclTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2461,10 +2461,10 @@ class FriendTemplateDecl : public Decl {
SourceLocation FriendLoc;

FriendTemplateDecl(DeclContext *DC, SourceLocation Loc,
MutableArrayRef<TemplateParameterList *> Params,
TemplateParameterList **Params, unsigned NumParams,
FriendUnion Friend, SourceLocation FriendLoc)
: Decl(Decl::FriendTemplate, DC, Loc), NumParams(Params.size()),
Params(Params.data()), Friend(Friend), FriendLoc(FriendLoc) {}
: Decl(Decl::FriendTemplate, DC, Loc), NumParams(NumParams),
Params(Params), Friend(Friend), FriendLoc(FriendLoc) {}

FriendTemplateDecl(EmptyShell Empty) : Decl(Decl::FriendTemplate, Empty) {}

Expand Down
9 changes: 8 additions & 1 deletion clang/lib/AST/DeclTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
Expand Down Expand Up @@ -1098,7 +1099,13 @@ FriendTemplateDecl::Create(ASTContext &Context, DeclContext *DC,
SourceLocation L,
MutableArrayRef<TemplateParameterList *> Params,
FriendUnion Friend, SourceLocation FLoc) {
return new (Context, DC) FriendTemplateDecl(DC, L, Params, Friend, FLoc);
TemplateParameterList **TPL = nullptr;
if (!Params.empty()) {
TPL = new (Context) TemplateParameterList *[Params.size()];
llvm::copy(Params, TPL);
}
return new (Context, DC)
FriendTemplateDecl(DC, L, TPL, Params.size(), Friend, FLoc);
}

FriendTemplateDecl *FriendTemplateDecl::CreateDeserialized(ASTContext &C,
Expand Down
5 changes: 4 additions & 1 deletion clang/lib/Analysis/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT)
# Since these do not specify a specific PLUGIN_TOOL (which could be clang or
# clang-tidy), we cannot compile this unless the platform supports plugins with
# undefined symbols, and cannot use it unless the user has opted for clang plugins).
if(CLANG_ENABLE_STATIC_ANALYZER AND CLANG_PLUGIN_SUPPORT AND LLVM_ENABLE_PLUGINS)
add_subdirectory(SampleAnalyzer)
add_subdirectory(CheckerDependencyHandling)
add_subdirectory(CheckerOptionHandling)
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ static bool addSanitizerDynamicList(const ToolChain &TC, const ArgList &Args,
return false;
}

static const char *getAsNeededOption(const ToolChain &TC, bool as_needed) {
const char *tools::getAsNeededOption(const ToolChain &TC, bool as_needed) {
assert(!TC.getTriple().isOSAIX() &&
"AIX linker does not support any form of --as-needed option yet.");

Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Driver/ToolChains/CommonArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ bool addOpenMPRuntime(llvm::opt::ArgStringList &CmdArgs, const ToolChain &TC,
bool ForceStaticHostRuntime = false,
bool IsOffloadingHost = false, bool GompNeedsRT = false);

const char *getAsNeededOption(const ToolChain &TC, bool as_needed);

llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);

Expand Down
9 changes: 6 additions & 3 deletions clang/lib/Driver/ToolChains/DragonFly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ void dragonfly::Linker::ConstructJob(Compilation &C, const JobAction &JA,
assert(Output.isNothing() && "Invalid output.");
}

if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_r)) {
if (!Args.hasArg(options::OPT_shared)) {
if (Args.hasArg(options::OPT_pg))
CmdArgs.push_back(
Expand Down Expand Up @@ -119,7 +120,8 @@ void dragonfly::Linker::ConstructJob(Compilation &C, const JobAction &JA,

AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);

if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_r)) {
CmdArgs.push_back("-L/usr/lib/gcc80");

if (!Args.hasArg(options::OPT_static)) {
Expand Down Expand Up @@ -158,7 +160,8 @@ void dragonfly::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}

if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_r)) {
if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
CmdArgs.push_back(
Args.MakeArgString(getToolChain().GetFilePath("crtendS.o")));
Expand Down
9 changes: 6 additions & 3 deletions clang/lib/Driver/ToolChains/NetBSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
assert(Output.isNothing() && "Invalid output.");
}

if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_r)) {
if (!Args.hasArg(options::OPT_shared)) {
CmdArgs.push_back(
Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
Expand Down Expand Up @@ -294,7 +295,8 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}

if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_r)) {
// Use the static OpenMP runtime with -static-openmp
bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) &&
!Args.hasArg(options::OPT_static);
Expand Down Expand Up @@ -330,7 +332,8 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}

if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_r)) {
if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
CmdArgs.push_back(
Args.MakeArgString(ToolChain.GetFilePath("crtendS.o")));
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Driver/ToolChains/OpenBSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
FileType Type = ToolChain::FT_Static) const override;

bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
return true;
}

LangOptions::StackProtectorMode
GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
return LangOptions::SSPStrong;
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Driver/ToolChains/PPCLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ bool PPCLinuxToolChain::SupportIEEEFloat128(
if (Args.hasArg(options::OPT_nostdlib, options::OPT_nostdlibxx))
return true;

CXXStdlibType StdLib = ToolChain::GetCXXStdlibType(Args);
bool HasUnsupportedCXXLib =
ToolChain::GetCXXStdlibType(Args) == CST_Libcxx &&
GCCInstallation.getVersion().isOlderThan(12, 1, 0);
StdLib == CST_Libcxx ||
(StdLib == CST_Libstdcxx &&
GCCInstallation.getVersion().isOlderThan(12, 1, 0));

return GlibcSupportsFloat128(Linux::getDynamicLinker(Args)) &&
!(D.CCCIsCXX() && HasUnsupportedCXXLib);
Expand Down
Loading

0 comments on commit c8eccf6

Please sign in to comment.