Skip to content

Commit cec0ba4

Browse files
committed
Merge remote-tracking branch 'llvm/master' into xyb/merge-llvm-master
2 parents e8e1738 + 635d383 commit cec0ba4

File tree

1,051 files changed

+14374
-8264
lines changed

Some content is hidden

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

1,051 files changed

+14374
-8264
lines changed

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
#include "clang/Rewrite/Frontend/FixItRewriter.h"
3737
#include "clang/Rewrite/Frontend/FrontendActions.h"
3838
#include "clang/Tooling/Core/Diagnostic.h"
39-
#if CLANG_ENABLE_STATIC_ANALYZER
40-
#include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
41-
#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
42-
#endif // CLANG_ENABLE_STATIC_ANALYZER
4339
#include "clang/Tooling/DiagnosticsYaml.h"
4440
#include "clang/Tooling/Refactoring.h"
4541
#include "clang/Tooling/ReplacementsYaml.h"
@@ -49,6 +45,11 @@
4945
#include <algorithm>
5046
#include <utility>
5147

48+
#if CLANG_ENABLE_STATIC_ANALYZER
49+
#include "clang/Analysis/PathDiagnostic.h"
50+
#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
51+
#endif // CLANG_ENABLE_STATIC_ANALYZER
52+
5253
using namespace clang::ast_matchers;
5354
using namespace clang::driver;
5455
using namespace clang::tooling;

clang/docs/OpenMPSupport.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ implementation.
149149
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
150150
| loop extension | collapse imperfectly nested loop | :none:`unclaimed` | |
151151
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
152-
| loop extension | collapse non-rectangular nested loop | :part:`worked on` | |
152+
| loop extension | collapse non-rectangular nested loop | :good:`done` | |
153153
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
154154
| loop extension | C++ range-base for loop | :none:`unclaimed` | |
155155
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
@@ -233,7 +233,7 @@ implementation.
233233
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
234234
| device extension | map(replicate) or map(local) when requires unified_shared_me | :part:`worked on` | D55719,D55892 |
235235
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
236-
| device extension | teams construct on the host device | :part:`worked on` | |
236+
| device extension | teams construct on the host device | :part:`worked on` | Clang part is done, r371553. |
237237
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
238238
| atomic extension | hints for the atomic construct | :part:`worked on` | D51233 |
239239
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
@@ -251,7 +251,7 @@ implementation.
251251
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
252252
| misc extension | conditional modifier for lastprivate clause | :none:`unclaimed` | |
253253
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
254-
| misc extension | user-defined function variants | :none:`unclaimed` | |
254+
| misc extension | user-defined function variants | :part:`worked on` | D67294, D64095 |
255255
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
256256
| misc extensions | pointer/reference to pointer based array reductions | :none:`unclaimed` | |
257257
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ Improvements to Clang's diagnostics
5656
Non-comprehensive list of changes in this release
5757
-------------------------------------------------
5858

59-
- ...
60-
59+
- For X86 target, -march=skylake-avx512, -march=icelake-client,
60+
-march=icelake-server, -march=cascadelake, -march=cooperlake will default to
61+
not using 512-bit zmm registers in vectorized code unless 512-bit intrinsics
62+
are used in the source code. 512-bit operations are known to cause the CPUs
63+
to run at a lower frequency which can impact performance. This behavior can be
64+
changed by passing -mprefer-vector-width=512 on the command line.
6165

6266
New Compiler Flags
6367
------------------
Lines changed: 23 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ class SourceManager;
5252

5353
namespace ento {
5454

55-
class ExplodedNode;
56-
class SymExpr;
57-
58-
using SymbolRef = const SymExpr *;
59-
6055
//===----------------------------------------------------------------------===//
6156
// High-level interface for handlers of path-sensitive diagnostics.
6257
//===----------------------------------------------------------------------===//
@@ -276,18 +271,21 @@ class PathDiagnosticLocation {
276271
static PathDiagnosticLocation createDeclEnd(const LocationContext *LC,
277272
const SourceManager &SM);
278273

279-
/// Create a location corresponding to the given valid ExplodedNode.
274+
/// Create a location corresponding to the given valid ProgramPoint.
280275
static PathDiagnosticLocation create(const ProgramPoint &P,
281276
const SourceManager &SMng);
282277

283-
/// Create a location corresponding to the next valid ExplodedNode as end
284-
/// of path location.
285-
static PathDiagnosticLocation createEndOfPath(const ExplodedNode* N);
286-
287278
/// Convert the given location into a single kind location.
288279
static PathDiagnosticLocation createSingleLocation(
289280
const PathDiagnosticLocation &PDL);
290281

282+
/// Construct a source location that corresponds to either the beginning
283+
/// or the end of the given statement, or a nearby valid source location
284+
/// if the statement does not have a valid source location of its own.
285+
static SourceLocation
286+
getValidSourceLocation(const Stmt *S, LocationOrAnalysisDeclContext LAC,
287+
bool UseEndOfStatement = false);
288+
291289
bool operator==(const PathDiagnosticLocation &X) const {
292290
return K == X.K && Loc == X.Loc && Range == X.Range;
293291
}
@@ -332,13 +330,6 @@ class PathDiagnosticLocation {
332330
void Profile(llvm::FoldingSetNodeID &ID) const;
333331

334332
void dump() const;
335-
336-
/// Given an exploded node, retrieve the statement that should be used
337-
/// for the diagnostic location.
338-
static const Stmt *getStmt(const ExplodedNode *N);
339-
340-
/// Retrieve the statement corresponding to the successor node.
341-
static const Stmt *getNextStmt(const ExplodedNode *N);
342333
};
343334

344335
class PathDiagnosticLocationPair {
@@ -502,65 +493,13 @@ class PathDiagnosticSpotPiece : public PathDiagnosticPiece {
502493
}
503494
};
504495

505-
/// Interface for classes constructing Stack hints.
506-
///
507-
/// If a PathDiagnosticEvent occurs in a different frame than the final
508-
/// diagnostic the hints can be used to summarize the effect of the call.
509-
class StackHintGenerator {
510-
public:
511-
virtual ~StackHintGenerator() = 0;
512-
513-
/// Construct the Diagnostic message for the given ExplodedNode.
514-
virtual std::string getMessage(const ExplodedNode *N) = 0;
515-
};
516-
517-
/// Constructs a Stack hint for the given symbol.
518-
///
519-
/// The class knows how to construct the stack hint message based on
520-
/// traversing the CallExpr associated with the call and checking if the given
521-
/// symbol is returned or is one of the arguments.
522-
/// The hint can be customized by redefining 'getMessageForX()' methods.
523-
class StackHintGeneratorForSymbol : public StackHintGenerator {
524-
private:
525-
SymbolRef Sym;
526-
std::string Msg;
527-
528-
public:
529-
StackHintGeneratorForSymbol(SymbolRef S, StringRef M) : Sym(S), Msg(M) {}
530-
~StackHintGeneratorForSymbol() override = default;
531-
532-
/// Search the call expression for the symbol Sym and dispatch the
533-
/// 'getMessageForX()' methods to construct a specific message.
534-
std::string getMessage(const ExplodedNode *N) override;
535-
536-
/// Produces the message of the following form:
537-
/// 'Msg via Nth parameter'
538-
virtual std::string getMessageForArg(const Expr *ArgE, unsigned ArgIndex);
539-
540-
virtual std::string getMessageForReturn(const CallExpr *CallExpr) {
541-
return Msg;
542-
}
543-
544-
virtual std::string getMessageForSymbolNotFound() {
545-
return Msg;
546-
}
547-
};
548-
549496
class PathDiagnosticEventPiece : public PathDiagnosticSpotPiece {
550497
Optional<bool> IsPrunable;
551498

552-
/// If the event occurs in a different frame than the final diagnostic,
553-
/// supply a message that will be used to construct an extra hint on the
554-
/// returns from all the calls on the stack from this event to the final
555-
/// diagnostic.
556-
std::unique_ptr<StackHintGenerator> CallStackHint;
557-
558499
public:
559500
PathDiagnosticEventPiece(const PathDiagnosticLocation &pos,
560-
StringRef s, bool addPosRange = true,
561-
StackHintGenerator *stackHint = nullptr)
562-
: PathDiagnosticSpotPiece(pos, s, Event, addPosRange),
563-
CallStackHint(stackHint) {}
501+
StringRef s, bool addPosRange = true)
502+
: PathDiagnosticSpotPiece(pos, s, Event, addPosRange) {}
564503
~PathDiagnosticEventPiece() override;
565504

566505
/// Mark the diagnostic piece as being potentially prunable. This
@@ -577,16 +516,6 @@ class PathDiagnosticEventPiece : public PathDiagnosticSpotPiece {
577516
return IsPrunable.hasValue() ? IsPrunable.getValue() : false;
578517
}
579518

580-
bool hasCallStackHint() { return (bool)CallStackHint; }
581-
582-
/// Produce the hint for the given node. The node contains
583-
/// information about the call for which the diagnostic can be generated.
584-
std::string getCallStackMessage(const ExplodedNode *N) {
585-
if (CallStackHint)
586-
return CallStackHint->getMessage(N);
587-
return {};
588-
}
589-
590519
void dump() const override;
591520

592521
static bool classof(const PathDiagnosticPiece *P) {
@@ -863,11 +792,6 @@ class PathDiagnostic : public llvm::FoldingSetNode {
863792
VerboseDesc += S;
864793
}
865794

866-
/// If the last piece of the report point to the header file, resets
867-
/// the location of the report to be the last location in the main source
868-
/// file.
869-
void resetDiagnosticLocationToMainFile();
870-
871795
StringRef getVerboseDescription() const { return VerboseDesc; }
872796

873797
StringRef getShortDescription() const {
@@ -878,11 +802,6 @@ class PathDiagnostic : public llvm::FoldingSetNode {
878802
StringRef getBugType() const { return BugType; }
879803
StringRef getCategory() const { return Category; }
880804

881-
/// Return the semantic context where an issue occurred. If the
882-
/// issue occurs along a path, this represents the "central" area
883-
/// where the bug manifests.
884-
const Decl *getDeclWithIssue() const { return DeclWithIssue; }
885-
886805
using meta_iterator = std::deque<std::string>::const_iterator;
887806

888807
meta_iterator meta_begin() const { return OtherDesc.begin(); }
@@ -897,10 +816,23 @@ class PathDiagnostic : public llvm::FoldingSetNode {
897816
return *ExecutedLines;
898817
}
899818

819+
/// Return the semantic context where an issue occurred. If the
820+
/// issue occurs along a path, this represents the "central" area
821+
/// where the bug manifests.
822+
const Decl *getDeclWithIssue() const { return DeclWithIssue; }
823+
824+
void setDeclWithIssue(const Decl *D) {
825+
DeclWithIssue = D;
826+
}
827+
900828
PathDiagnosticLocation getLocation() const {
901829
return Loc;
902830
}
903831

832+
void setLocation(PathDiagnosticLocation NewLoc) {
833+
Loc = NewLoc;
834+
}
835+
904836
/// Get the location on which the report should be uniqued.
905837
PathDiagnosticLocation getUniqueingLoc() const {
906838
return UniqueingLoc;

clang/include/clang/Basic/DiagnosticFrontendKinds.td

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,12 @@ def warn_profile_data_missing : Warning<
275275
def warn_profile_data_unprofiled : Warning<
276276
"no profile data available for file \"%0\"">,
277277
InGroup<ProfileInstrUnprofiled>;
278-
278+
def warn_profile_data_misexpect : Warning<
279+
"Potential performance regression from use of __builtin_expect(): "
280+
"Annotation was correct on %0 of profiled executions.">,
281+
BackendInfo,
282+
InGroup<MisExpect>,
283+
DefaultIgnore;
279284
} // end of instrumentation issue category
280285

281286
}

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,7 @@ def BackendOptimizationFailure : DiagGroup<"pass-failed">;
10421042
def ProfileInstrMissing : DiagGroup<"profile-instr-missing">;
10431043
def ProfileInstrOutOfDate : DiagGroup<"profile-instr-out-of-date">;
10441044
def ProfileInstrUnprofiled : DiagGroup<"profile-instr-unprofiled">;
1045+
def MisExpect : DiagGroup<"misexpect">;
10451046

10461047
// AddressSanitizer frontend instrumentation remarks.
10471048
def SanitizeAddressRemarks : DiagGroup<"sanitize-address">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3406,6 +3406,10 @@ def note_pointer_declared_here : Note<
34063406
def warn_division_sizeof_ptr : Warning<
34073407
"'%0' will return the size of the pointer, not the array itself">,
34083408
InGroup<DiagGroup<"sizeof-pointer-div">>;
3409+
def warn_division_sizeof_array : Warning<
3410+
"expression does not compute the number of elements in this array; element "
3411+
"type is %0, not %1">,
3412+
InGroup<DiagGroup<"sizeof-array-div">>;
34093413

34103414
def note_function_warning_silence : Note<
34113415
"prefix with the address-of operator to silence this warning">;
@@ -9090,7 +9094,7 @@ def ext_omp_loop_not_canonical_init : ExtWarn<
90909094
"('var = init' or 'T var = init')">, InGroup<OpenMPLoopForm>;
90919095
def err_omp_loop_not_canonical_cond : Error<
90929096
"condition of OpenMP for loop must be a relational comparison "
9093-
"('<', '<=', '>', or '>=') of loop variable %0">;
9097+
"('<', '<=', '>', %select{or '>='|'>=', or '!='}0) of loop variable %1">;
90949098
def err_omp_loop_not_canonical_incr : Error<
90959099
"increment clause of OpenMP for loop must perform simple addition "
90969100
"or subtraction on loop variable %0">;

clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ struct Token {
6666
Token(TokenKind K, int Offset) : K(K), Offset(Offset) {}
6767
};
6868

69+
/// Simplified token range to track the range of a potentially skippable PP
70+
/// directive.
71+
struct SkippedRange {
72+
/// Offset into the output byte stream of where the skipped directive begins.
73+
int Offset;
74+
75+
/// The number of bytes that can be skipped before the preprocessing must
76+
/// resume.
77+
int Length;
78+
};
79+
80+
/// Computes the potential source ranges that can be skipped by the preprocessor
81+
/// when skipping a directive like #if, #ifdef or #elsif.
82+
///
83+
/// \returns false on success, true on error.
84+
bool computeSkippedRanges(ArrayRef<Token> Input,
85+
llvm::SmallVectorImpl<SkippedRange> &Range);
86+
6987
} // end namespace minimize_source_to_dependency_directives
7088

7189
/// Minimize the input down to the preprocessor directives that might have

clang/include/clang/Lex/DirectoryLookup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class DirectoryLookup {
183183
SmallVectorImpl<char> *RelativePath, Module *RequestingModule,
184184
ModuleMap::KnownHeader *SuggestedModule,
185185
bool &InUserSpecifiedSystemFramework, bool &IsFrameworkFound,
186-
bool &HasBeenMapped, SmallVectorImpl<char> &MappedName) const;
186+
bool &IsInHeaderMap, SmallVectorImpl<char> &MappedName) const;
187187

188188
private:
189189
Optional<FileEntryRef> DoFrameworkLookup(

clang/include/clang/Lex/Lexer.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,21 @@ class Lexer : public PreprocessorLexer {
265265
/// Return the current location in the buffer.
266266
const char *getBufferLocation() const { return BufferPtr; }
267267

268+
/// Returns the current lexing offset.
269+
unsigned getCurrentBufferOffset() {
270+
assert(BufferPtr >= BufferStart && "Invalid buffer state");
271+
return BufferPtr - BufferStart;
272+
}
273+
274+
/// Skip over \p NumBytes bytes.
275+
///
276+
/// If the skip is successful, the next token will be lexed from the new
277+
/// offset. The lexer also assumes that we skipped to the start of the line.
278+
///
279+
/// \returns true if the skip failed (new offset would have been past the
280+
/// end of the buffer), false otherwise.
281+
bool skipOver(unsigned NumBytes);
282+
268283
/// Stringify - Convert the specified string into a C string by i) escaping
269284
/// '\\' and " characters and ii) replacing newline character(s) with "\\n".
270285
/// If Charify is true, this escapes the ' character instead of ".

0 commit comments

Comments
 (0)