Skip to content

Commit fab307f

Browse files
committed
merge main into amd-staging
Reverts: 0e73bbd [AMDGPU][PromoteAlloca] Don't stop when an alloca is too big to promote (llvm#93466) Change-Id: I1d86ab5653aa184da3062366f0f55d26f56f6db2
2 parents 109283b + d33864d commit fab307f

File tree

293 files changed

+28344
-2180
lines changed

Some content is hidden

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

293 files changed

+28344
-2180
lines changed

clang/docs/InternalsManual.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,44 @@ severe that error recovery won't be able to recover sensibly from them (thus
123123
spewing a ton of bogus errors). One example of this class of error are failure
124124
to ``#include`` a file.
125125

126+
Diagnostic Wording
127+
^^^^^^^^^^^^^^^^^^
128+
The wording used for a diagnostic is critical because it is the only way for a
129+
user to know how to correct their code. Use the following suggestions when
130+
wording a diagnostic.
131+
132+
* Diagnostics in Clang do not start with a capital letter and do not end with
133+
punctuation.
134+
135+
* This does not apply to proper nouns like ``Clang`` or ``OpenMP``, to
136+
acronyms like ``GCC`` or ``ARC``, or to language standards like ``C23``
137+
or ``C++17``.
138+
* A trailing question mark is allowed. e.g., ``unknown identifier %0; did
139+
you mean %1?``.
140+
141+
* Appropriately capitalize proper nouns like ``Clang``, ``OpenCL``, ``GCC``,
142+
``Objective-C``, etc and language standard versions like ``C11`` or ``C++11``.
143+
* The wording should be succinct. If necessary, use a semicolon to combine
144+
sentence fragments instead of using complete sentences. e.g., prefer wording
145+
like ``'%0' is deprecated; it will be removed in a future release of Clang``
146+
over wording like ``'%0' is deprecated. It will be removed in a future release
147+
of Clang``.
148+
* The wording should be actionable and avoid using standards terms or grammar
149+
productions that a new user would not be familiar with. e.g., prefer wording
150+
like ``missing semicolon`` over wording like ``syntax error`` (which is not
151+
actionable) or ``expected unqualified-id`` (which uses standards terminology).
152+
* The wording should clearly explain what is wrong with the code rather than
153+
restating what the code does. e.g., prefer wording like ``type %0 requires a
154+
value in the range %1 to %2`` over wording like ``%0 is invalid``.
155+
* The wording should have enough contextual information to help the user
156+
identify the issue in a complex expression. e.g., prefer wording like
157+
``both sides of the %0 binary operator are identical`` over wording like
158+
``identical operands to binary operator``.
159+
* Use single quotes to denote syntactic constructs or command line arguments
160+
named in a diagnostic message. e.g., prefer wording like ``'this' pointer
161+
cannot be null in well-defined C++ code`` over wording like ``this pointer
162+
cannot be null in well-defined C++ code``.
163+
126164
The Format String
127165
^^^^^^^^^^^^^^^^^
128166

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,9 @@ Improvements to Clang's diagnostics
546546
- Clang emits a ``-Wparentheses`` warning for expressions with consecutive comparisons like ``x < y < z``.
547547
Fixes #GH20456.
548548

549+
- Clang no longer emits a "declared here" note for a builtin function that has no declaration in source.
550+
Fixes #GH93369.
551+
549552
Improvements to Clang's time-trace
550553
----------------------------------
551554

@@ -807,6 +810,8 @@ Bug Fixes to C++ Support
807810
- Fixed a regression introduced in Clang 18 causing a static function overloading a non-static function
808811
with the same parameters not to be diagnosed. (Fixes #GH93456).
809812
- Clang now diagnoses unexpanded parameter packs in attributes. (Fixes #GH93269).
813+
- Clang now allows ``@$``` in raw string literals. Fixes (#GH93130).
814+
- Fix an assertion failure when checking invalid ``this`` usage in the wrong context. (Fixes #GH91536).
810815

811816
Bug Fixes to AST Handling
812817
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/Attr.td

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,9 +2025,12 @@ def Convergent : InheritableAttr {
20252025
def NoInline : DeclOrStmtAttr {
20262026
let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
20272027
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
2028+
CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
20282029
Declspec<"noinline">];
2029-
let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
2030-
C23<"clang", "noinline">]>];
2030+
let Accessors = [Accessor<"isStmtNoInline", [CXX11<"clang", "noinline">,
2031+
C23<"clang", "noinline">,
2032+
CXX11<"msvc", "noinline">,
2033+
C23<"msvc", "noinline">]>];
20312034
let Documentation = [NoInlineDocs];
20322035
let Subjects = SubjectList<[Function, Stmt], WarnDiag,
20332036
"functions and statements">;

clang/include/clang/Basic/CharInfo.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ namespace charinfo {
2828
CHAR_LOWER = 0x0040, // a-z
2929
CHAR_UNDER = 0x0080, // _
3030
CHAR_PERIOD = 0x0100, // .
31-
CHAR_RAWDEL = 0x0200, // {}[]#<>%:;?*+-/^&|~!=,"'
32-
CHAR_PUNCT = 0x0400 // `$@()
31+
CHAR_PUNCT = 0x0200, // {}[]#<>%:;?*+-/^&|~!=,"'`$@()
3332
};
3433

3534
enum {
@@ -152,16 +151,17 @@ LLVM_READONLY inline bool isHexDigit(unsigned char c) {
152151
/// Note that '_' is both a punctuation character and an identifier character!
153152
LLVM_READONLY inline bool isPunctuation(unsigned char c) {
154153
using namespace charinfo;
155-
return (InfoTable[c] & (CHAR_UNDER|CHAR_PERIOD|CHAR_RAWDEL|CHAR_PUNCT)) != 0;
154+
return (InfoTable[c] &
155+
(CHAR_UNDER | CHAR_PERIOD | CHAR_PUNCT | CHAR_PUNCT)) != 0;
156156
}
157157

158158
/// Return true if this character is an ASCII printable character; that is, a
159159
/// character that should take exactly one column to print in a fixed-width
160160
/// terminal.
161161
LLVM_READONLY inline bool isPrintable(unsigned char c) {
162162
using namespace charinfo;
163-
return (InfoTable[c] & (CHAR_UPPER|CHAR_LOWER|CHAR_PERIOD|CHAR_PUNCT|
164-
CHAR_DIGIT|CHAR_UNDER|CHAR_RAWDEL|CHAR_SPACE)) != 0;
163+
return (InfoTable[c] & (CHAR_UPPER | CHAR_LOWER | CHAR_PERIOD | CHAR_PUNCT |
164+
CHAR_DIGIT | CHAR_UNDER | CHAR_SPACE)) != 0;
165165
}
166166

167167
/// Return true if this is the body character of a C preprocessing number,
@@ -175,8 +175,9 @@ LLVM_READONLY inline bool isPreprocessingNumberBody(unsigned char c) {
175175
/// Return true if this is the body character of a C++ raw string delimiter.
176176
LLVM_READONLY inline bool isRawStringDelimBody(unsigned char c) {
177177
using namespace charinfo;
178-
return (InfoTable[c] & (CHAR_UPPER|CHAR_LOWER|CHAR_PERIOD|
179-
CHAR_DIGIT|CHAR_UNDER|CHAR_RAWDEL)) != 0;
178+
return (InfoTable[c] & (CHAR_UPPER | CHAR_LOWER | CHAR_PERIOD | CHAR_DIGIT |
179+
CHAR_UNDER | CHAR_PUNCT)) != 0 &&
180+
c != '(' && c != ')';
180181
}
181182

182183
enum class EscapeChar {

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ def err_drv_invalid_diagnotics_misexpect_tolerance : Error<
193193
def err_drv_missing_argument : Error<
194194
"argument to '%0' is missing (expected %1 value%s1)">;
195195
def err_drv_missing_Xopenmptarget_or_march: Error<
196-
"The option -fopenmp-targets= requires additional options -Xopenmp-target= and -march= .">,
196+
"option -fopenmp-targets= requires additional options -Xopenmp-target= and -march=">,
197197
DefaultFatal;
198198
def warn_drv_missing_flang_exec : Warning<
199-
"%0 not found, 'openmp-extras' package from ROCm may be missing.">,
199+
"%0 not found, 'openmp-extras' package from ROCm may be missing">,
200200
InGroup<InvalidCommandLineArgument>;
201201
def err_drv_invalid_Xarch_argument_with_args : Error<
202202
"invalid Xarch argument: '%0', options requiring arguments are unsupported">;
@@ -662,7 +662,7 @@ def warn_drv_global_isel_incomplete_opt : Warning<
662662
InGroup<GlobalISel>;
663663

664664
def warn_drv_amd_opt_not_found : Warning<
665-
"The [AMD] proprietary optimization compiler installation was not found">,
665+
"[AMD] proprietary optimization compiler installation was not found">,
666666
InGroup<UnusedCommandLineArgument>;
667667

668668
def warn_drv_moutline_unsupported_opt : Warning<

clang/include/clang/Basic/DiagnosticLexKinds.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ def warn_cxx98_compat_raw_string_literal : Warning<
111111
"raw string literals are incompatible with C++98">,
112112
InGroup<CXX98Compat>, DefaultIgnore;
113113

114+
def warn_cxx26_compat_raw_string_literal_character_set : Warning<
115+
" '%0' in a raw string literal delimiter is incompatible "
116+
"with standards before C++2c">,
117+
InGroup<CXXPre26Compat>, DefaultIgnore;
118+
def ext_cxx26_raw_string_literal_character_set : Extension<
119+
" '%0' in a raw string literal delimiter is a C++2c extension">,
120+
InGroup<CXX26>, DefaultIgnore;
121+
114122
def warn_multichar_character_literal : Warning<
115123
"multi-character character constant">, InGroup<MultiChar>;
116124
def warn_four_char_character_literal : Warning<

clang/include/clang/Interpreter/Interpreter.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ class Interpreter {
110110
RuntimeInterfaceBuilder::TransformExprFunction *AddPrintValueCall = nullptr;
111111

112112
protected:
113-
// Derived classes can make use an extended interface of the Interpreter.
114-
// That's useful for testing and out-of-tree clients.
115-
Interpreter(std::unique_ptr<CompilerInstance> CI, llvm::Error &Err);
113+
// Derived classes can use an extended interface of the Interpreter.
114+
Interpreter(std::unique_ptr<CompilerInstance> CI, llvm::Error &Err,
115+
std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder = nullptr);
116116

117117
// Create the internal IncrementalExecutor, or re-create it after calling
118118
// ResetExecutor().
@@ -128,13 +128,6 @@ class Interpreter {
128128
// custom runtime.
129129
virtual std::unique_ptr<RuntimeInterfaceBuilder> FindRuntimeInterface();
130130

131-
// Lazily construct thev ORCv2 JITBuilder. This called when the internal
132-
// IncrementalExecutor is created. The default implementation populates an
133-
// in-process JIT with debugging support. Override this to configure the JIT
134-
// engine used for execution.
135-
virtual llvm::Expected<std::unique_ptr<llvm::orc::LLJITBuilder>>
136-
CreateJITBuilder(CompilerInstance &CI);
137-
138131
public:
139132
virtual ~Interpreter();
140133

@@ -189,6 +182,8 @@ class Interpreter {
189182
llvm::DenseMap<CXXRecordDecl *, llvm::orc::ExecutorAddr> Dtors;
190183

191184
llvm::SmallVector<Expr *, 4> ValuePrintingInfo;
185+
186+
std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder;
192187
};
193188
} // namespace clang
194189

clang/lib/AST/APValue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ QualType APValue::LValueBase::getType() const {
9090
// For a materialized temporary, the type of the temporary we materialized
9191
// may not be the type of the expression.
9292
if (const MaterializeTemporaryExpr *MTE =
93-
clang::dyn_cast<MaterializeTemporaryExpr>(Base)) {
93+
llvm::dyn_cast<MaterializeTemporaryExpr>(Base)) {
9494
SmallVector<const Expr *, 2> CommaLHSs;
9595
SmallVector<SubobjectAdjustment, 2> Adjustments;
9696
const Expr *Temp = MTE->getSubExpr();

clang/lib/AST/Interp/ByteCodeStmtGen.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -687,26 +687,29 @@ bool ByteCodeStmtGen<Emitter>::visitDefaultStmt(const DefaultStmt *S) {
687687
template <class Emitter>
688688
bool ByteCodeStmtGen<Emitter>::visitAttributedStmt(const AttributedStmt *S) {
689689

690-
for (const Attr *A : S->getAttrs()) {
691-
auto *AA = dyn_cast<CXXAssumeAttr>(A);
692-
if (!AA)
693-
continue;
690+
if (this->Ctx.getLangOpts().CXXAssumptions &&
691+
!this->Ctx.getLangOpts().MSVCCompat) {
692+
for (const Attr *A : S->getAttrs()) {
693+
auto *AA = dyn_cast<CXXAssumeAttr>(A);
694+
if (!AA)
695+
continue;
694696

695-
assert(isa<NullStmt>(S->getSubStmt()));
697+
assert(isa<NullStmt>(S->getSubStmt()));
696698

697-
const Expr *Assumption = AA->getAssumption();
698-
if (Assumption->isValueDependent())
699-
return false;
699+
const Expr *Assumption = AA->getAssumption();
700+
if (Assumption->isValueDependent())
701+
return false;
700702

701-
if (Assumption->HasSideEffects(this->Ctx.getASTContext()))
702-
continue;
703+
if (Assumption->HasSideEffects(this->Ctx.getASTContext()))
704+
continue;
703705

704-
// Evaluate assumption.
705-
if (!this->visitBool(Assumption))
706-
return false;
706+
// Evaluate assumption.
707+
if (!this->visitBool(Assumption))
708+
return false;
707709

708-
if (!this->emitAssume(Assumption))
709-
return false;
710+
if (!this->emitAssume(Assumption))
711+
return false;
712+
}
710713
}
711714

712715
// Ignore other attributes.

clang/lib/Analysis/MacroExpansionContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#define DEBUG_TYPE "macro-expansion-context"
1414

15-
static void dumpTokenInto(const clang::Preprocessor &PP, clang::raw_ostream &OS,
15+
static void dumpTokenInto(const clang::Preprocessor &PP, llvm::raw_ostream &OS,
1616
clang::Token Tok);
1717

1818
namespace clang {

clang/lib/Basic/CharInfo.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ const uint16_t clang::charinfo::InfoTable[256] = {
3131
0 , 0 , 0 , 0 ,
3232
//32 SP 33 ! 34 " 35 #
3333
//36 $ 37 % 38 & 39 '
34-
CHAR_SPACE , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL ,
35-
CHAR_PUNCT , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL ,
34+
CHAR_SPACE , CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT ,
35+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT ,
3636
//40 ( 41 ) 42 * 43 +
3737
//44 , 45 - 46 . 47 /
38-
CHAR_PUNCT , CHAR_PUNCT , CHAR_RAWDEL , CHAR_RAWDEL ,
39-
CHAR_RAWDEL , CHAR_RAWDEL , CHAR_PERIOD , CHAR_RAWDEL ,
38+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT ,
39+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PERIOD , CHAR_PUNCT ,
4040
//48 0 49 1 50 2 51 3
4141
//52 4 53 5 54 6 55 7
4242
CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT ,
4343
CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT , CHAR_DIGIT ,
4444
//56 8 57 9 58 : 59 ;
4545
//60 < 61 = 62 > 63 ?
46-
CHAR_DIGIT , CHAR_DIGIT , CHAR_RAWDEL , CHAR_RAWDEL ,
47-
CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL ,
46+
CHAR_DIGIT , CHAR_DIGIT , CHAR_PUNCT , CHAR_PUNCT ,
47+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT ,
4848
//64 @ 65 A 66 B 67 C
4949
//68 D 69 E 70 F 71 G
5050
CHAR_PUNCT , CHAR_XUPPER , CHAR_XUPPER , CHAR_XUPPER ,
@@ -59,8 +59,8 @@ const uint16_t clang::charinfo::InfoTable[256] = {
5959
CHAR_UPPER , CHAR_UPPER , CHAR_UPPER , CHAR_UPPER ,
6060
//88 X 89 Y 90 Z 91 [
6161
//92 \ 93 ] 94 ^ 95 _
62-
CHAR_UPPER , CHAR_UPPER , CHAR_UPPER , CHAR_RAWDEL ,
63-
CHAR_PUNCT , CHAR_RAWDEL , CHAR_RAWDEL , CHAR_UNDER ,
62+
CHAR_UPPER , CHAR_UPPER , CHAR_UPPER , CHAR_PUNCT ,
63+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT , CHAR_UNDER ,
6464
//96 ` 97 a 98 b 99 c
6565
//100 d 101 e 102 f 103 g
6666
CHAR_PUNCT , CHAR_XLOWER , CHAR_XLOWER , CHAR_XLOWER ,
@@ -75,6 +75,6 @@ const uint16_t clang::charinfo::InfoTable[256] = {
7575
CHAR_LOWER , CHAR_LOWER , CHAR_LOWER , CHAR_LOWER ,
7676
//120 x 121 y 122 z 123 {
7777
//124 | 125 } 126 ~ 127 DEL
78-
CHAR_LOWER , CHAR_LOWER , CHAR_LOWER , CHAR_RAWDEL ,
79-
CHAR_RAWDEL , CHAR_RAWDEL , CHAR_RAWDEL , 0
78+
CHAR_LOWER , CHAR_LOWER , CHAR_LOWER , CHAR_PUNCT ,
79+
CHAR_PUNCT , CHAR_PUNCT , CHAR_PUNCT , 0
8080
};

clang/lib/Interpreter/Interpreter.cpp

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,32 @@ IncrementalCompilerBuilder::CreateCudaHost() {
229229
}
230230

231231
Interpreter::Interpreter(std::unique_ptr<CompilerInstance> CI,
232-
llvm::Error &Err) {
233-
llvm::ErrorAsOutParameter EAO(&Err);
232+
llvm::Error &ErrOut,
233+
std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder)
234+
: JITBuilder(std::move(JITBuilder)) {
235+
llvm::ErrorAsOutParameter EAO(&ErrOut);
234236
auto LLVMCtx = std::make_unique<llvm::LLVMContext>();
235237
TSCtx = std::make_unique<llvm::orc::ThreadSafeContext>(std::move(LLVMCtx));
236-
IncrParser = std::make_unique<IncrementalParser>(*this, std::move(CI),
237-
*TSCtx->getContext(), Err);
238+
IncrParser = std::make_unique<IncrementalParser>(
239+
*this, std::move(CI), *TSCtx->getContext(), ErrOut);
240+
if (ErrOut)
241+
return;
242+
243+
// Not all frontends support code-generation, e.g. ast-dump actions don't
244+
if (IncrParser->getCodeGen()) {
245+
if (llvm::Error Err = CreateExecutor()) {
246+
ErrOut = joinErrors(std::move(ErrOut), std::move(Err));
247+
return;
248+
}
249+
250+
// Process the PTUs that came from initialization. For example -include will
251+
// give us a header that's processed at initialization of the preprocessor.
252+
for (PartialTranslationUnit &PTU : IncrParser->getPTUs())
253+
if (llvm::Error Err = Execute(PTU)) {
254+
ErrOut = joinErrors(std::move(ErrOut), std::move(Err));
255+
return;
256+
}
257+
}
238258
}
239259

240260
Interpreter::~Interpreter() {
@@ -382,25 +402,29 @@ createJITTargetMachineBuilder(const std::string &TT) {
382402
return llvm::orc::JITTargetMachineBuilder(llvm::Triple(TT));
383403
}
384404

385-
llvm::Expected<std::unique_ptr<llvm::orc::LLJITBuilder>>
386-
Interpreter::CreateJITBuilder(CompilerInstance &CI) {
387-
auto JTMB = createJITTargetMachineBuilder(CI.getTargetOpts().Triple);
388-
if (!JTMB)
389-
return JTMB.takeError();
390-
return IncrementalExecutor::createDefaultJITBuilder(std::move(*JTMB));
391-
}
392-
393405
llvm::Error Interpreter::CreateExecutor() {
394406
if (IncrExecutor)
395407
return llvm::make_error<llvm::StringError>("Operation failed. "
396408
"Execution engine exists",
397409
std::error_code());
398-
llvm::Expected<std::unique_ptr<llvm::orc::LLJITBuilder>> JB =
399-
CreateJITBuilder(*getCompilerInstance());
400-
if (!JB)
401-
return JB.takeError();
410+
if (!IncrParser->getCodeGen())
411+
return llvm::make_error<llvm::StringError>("Operation failed. "
412+
"No code generator available",
413+
std::error_code());
414+
if (!JITBuilder) {
415+
const std::string &TT = getCompilerInstance()->getTargetOpts().Triple;
416+
auto JTMB = createJITTargetMachineBuilder(TT);
417+
if (!JTMB)
418+
return JTMB.takeError();
419+
auto JB = IncrementalExecutor::createDefaultJITBuilder(std::move(*JTMB));
420+
if (!JB)
421+
return JB.takeError();
422+
JITBuilder = std::move(*JB);
423+
}
424+
402425
llvm::Error Err = llvm::Error::success();
403-
auto Executor = std::make_unique<IncrementalExecutor>(*TSCtx, **JB, Err);
426+
auto Executor =
427+
std::make_unique<IncrementalExecutor>(*TSCtx, *JITBuilder, Err);
404428
if (!Err)
405429
IncrExecutor = std::move(Executor);
406430

0 commit comments

Comments
 (0)