Skip to content

Commit 173de22

Browse files
committed
merge main into amd-staging
2 parents 14e860c + 41f1663 commit 173de22

File tree

226 files changed

+5561
-1020
lines changed

Some content is hidden

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

226 files changed

+5561
-1020
lines changed

bolt/docs/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ if (LLVM_ENABLE_DOXYGEN)
4848
set(bolt_doxygen_qhp_cust_filter_attrs "")
4949
endif()
5050

51-
option(LLVM_DOXYGEN_SVG
52-
"Use svg instead of png files for doxygen graphs." OFF)
53-
if (LLVM_DOXYGEN_SVG)
54-
set(DOT_IMAGE_FORMAT "svg")
55-
else()
56-
set(DOT_IMAGE_FORMAT "png")
57-
endif()
58-
5951
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen.cfg.in
6052
${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg @ONLY)
6153

@@ -73,7 +65,6 @@ if (LLVM_ENABLE_DOXYGEN)
7365
set(bolt_doxygen_qhelpgenerator_path)
7466
set(bolt_doxygen_qhp_cust_filter_name)
7567
set(bolt_doxygen_qhp_cust_filter_attrs)
76-
set(DOT_IMAGE_FORMAT)
7768

7869
add_custom_target(doxygen-bolt
7970
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg

bolt/docs/doxygen.cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,7 @@ DIRECTORY_GRAPH = YES
22102210
# The default value is: png.
22112211
# This tag requires that the tag HAVE_DOT is set to YES.
22122212

2213-
DOT_IMAGE_FORMAT = @DOT_IMAGE_FORMAT@
2213+
DOT_IMAGE_FORMAT = svg
22142214

22152215
# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
22162216
# enable generation of interactive SVG images that allow zooming and panning.

clang-tools-extra/docs/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ if (DOXYGEN_FOUND)
4646
set(clang_tools_doxygen_qhp_cust_filter_attrs "")
4747
endif()
4848

49-
option(LLVM_DOXYGEN_SVG
50-
"Use svg instead of png files for doxygen graphs." OFF)
51-
if (LLVM_DOXYGEN_SVG)
52-
set(DOT_IMAGE_FORMAT "svg")
53-
else()
54-
set(DOT_IMAGE_FORMAT "png")
55-
endif()
56-
5749
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen.cfg.in
5850
${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg @ONLY)
5951

@@ -71,7 +63,6 @@ if (DOXYGEN_FOUND)
7163
set(clang_tools_doxygen_qhelpgenerator_path)
7264
set(clang_tools_doxygen_qhp_cust_filter_name)
7365
set(clang_tools_doxygen_qhp_cust_filter_attrs)
74-
set(DOT_IMAGE_FORMAT)
7566

7667
add_custom_target(doxygen-clang-tools
7768
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg

clang-tools-extra/docs/doxygen.cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,7 @@ DIRECTORY_GRAPH = YES
22052205
# The default value is: png.
22062206
# This tag requires that the tag HAVE_DOT is set to YES.
22072207

2208-
DOT_IMAGE_FORMAT = @DOT_IMAGE_FORMAT@
2208+
DOT_IMAGE_FORMAT = svg
22092209

22102210
# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
22112211
# enable generation of interactive SVG images that allow zooming and panning.

clang/docs/CMakeLists.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ if (LLVM_ENABLE_DOXYGEN)
4747
set(clang_doxygen_qhp_cust_filter_attrs "")
4848
endif()
4949

50-
option(LLVM_DOXYGEN_SVG
51-
"Use svg instead of png files for doxygen graphs." OFF)
52-
if (LLVM_DOXYGEN_SVG)
53-
set(DOT_IMAGE_FORMAT "svg")
54-
else()
55-
set(DOT_IMAGE_FORMAT "png")
56-
endif()
57-
5850
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxygen.cfg.in
5951
${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg @ONLY)
6052

@@ -72,7 +64,6 @@ if (LLVM_ENABLE_DOXYGEN)
7264
set(clang_doxygen_qhelpgenerator_path)
7365
set(clang_doxygen_qhp_cust_filter_name)
7466
set(clang_doxygen_qhp_cust_filter_attrs)
75-
set(DOT_IMAGE_FORMAT)
7667

7768
add_custom_target(doxygen-clang
7869
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg

clang/docs/CommandGuide/clang.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,8 @@ Code Generation Options
443443
:option:`-Oz` Like :option:`-Os` (and thus :option:`-O2`), but reduces code
444444
size further.
445445

446-
:option:`-Og` Similar to :option:`-O1`, but with slightly reduced
447-
optimization and better variable visibility. The same optimizations are run
448-
as at :option:`-O1`, but the ``-fextend-variable-liveness`` flag is
449-
also set, which tries to prevent optimizations from reducing the liveness of
450-
user variables, improving their availability when debugging.
446+
:option:`-Og` Like :option:`-O1`. In future versions, this option might
447+
disable different optimizations in order to improve debuggability.
451448

452449
:option:`-O` Equivalent to :option:`-O1`.
453450

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ C Language Changes
140140
- Clang now allows an ``inline`` specifier on a typedef declaration of a
141141
function type in Microsoft compatibility mode. #GH124869
142142
- Clang now allows ``restrict`` qualifier for array types with pointer elements (#GH92847).
143+
- Clang now diagnoses ``const``-qualified object definitions without an
144+
initializer. If the object is zero-initialized, it will be diagnosed under
145+
the new warning ``-Wdefault-const-init`` (which is grouped under
146+
``-Wc++-compat`` because this construct is not compatible with C++). If the
147+
object is left uninitialized, it will be diagnosed unsed the new warning
148+
``-Wdefault-const-init-unsafe`` (which is grouped under
149+
``-Wdefault-const-init``). #GH19297
143150
- Added ``-Wimplicit-void-ptr-cast``, grouped under ``-Wc++-compat``, which
144151
diagnoses implicit conversion from ``void *`` to another pointer type as
145152
being incompatible with C++. (#GH17792)
@@ -230,10 +237,6 @@ Modified Compiler Flags
230237

231238
- The ``-mexecute-only`` and ``-mpure-code`` flags are now accepted for AArch64 targets. (#GH125688)
232239

233-
- The ``-Og`` optimization flag now sets ``-fextend-variable-liveness``,
234-
reducing performance slightly while reducing the number of optimized-out
235-
variables.
236-
237240
Removed Compiler Flags
238241
-------------------------
239242

clang/docs/doxygen.cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2193,7 +2193,7 @@ DIRECTORY_GRAPH = YES
21932193
# The default value is: png.
21942194
# This tag requires that the tag HAVE_DOT is set to YES.
21952195

2196-
DOT_IMAGE_FORMAT = @DOT_IMAGE_FORMAT@
2196+
DOT_IMAGE_FORMAT = svg
21972197

21982198
# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
21992199
# enable generation of interactive SVG images that allow zooming and panning.

clang/include/clang/Analysis/CFG.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ class CFGElement {
122122
return (Kind) x;
123123
}
124124

125-
void dumpToStream(llvm::raw_ostream &OS,
126-
bool TerminateWithNewLine = true) const;
125+
void dumpToStream(llvm::raw_ostream &OS) const;
127126

128127
void dump() const {
129128
dumpToStream(llvm::errs());
@@ -696,11 +695,6 @@ class CFGBlock {
696695
void dump() const {
697696
dumpToStream(llvm::errs());
698697
}
699-
700-
void Profile(llvm::FoldingSetNodeID &ID) const {
701-
ID.AddPointer(Parent);
702-
ID.AddInteger(Index);
703-
}
704698
};
705699

706700
template <bool IsReverse, bool IsConst> class ElementRefIterator {
@@ -1196,8 +1190,6 @@ class CFGBlock {
11961190
}
11971191
};
11981192

1199-
using ConstCFGElementRef = CFGBlock::ConstCFGElementRef;
1200-
12011193
/// CFGCallback defines methods that should be called when a logical
12021194
/// operator error is found when building the CFG.
12031195
class CFGCallback {

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ def BuiltinRequiresHeader : DiagGroup<"builtin-requires-header">;
154154
def C99Compat : DiagGroup<"c99-compat">;
155155
def C23Compat : DiagGroup<"c23-compat">;
156156
def : DiagGroup<"c2x-compat", [C23Compat]>;
157-
157+
def DefaultConstInitUnsafe : DiagGroup<"default-const-init-unsafe">;
158+
def DefaultConstInit : DiagGroup<"default-const-init", [DefaultConstInitUnsafe]>;
158159
def ImplicitVoidPtrCast : DiagGroup<"implicit-void-ptr-cast">;
159-
def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast]>;
160+
def CXXCompat: DiagGroup<"c++-compat", [ImplicitVoidPtrCast, DefaultConstInit]>;
161+
160162
def ExternCCompat : DiagGroup<"extern-c-compat">;
161163
def KeywordCompat : DiagGroup<"keyword-compat">;
162164
def GNUCaseRange : DiagGroup<"gnu-case-range">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8197,6 +8197,16 @@ def err_address_space_qualified_new : Error<
81978197
def err_address_space_qualified_delete : Error<
81988198
"'delete' cannot delete objects of type %0 in address space '%1'">;
81998199

8200+
def note_default_init_const_member : Note<
8201+
"member %0 declared 'const' here">;
8202+
def warn_default_init_const : Warning<
8203+
"default initialization of an object of type %0%select{| with const member}1 "
8204+
"is incompatible with C++">,
8205+
InGroup<DefaultConstInit>, DefaultIgnore;
8206+
def warn_default_init_const_unsafe : Warning<
8207+
"default initialization of an object of type %0%select{| with const member}1 "
8208+
"leaves the object uninitialized and is incompatible with C++">,
8209+
InGroup<DefaultConstInitUnsafe>;
82008210
def err_default_init_const : Error<
82018211
"default initialization of an object of const type %0"
82028212
"%select{| without a user-provided default constructor}1">;

clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "clang/AST/DeclCXX.h"
2020
#include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
2121
#include "llvm/ADT/StringExtras.h"
22-
#include "llvm/Support/raw_ostream.h"
2322

2423
namespace clang {
2524

@@ -30,13 +29,6 @@ class SValExplainer : public FullSValVisitor<SValExplainer, std::string> {
3029
ASTContext &ACtx;
3130
ProgramStateRef State;
3231

33-
std::string printCFGElementRef(ConstCFGElementRef Elem) {
34-
std::string Str;
35-
llvm::raw_string_ostream OS(Str);
36-
Elem->dumpToStream(OS, /*TerminateWithNewLine=*/false);
37-
return Str;
38-
}
39-
4032
std::string printStmt(const Stmt *S) {
4133
std::string Str;
4234
llvm::raw_string_ostream OS(Str);
@@ -122,8 +114,7 @@ class SValExplainer : public FullSValVisitor<SValExplainer, std::string> {
122114

123115
std::string VisitSymbolConjured(const SymbolConjured *S) {
124116
return "symbol of type '" + S->getType().getAsString() +
125-
"' conjured at CFG element '" +
126-
printCFGElementRef(S->getCFGElementRef()) + "'";
117+
"' conjured at statement '" + printStmt(S->getStmt()) + "'";
127118
}
128119

129120
std::string VisitSymbolDerived(const SymbolDerived *S) {

clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ class CheckerContext {
151151
return Pred->getSVal(S);
152152
}
153153

154-
ConstCFGElementRef getCFGElementRef() const { return Eng.getCFGElementRef(); }
155-
156154
/// Returns true if the value of \p E is greater than or equal to \p
157155
/// Val under unsigned comparison.
158156
bool isGreaterOrEqual(const Expr *E, unsigned long long Val);

clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class ExprEngine {
226226
return (*G.roots_begin())->getLocation().getLocationContext();
227227
}
228228

229-
ConstCFGElementRef getCFGElementRef() const {
229+
CFGBlock::ConstCFGElementRef getCFGElementRef() const {
230230
const CFGBlock *blockPtr = currBldrCtx ? currBldrCtx->getBlock() : nullptr;
231231
return {blockPtr, currStmtIdx};
232232
}

clang/include/clang/StaticAnalyzer/Core/PathSensitive/LoopWidening.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ namespace ento {
2727
/// by the loop body in any iteration.
2828
ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState,
2929
const LocationContext *LCtx,
30-
unsigned BlockCount,
31-
ConstCFGElementRef Elem);
30+
unsigned BlockCount, const Stmt *LoopStmt);
3231

3332
} // end namespace ento
3433
} // end namespace clang

clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class ProgramState : public llvm::FoldingSetNode {
313313
/// be triggered by this event.
314314
///
315315
/// \param Regions the set of regions to be invalidated.
316-
/// \param Elem The CFG Element that caused the invalidation.
316+
/// \param E the expression that caused the invalidation.
317317
/// \param BlockCount The number of times the current basic block has been
318318
/// visited.
319319
/// \param CausesPointerEscape the flag is set to true when the invalidation
@@ -325,17 +325,16 @@ class ProgramState : public llvm::FoldingSetNode {
325325
/// \param ITraits information about special handling for particular regions
326326
/// or symbols.
327327
[[nodiscard]] ProgramStateRef
328-
invalidateRegions(ArrayRef<const MemRegion *> Regions,
329-
ConstCFGElementRef Elem, unsigned BlockCount,
330-
const LocationContext *LCtx, bool CausesPointerEscape,
331-
InvalidatedSymbols *IS = nullptr,
328+
invalidateRegions(ArrayRef<const MemRegion *> Regions, const Stmt *S,
329+
unsigned BlockCount, const LocationContext *LCtx,
330+
bool CausesPointerEscape, InvalidatedSymbols *IS = nullptr,
332331
const CallEvent *Call = nullptr,
333332
RegionAndSymbolInvalidationTraits *ITraits = nullptr) const;
334333

335334
[[nodiscard]] ProgramStateRef
336-
invalidateRegions(ArrayRef<SVal> Values, ConstCFGElementRef Elem,
337-
unsigned BlockCount, const LocationContext *LCtx,
338-
bool CausesPointerEscape, InvalidatedSymbols *IS = nullptr,
335+
invalidateRegions(ArrayRef<SVal> Values, const Stmt *S, unsigned BlockCount,
336+
const LocationContext *LCtx, bool CausesPointerEscape,
337+
InvalidatedSymbols *IS = nullptr,
339338
const CallEvent *Call = nullptr,
340339
RegionAndSymbolInvalidationTraits *ITraits = nullptr) const;
341340

clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "clang/AST/Expr.h"
2020
#include "clang/AST/ExprObjC.h"
2121
#include "clang/AST/Type.h"
22-
#include "clang/Analysis/CFG.h"
2322
#include "clang/Basic/LLVM.h"
2423
#include "clang/Basic/LangOptions.h"
2524
#include "clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h"
@@ -47,10 +46,10 @@ class Stmt;
4746

4847
namespace ento {
4948

49+
class CallEvent;
5050
class ConditionTruthVal;
5151
class ProgramStateManager;
5252
class StoreRef;
53-
5453
class SValBuilder {
5554
virtual void anchor();
5655

@@ -172,11 +171,19 @@ class SValBuilder {
172171

173172
// Forwarding methods to SymbolManager.
174173

175-
const SymbolConjured *conjureSymbol(ConstCFGElementRef Elem,
174+
const SymbolConjured* conjureSymbol(const Stmt *stmt,
175+
const LocationContext *LCtx,
176+
QualType type,
177+
unsigned visitCount,
178+
const void *symbolTag = nullptr) {
179+
return SymMgr.conjureSymbol(stmt, LCtx, type, visitCount, symbolTag);
180+
}
181+
182+
const SymbolConjured* conjureSymbol(const Expr *expr,
176183
const LocationContext *LCtx,
177-
QualType type, unsigned visitCount,
184+
unsigned visitCount,
178185
const void *symbolTag = nullptr) {
179-
return SymMgr.conjureSymbol(Elem, LCtx, type, visitCount, symbolTag);
186+
return SymMgr.conjureSymbol(expr, LCtx, visitCount, symbolTag);
180187
}
181188

182189
/// Construct an SVal representing '0' for the specified type.
@@ -192,19 +199,35 @@ class SValBuilder {
192199
/// preserve the relation between related(or even equivalent) expressions, so
193200
/// conjured symbols should be used sparingly.
194201
DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag,
195-
ConstCFGElementRef elem,
202+
const Expr *expr,
196203
const LocationContext *LCtx,
197204
unsigned count);
198-
DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag,
199-
ConstCFGElementRef elem,
205+
DefinedOrUnknownSVal conjureSymbolVal(const void *symbolTag, const Stmt *S,
200206
const LocationContext *LCtx,
201207
QualType type, unsigned count);
202-
DefinedOrUnknownSVal conjureSymbolVal(ConstCFGElementRef elem,
208+
DefinedOrUnknownSVal conjureSymbolVal(const Stmt *stmt,
203209
const LocationContext *LCtx,
204-
QualType type, unsigned visitCount);
210+
QualType type,
211+
unsigned visitCount);
212+
DefinedOrUnknownSVal conjureSymbolVal(const CallEvent &call, QualType type,
213+
unsigned visitCount,
214+
const void *symbolTag = nullptr);
215+
DefinedOrUnknownSVal conjureSymbolVal(const CallEvent &call,
216+
unsigned visitCount,
217+
const void *symbolTag = nullptr);
205218

206219
/// Conjure a symbol representing heap allocated memory region.
207-
DefinedSVal getConjuredHeapSymbolVal(ConstCFGElementRef elem,
220+
///
221+
/// Note, the expression should represent a location.
222+
DefinedSVal getConjuredHeapSymbolVal(const Expr *E,
223+
const LocationContext *LCtx,
224+
unsigned Count);
225+
226+
/// Conjure a symbol representing heap allocated memory region.
227+
///
228+
/// Note, now, the expression *doesn't* need to represent a location.
229+
/// But the type need to!
230+
DefinedSVal getConjuredHeapSymbolVal(const Expr *E,
208231
const LocationContext *LCtx,
209232
QualType type, unsigned Count);
210233

0 commit comments

Comments
 (0)