Skip to content

Commit fc7f765

Browse files
committed
Merge from 'main' to 'sycl-web' (intel#80)
CONFLICT (content): Merge conflict in clang/lib/Frontend/CompilerInstance.cpp
2 parents a549cf8 + d412dbe commit fc7f765

File tree

283 files changed

+7859
-2085
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+7859
-2085
lines changed

clang/docs/ClangCommandLineReference.rst

+11
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,17 @@ Enable use-after-scope detection in AddressSanitizer
870870

871871
Enable ODR indicator globals to avoid false ODR violation reports in partially sanitized programs at the cost of an increase in binary size
872872

873+
.. option:: -fsanitize-address-destructor-kind=<arg>
874+
875+
Set the kind of module destructors emitted by AddressSanitizer instrumentation.
876+
These destructors are emitted to unregister instrumented global variables when
877+
code is unloaded (e.g. via `dlclose()`).
878+
879+
Valid options are:
880+
881+
* ``global`` - Emit module destructors that are called via a platform specific array (see `llvm.global_dtors`).
882+
* ``none`` - Do not emit module destructors.
883+
873884
.. option:: -fsanitize-blacklist=<arg>
874885

875886
Path to blacklist file for sanitizers

clang/docs/ClangFormatStyleOptions.rst

+27
Original file line numberDiff line numberDiff line change
@@ -2360,6 +2360,33 @@ the configuration (without a prefix: ``Auto``).
23602360
``ClassImpl.hpp`` would not have the main include file put on top
23612361
before any other include.
23622362

2363+
**IndentAccessModifiers** (``bool``)
2364+
Specify whether access modifiers should have their own indentation level.
2365+
2366+
When ``false``, access modifiers are indented (or outdented) relative to
2367+
the record members, respecting the ``AccessModifierOffset``. Record
2368+
members are indented one level below the record.
2369+
When ``true``, access modifiers get their own indentation level. As a
2370+
consequence, record members are indented 2 levels below the record,
2371+
regardless of the access modifier presence. Value of the
2372+
``AccessModifierOffset`` is ignored.
2373+
2374+
.. code-block:: c++
2375+
2376+
false: true:
2377+
class C { vs. class C {
2378+
class D { class D {
2379+
void bar(); void bar();
2380+
protected: protected:
2381+
D(); D();
2382+
}; };
2383+
public: public:
2384+
C(); C();
2385+
}; };
2386+
void foo() { void foo() {
2387+
return 1; return 1;
2388+
} }
2389+
23632390
**IndentCaseBlocks** (``bool``)
23642391
Indent case label blocks one level from the case label.
23652392

clang/docs/ReleaseNotes.rst

+3
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ clang-format
196196
- ``BasedOnStyle: InheritParentConfig`` allows to use the ``.clang-format`` of
197197
the parent directories to overwrite only parts of it.
198198

199+
- Option ``IndentAccessModifiers`` has been added to be able to give access
200+
modifiers their own indentation level inside records.
201+
199202
libclang
200203
--------
201204

clang/include/clang/Basic/AttrDocs.td

+17-21
Original file line numberDiff line numberDiff line change
@@ -5092,9 +5092,8 @@ def NotTailCalledDocs : Documentation {
50925092
let Category = DocCatFunction;
50935093
let Content = [{
50945094
The ``not_tail_called`` attribute prevents tail-call optimization on statically
5095-
bound calls. It has no effect on indirect calls. Virtual functions, objective-c
5096-
methods, and functions marked as ``always_inline`` cannot be marked as
5097-
``not_tail_called``.
5095+
bound calls. Objective-c methods, and functions marked as ``always_inline``
5096+
cannot be marked as ``not_tail_called``.
50985097

50995098
For example, it prevents tail-call optimization in the following case:
51005099

@@ -5120,28 +5119,25 @@ However, it doesn't prevent tail-call optimization in this case:
51205119
return (*fn)(a);
51215120
}
51225121

5123-
Marking virtual functions as ``not_tail_called`` is an error:
5122+
Generally, marking an overriding virtual function as ``not_tail_called`` is
5123+
not useful, because this attribute is a property of the static type. Calls
5124+
made through a pointer or reference to the base class type will respect
5125+
the ``not_tail_called`` attribute of the base class's member function,
5126+
regardless of the runtime destination of the call:
51245127

51255128
.. code-block:: c++
51265129

5127-
class Base {
5128-
public:
5129-
// not_tail_called on a virtual function is an error.
5130-
[[clang::not_tail_called]] virtual int foo1();
5131-
5132-
virtual int foo2();
5133-
5134-
// Non-virtual functions can be marked ``not_tail_called``.
5135-
[[clang::not_tail_called]] int foo3();
5136-
};
5137-
5138-
class Derived1 : public Base {
5139-
public:
5140-
int foo1() override;
5141-
5142-
// not_tail_called on a virtual function is an error.
5143-
[[clang::not_tail_called]] int foo2() override;
5130+
struct Foo { virtual void f(); };
5131+
struct Bar : Foo {
5132+
[[clang::not_tail_called]] void f() override;
51445133
};
5134+
void callera(Bar& bar) {
5135+
Foo& foo = bar;
5136+
// not_tail_called has no effect on here, even though the
5137+
// underlying method is f from Bar.
5138+
foo.f();
5139+
bar.f(); // No tail-call optimization on here.
5140+
}
51455141
}];
51465142
}
51475143

clang/include/clang/Basic/BuiltinsAMDGPU.def

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ BUILTIN(__builtin_amdgcn_grid_size_z, "Ui", "nc")
4444
BUILTIN(__builtin_amdgcn_mbcnt_hi, "UiUiUi", "nc")
4545
BUILTIN(__builtin_amdgcn_mbcnt_lo, "UiUiUi", "nc")
4646

47+
TARGET_BUILTIN(__builtin_amdgcn_s_memtime, "LUi", "n", "s-memtime-inst")
48+
4749
//===----------------------------------------------------------------------===//
4850
// Instruction builtins.
4951
//===----------------------------------------------------------------------===//
@@ -105,7 +107,6 @@ BUILTIN(__builtin_amdgcn_cubeid, "ffff", "nc")
105107
BUILTIN(__builtin_amdgcn_cubesc, "ffff", "nc")
106108
BUILTIN(__builtin_amdgcn_cubetc, "ffff", "nc")
107109
BUILTIN(__builtin_amdgcn_cubema, "ffff", "nc")
108-
BUILTIN(__builtin_amdgcn_s_memtime, "LUi", "n")
109110
BUILTIN(__builtin_amdgcn_s_sleep, "vIi", "n")
110111
BUILTIN(__builtin_amdgcn_s_incperflevel, "vIi", "n")
111112
BUILTIN(__builtin_amdgcn_s_decperflevel, "vIi", "n")

clang/include/clang/Basic/CodeGenOptions.def

+3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ CODEGENOPT(SanitizeAddressGlobalsDeadStripping, 1, 0) ///< Enable linker dead st
214214
CODEGENOPT(SanitizeAddressUseOdrIndicator, 1, 0) ///< Enable ODR indicator globals
215215
CODEGENOPT(SanitizeMemoryTrackOrigins, 2, 0) ///< Enable tracking origins in
216216
///< MemorySanitizer
217+
ENUM_CODEGENOPT(SanitizeAddressDtorKind, llvm::AsanDtorKind, 2,
218+
llvm::AsanDtorKind::Global) ///< Set how ASan global
219+
///< destructors are emitted.
217220
CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete detection
218221
///< in MemorySanitizer
219222
CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.

clang/include/clang/Basic/CodeGenOptions.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/Support/CodeGen.h"
2121
#include "llvm/Support/Regex.h"
2222
#include "llvm/Target/TargetOptions.h"
23+
#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
2324
#include <map>
2425
#include <memory>
2526
#include <string>
@@ -173,7 +174,7 @@ class CodeGenOptions : public CodeGenOptionsBase {
173174
std::string DebugCompilationDir;
174175

175176
/// The string to embed in coverage mapping as the current working directory.
176-
std::string ProfileCompilationDir;
177+
std::string CoverageCompilationDir;
177178

178179
/// The string to embed in the debug information for the compile unit, if
179180
/// non-empty.
@@ -184,7 +185,7 @@ class CodeGenOptions : public CodeGenOptionsBase {
184185
std::string RecordCommandLine;
185186

186187
std::map<std::string, std::string> DebugPrefixMap;
187-
std::map<std::string, std::string> ProfilePrefixMap;
188+
std::map<std::string, std::string> CoveragePrefixMap;
188189

189190
/// The ABI to use for passing floating point arguments.
190191
std::string FloatABI;

clang/include/clang/Basic/Diagnostic.h

+37
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,13 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
273273
// Which overload candidates to show.
274274
OverloadsShown ShowOverloads = Ovl_All;
275275

276+
// With Ovl_Best, the number of overload candidates to show when we encounter
277+
// an error.
278+
//
279+
// The value here is the number of candidates to show in the first nontrivial
280+
// error. Future errors may show a different number of candidates.
281+
unsigned NumOverloadsToShow = 32;
282+
276283
// Cap of # errors emitted, 0 -> no limit.
277284
unsigned ErrorLimit = 0;
278285

@@ -707,6 +714,36 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
707714
}
708715
OverloadsShown getShowOverloads() const { return ShowOverloads; }
709716

717+
/// When a call or operator fails, print out up to this many candidate
718+
/// overloads as suggestions.
719+
///
720+
/// With Ovl_Best, we set a high limit for the first nontrivial overload set
721+
/// we print, and a lower limit for later sets. This way the user has a
722+
/// chance of diagnosing at least one callsite in their program without
723+
/// having to recompile with -fshow-overloads=all.
724+
unsigned getNumOverloadCandidatesToShow() const {
725+
switch (getShowOverloads()) {
726+
case Ovl_All:
727+
// INT_MAX rather than UINT_MAX so that we don't have to think about the
728+
// effect of implicit conversions on this value. In practice we'll never
729+
// hit 2^31 candidates anyway.
730+
return std::numeric_limits<int>::max();
731+
case Ovl_Best:
732+
return NumOverloadsToShow;
733+
}
734+
}
735+
736+
/// Call this after showing N overload candidates. This influences the value
737+
/// returned by later calls to getNumOverloadCandidatesToShow().
738+
void overloadCandidatesShown(unsigned N) {
739+
// Current heuristic: Start out with a large value for NumOverloadsToShow,
740+
// and then once we print one nontrivially-large overload set, decrease it
741+
// for future calls.
742+
if (N > 4) {
743+
NumOverloadsToShow = 4;
744+
}
745+
}
746+
710747
/// Pretend that the last diagnostic issued was ignored, so any
711748
/// subsequent notes will be suppressed, or restore a prior ignoring
712749
/// state after ignoring some diagnostics and their notes, possibly in

clang/include/clang/Basic/DiagnosticSemaKinds.td

+3-1
Original file line numberDiff line numberDiff line change
@@ -3130,6 +3130,8 @@ def err_only_annotate_after_access_spec : Error<
31303130

31313131
def err_attribute_section_invalid_for_target : Error<
31323132
"argument to %select{'code_seg'|'section'}1 attribute is not valid for this target: %0">;
3133+
def err_pragma_section_invalid_for_target : Error<
3134+
"argument to #pragma section is not valid for this target: %0">;
31333135
def warn_attribute_section_drectve : Warning<
31343136
"#pragma %0(\".drectve\") has undefined behavior, "
31353137
"use #pragma comment(linker, ...) instead">, InGroup<MicrosoftDrectveSection>;
@@ -7676,7 +7678,7 @@ def warn_condition_is_assignment : Warning<"using the result of an "
76767678
"assignment as a condition without parentheses">,
76777679
InGroup<Parentheses>;
76787680
def warn_free_nonheap_object
7679-
: Warning<"attempt to call %0 on non-heap object %1">,
7681+
: Warning<"attempt to call %0 on non-heap %select{object %2|object: block expression|object: lambda-to-function-pointer conversion}1">,
76807682
InGroup<FreeNonHeapObject>;
76817683

76827684
// Completely identical except off by default.

clang/include/clang/Basic/Sanitizers.h

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "clang/Basic/LLVM.h"
1818
#include "llvm/ADT/StringRef.h"
1919
#include "llvm/Support/MathExtras.h"
20+
#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
2021
#include <cassert>
2122
#include <cstdint>
2223

@@ -193,6 +194,10 @@ inline SanitizerMask getPPTransparentSanitizers() {
193194
SanitizerKind::Undefined | SanitizerKind::FloatDivideByZero;
194195
}
195196

197+
StringRef AsanDtorKindToString(llvm::AsanDtorKind kind);
198+
199+
llvm::AsanDtorKind AsanDtorKindFromString(StringRef kind);
200+
196201
} // namespace clang
197202

198203
#endif // LLVM_CLANG_BASIC_SANITIZERS_H

clang/include/clang/Basic/TargetInfo.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "llvm/ADT/Triple.h"
3333
#include "llvm/Frontend/OpenMP/OMPGridValues.h"
3434
#include "llvm/Support/DataTypes.h"
35+
#include "llvm/Support/Error.h"
3536
#include "llvm/Support/VersionTuple.h"
3637
#include <cassert>
3738
#include <string>
@@ -1115,15 +1116,15 @@ class TargetInfo : public virtual TransferrableTargetInfo,
11151116
/// checking on attribute((section("foo"))) specifiers.
11161117
///
11171118
/// In this case, "foo" is passed in to be checked. If the section
1118-
/// specifier is invalid, the backend should return a non-empty string
1119-
/// that indicates the problem.
1119+
/// specifier is invalid, the backend should return an Error that indicates
1120+
/// the problem.
11201121
///
11211122
/// This hook is a simple quality of implementation feature to catch errors
11221123
/// and give good diagnostics in cases when the assembler or code generator
11231124
/// would otherwise reject the section specifier.
11241125
///
1125-
virtual std::string isValidSectionSpecifier(StringRef SR) const {
1126-
return "";
1126+
virtual llvm::Error isValidSectionSpecifier(StringRef SR) const {
1127+
return llvm::Error::success();
11271128
}
11281129

11291130
/// Set forced language options.

clang/include/clang/Driver/Options.td

+17-5
Original file line numberDiff line numberDiff line change
@@ -1122,10 +1122,12 @@ def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">,
11221122
def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
11231123
Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>,
11241124
Alias<fdebug_compilation_dir_EQ>;
1125-
def fprofile_compilation_dir_EQ : Joined<["-"], "fprofile-compilation-dir=">,
1125+
def fcoverage_compilation_dir_EQ : Joined<["-"], "fcoverage-compilation-dir=">,
11261126
Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>,
11271127
HelpText<"The compilation directory to embed in the coverage mapping.">,
1128-
MarshallingInfoString<CodeGenOpts<"ProfileCompilationDir">>;
1128+
MarshallingInfoString<CodeGenOpts<"CoverageCompilationDir">>;
1129+
def ffile_compilation_dir_EQ : Joined<["-"], "ffile-compilation-dir=">, Group<f_Group>,
1130+
HelpText<"The compilation directory to embed in the debug info and coverage mapping.">;
11291131
defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling",
11301132
CodeGenOpts<"DebugInfoForProfiling">, DefaultFalse,
11311133
PosFlag<SetTrue, [CC1Option], "Emit extra debug info to make sample profile more accurate">,
@@ -1520,6 +1522,16 @@ defm sanitize_address_use_odr_indicator : BoolOption<"f", "sanitize-address-use-
15201522
" reports in partially sanitized programs at the cost of an increase in binary size">,
15211523
NegFlag<SetFalse, [], "Disable ODR indicator globals">>,
15221524
Group<f_clang_Group>;
1525+
def sanitize_address_destructor_kind_EQ
1526+
: Joined<["-"], "fsanitize-address-destructor-kind=">,
1527+
MetaVarName<"<kind>">,
1528+
Flags<[CC1Option]>,
1529+
HelpText<"Set destructor type used in ASan instrumentation">,
1530+
Group<f_clang_Group>,
1531+
Values<"none,global">,
1532+
NormalizedValuesScope<"llvm::AsanDtorKind">,
1533+
NormalizedValues<["None", "Global"]>,
1534+
MarshallingInfoEnum<CodeGenOpts<"SanitizeAddressDtorKind">, "Global">;
15231535
// Note: This flag was introduced when it was necessary to distinguish between
15241536
// ABI for correct codegen. This is no longer needed, but the flag is
15251537
// not removed since targeting either ABI will behave the same.
@@ -2724,10 +2736,10 @@ def fdebug_prefix_map_EQ
27242736
: Joined<["-"], "fdebug-prefix-map=">, Group<f_Group>,
27252737
Flags<[CC1Option,CC1AsOption]>,
27262738
HelpText<"remap file source paths in debug info">;
2727-
def fprofile_prefix_map_EQ
2728-
: Joined<["-"], "fprofile-prefix-map=">, Group<f_Group>,
2739+
def fcoverage_prefix_map_EQ
2740+
: Joined<["-"], "fcoverage-prefix-map=">, Group<f_Group>,
27292741
Flags<[CC1Option]>,
2730-
HelpText<"remap file source paths in coverage info">;
2742+
HelpText<"remap file source paths in coverage mapping">;
27312743
def ffile_prefix_map_EQ
27322744
: Joined<["-"], "ffile-prefix-map=">, Group<f_Group>,
27332745
HelpText<"remap file source paths in debug info and predefined preprocessor macros">;

clang/include/clang/Driver/SanitizerArgs.h

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class SanitizerArgs {
4343
bool AsanUseOdrIndicator = false;
4444
bool AsanInvalidPointerCmp = false;
4545
bool AsanInvalidPointerSub = false;
46+
llvm::AsanDtorKind AsanDtorKind = llvm::AsanDtorKind::Invalid;
4647
std::string HwasanAbi;
4748
bool LinkRuntimes = true;
4849
bool LinkCXXRuntimes = false;

clang/include/clang/Format/Format.h

+27
Original file line numberDiff line numberDiff line change
@@ -2047,6 +2047,32 @@ struct FormatStyle {
20472047

20482048
tooling::IncludeStyle IncludeStyle;
20492049

2050+
/// Specify whether access modifiers should have their own indentation level.
2051+
///
2052+
/// When ``false``, access modifiers are indented (or outdented) relative to
2053+
/// the record members, respecting the ``AccessModifierOffset``. Record
2054+
/// members are indented one level below the record.
2055+
/// When ``true``, access modifiers get their own indentation level. As a
2056+
/// consequence, record members are always indented 2 levels below the record,
2057+
/// regardless of the access modifier presence. Value of the
2058+
/// ``AccessModifierOffset`` is ignored.
2059+
/// \code
2060+
/// false: true:
2061+
/// class C { vs. class C {
2062+
/// class D { class D {
2063+
/// void bar(); void bar();
2064+
/// protected: protected:
2065+
/// D(); D();
2066+
/// }; };
2067+
/// public: public:
2068+
/// C(); C();
2069+
/// }; };
2070+
/// void foo() { void foo() {
2071+
/// return 1; return 1;
2072+
/// } }
2073+
/// \endcode
2074+
bool IndentAccessModifiers;
2075+
20502076
/// Indent case labels one level from the switch statement.
20512077
///
20522078
/// When ``false``, use the same indentation level as for the switch
@@ -3161,6 +3187,7 @@ struct FormatStyle {
31613187
R.IncludeStyle.IncludeIsMainRegex &&
31623188
IncludeStyle.IncludeIsMainSourceRegex ==
31633189
R.IncludeStyle.IncludeIsMainSourceRegex &&
3190+
IndentAccessModifiers == R.IndentAccessModifiers &&
31643191
IndentCaseLabels == R.IndentCaseLabels &&
31653192
IndentCaseBlocks == R.IndentCaseBlocks &&
31663193
IndentGotoLabels == R.IndentGotoLabels &&

clang/include/clang/Frontend/CompilerInstance.h

+3
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@ class CompilerInstance : public ModuleLoader {
382382
/// Replace the current AuxTarget.
383383
void setAuxTarget(TargetInfo *Value);
384384

385+
// Create Target and AuxTarget based on current options
386+
bool createTarget();
387+
385388
/// }
386389
/// @name Virtual File System
387390
/// {

0 commit comments

Comments
 (0)