Skip to content

Commit c6b3a6a

Browse files
authored
Merge pull request #6 from swiftwasm/swift/master
[pull] swiftwasm from swift/master
2 parents d79d38d + dcc89a2 commit c6b3a6a

File tree

846 files changed

+16140
-6561
lines changed

Some content is hidden

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

846 files changed

+16140
-6561
lines changed

clang/docs/analyzer/developer-docs/DebugChecks.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,28 @@ ExprInspection checks
275275

276276
See clang_analyzer_denote().
277277

278+
- ``void clang_analyzer_isTainted(a single argument of any type);``
279+
280+
Queries the analyzer whether the expression used as argument is tainted or not.
281+
This is useful in tests, where we don't want to issue warning for all tainted
282+
expressions but only check for certain expressions.
283+
This would help to reduce the *noise* that the `TaintTest` debug checker would
284+
introduce and let you focus on the `expected-warning`s that you really care
285+
about.
286+
287+
Example usage::
288+
289+
int read_integer() {
290+
int n;
291+
clang_analyzer_isTainted(n); // expected-warning{{NO}}
292+
scanf("%d", &n);
293+
clang_analyzer_isTainted(n); // expected-warning{{YES}}
294+
clang_analyzer_isTainted(n + 2); // expected-warning{{YES}}
295+
clang_analyzer_isTainted(n > 0); // expected-warning{{YES}}
296+
int next_tainted_value = n; // no-warning
297+
return n;
298+
}
299+
278300
Statistics
279301
==========
280302

clang/include/clang/AST/ASTImporter.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "clang/AST/DeclBase.h"
1818
#include "clang/AST/DeclarationName.h"
19+
#include "clang/AST/ExprCXX.h"
1920
#include "clang/AST/NestedNameSpecifier.h"
2021
#include "clang/AST/TemplateName.h"
2122
#include "clang/AST/Type.h"
@@ -349,6 +350,10 @@ class TypeSourceInfo;
349350
return ToOrErr.takeError();
350351
}
351352

353+
/// Import cleanup objects owned by ExprWithCleanup.
354+
llvm::Expected<ExprWithCleanups::CleanupObject>
355+
Import(ExprWithCleanups::CleanupObject From);
356+
352357
/// Import the given type from the "from" context into the "to"
353358
/// context. A null type is imported as a null type (no error).
354359
///

clang/include/clang/AST/Decl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3500,6 +3500,7 @@ class EnumDecl : public TagDecl {
35003500
/// negative enumerators of this enum. (see getNumNegativeBits)
35013501
void setNumNegativeBits(unsigned Num) { EnumDeclBits.NumNegativeBits = Num; }
35023502

3503+
public:
35033504
/// True if this tag declaration is a scoped enumeration. Only
35043505
/// possible in C++11 mode.
35053506
void setScoped(bool Scoped = true) { EnumDeclBits.IsScoped = Scoped; }
@@ -3516,6 +3517,7 @@ class EnumDecl : public TagDecl {
35163517
/// Microsoft-style enumeration with a fixed underlying type.
35173518
void setFixed(bool Fixed = true) { EnumDeclBits.IsFixed = Fixed; }
35183519

3520+
private:
35193521
/// True if a valid hash is stored in ODRHash.
35203522
bool hasODRHash() const { return EnumDeclBits.HasODRHash; }
35213523
void setHasODRHash(bool Hash = true) { EnumDeclBits.HasODRHash = Hash; }

clang/include/clang/AST/DeclBase.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,16 @@ class alignas(8) Decl {
626626
setModuleOwnershipKind(ModuleOwnershipKind::ModulePrivate);
627627
}
628628

629-
/// Set the owning module ID.
629+
public:
630+
/// Set the FromASTFile flag. This indicates that this declaration
631+
/// was deserialized and not parsed from source code and enables
632+
/// features such as module ownership information.
633+
void setFromASTFile() {
634+
FromASTFile = true;
635+
}
636+
637+
/// Set the owning module ID. This may only be called for
638+
/// deserialized Decls.
630639
void setOwningModuleID(unsigned ID) {
631640
assert(isFromASTFile() && "Only works on a deserialized declaration");
632641
*((unsigned*)this - 2) = ID;

clang/include/clang/AST/DeclCXX.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,17 +2387,6 @@ class CXXConstructorDecl final
23872387
: ExplicitSpecKind::ResolvedFalse);
23882388
}
23892389

2390-
void setExplicitSpecifier(ExplicitSpecifier ES) {
2391-
assert((!ES.getExpr() ||
2392-
CXXConstructorDeclBits.HasTrailingExplicitSpecifier) &&
2393-
"cannot set this explicit specifier. no trail-allocated space for "
2394-
"explicit");
2395-
if (ES.getExpr())
2396-
*getCanonicalDecl()->getTrailingObjects<ExplicitSpecifier>() = ES;
2397-
else
2398-
CXXConstructorDeclBits.IsSimpleExplicit = ES.isExplicit();
2399-
}
2400-
24012390
enum TraillingAllocKind {
24022391
TAKInheritsConstructor = 1,
24032392
TAKHasTailExplicit = 1 << 1,
@@ -2422,6 +2411,17 @@ class CXXConstructorDecl final
24222411
ConstexprSpecKind ConstexprKind,
24232412
InheritedConstructor Inherited = InheritedConstructor());
24242413

2414+
void setExplicitSpecifier(ExplicitSpecifier ES) {
2415+
assert((!ES.getExpr() ||
2416+
CXXConstructorDeclBits.HasTrailingExplicitSpecifier) &&
2417+
"cannot set this explicit specifier. no trail-allocated space for "
2418+
"explicit");
2419+
if (ES.getExpr())
2420+
*getCanonicalDecl()->getTrailingObjects<ExplicitSpecifier>() = ES;
2421+
else
2422+
CXXConstructorDeclBits.IsSimpleExplicit = ES.isExplicit();
2423+
}
2424+
24252425
ExplicitSpecifier getExplicitSpecifier() {
24262426
return getCanonicalDecl()->getExplicitSpecifierInternal();
24272427
}
@@ -2688,8 +2688,6 @@ class CXXConversionDecl : public CXXMethodDecl {
26882688

26892689
ExplicitSpecifier ExplicitSpec;
26902690

2691-
void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
2692-
26932691
public:
26942692
friend class ASTDeclReader;
26952693
friend class ASTDeclWriter;
@@ -2711,6 +2709,7 @@ class CXXConversionDecl : public CXXMethodDecl {
27112709

27122710
/// Return true if the declartion is already resolved to be explicit.
27132711
bool isExplicit() const { return getExplicitSpecifier().isExplicit(); }
2712+
void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
27142713

27152714
/// Returns the type that this conversion function is converting to.
27162715
QualType getConversionType() const {

clang/include/clang/AST/DeclTemplate.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,10 @@ class ClassTemplateSpecializationDecl
17301730
return *TemplateArgs;
17311731
}
17321732

1733+
void setTemplateArgs(TemplateArgumentList *Args) {
1734+
TemplateArgs = Args;
1735+
}
1736+
17331737
/// Determine the kind of specialization that this
17341738
/// declaration represents.
17351739
TemplateSpecializationKind getSpecializationKind() const {
@@ -1762,6 +1766,10 @@ class ClassTemplateSpecializationDecl
17621766
getTemplateSpecializationKind());
17631767
}
17641768

1769+
void setSpecializedTemplate(ClassTemplateDecl *Specialized) {
1770+
SpecializedTemplate = Specialized;
1771+
}
1772+
17651773
void setSpecializationKind(TemplateSpecializationKind TSK) {
17661774
SpecializationKind = TSK;
17671775
}

clang/include/clang/AST/ExprCXX.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3306,13 +3306,15 @@ class DependentScopeDeclRefExpr final
33063306
/// literal is the extent of the enclosing scope.
33073307
class ExprWithCleanups final
33083308
: public FullExpr,
3309-
private llvm::TrailingObjects<ExprWithCleanups, BlockDecl *> {
3309+
private llvm::TrailingObjects<
3310+
ExprWithCleanups,
3311+
llvm::PointerUnion<BlockDecl *, CompoundLiteralExpr *>> {
33103312
public:
33113313
/// The type of objects that are kept in the cleanup.
3312-
/// It's useful to remember the set of blocks; we could also
3313-
/// remember the set of temporaries, but there's currently
3314-
/// no need.
3315-
using CleanupObject = BlockDecl *;
3314+
/// It's useful to remember the set of blocks and block-scoped compound
3315+
/// literals; we could also remember the set of temporaries, but there's
3316+
/// currently no need.
3317+
using CleanupObject = llvm::PointerUnion<BlockDecl *, CompoundLiteralExpr *>;
33163318

33173319
private:
33183320
friend class ASTStmtReader;

clang/include/clang/AST/ExternalASTSource.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,21 @@ class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
173173
StringRef Path;
174174
StringRef ASTFile;
175175
ASTFileSignature Signature;
176-
const Module *ClangModule = nullptr;
176+
Module *ClangModule = nullptr;
177177

178178
public:
179179
ASTSourceDescriptor() = default;
180180
ASTSourceDescriptor(StringRef Name, StringRef Path, StringRef ASTFile,
181181
ASTFileSignature Signature)
182182
: PCHModuleName(std::move(Name)), Path(std::move(Path)),
183183
ASTFile(std::move(ASTFile)), Signature(Signature) {}
184-
ASTSourceDescriptor(const Module &M);
184+
ASTSourceDescriptor(Module &M);
185185

186186
std::string getModuleName() const;
187187
StringRef getPath() const { return Path; }
188188
StringRef getASTFile() const { return ASTFile; }
189189
ASTFileSignature getSignature() const { return Signature; }
190-
const Module *getModuleOrNull() const { return ClangModule; }
190+
Module *getModuleOrNull() const { return ClangModule; }
191191
};
192192

193193
/// Return a descriptor for the corresponding module, if one exists.

clang/include/clang/AST/NonTrivialTypeVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types *- C++ --*-===//
1+
//===-- NonTrivialTypeVisitor.h - Visitor for non-trivial Types -*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

clang/include/clang/AST/TextNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class TextNodeDumper
184184
void dumpBareDeclRef(const Decl *D);
185185
void dumpName(const NamedDecl *ND);
186186
void dumpAccessSpecifier(AccessSpecifier AS);
187+
void dumpCleanupObject(const ExprWithCleanups::CleanupObject &C);
187188

188189
void dumpDeclRef(const Decl *D, StringRef Label = {});
189190

0 commit comments

Comments
 (0)