Vendor import of clang release_60 branch r323338:

https://llvm.org/svn/llvm-project/cfe/branches/release_60@323338
This commit is contained in:
Dimitry Andric 2018-01-24 20:25:37 +00:00
parent ead8c8e4f1
commit 520a89e9d3
44 changed files with 494 additions and 160 deletions

68
docs/OpenMPSupport.rst Normal file

@ -0,0 +1,68 @@
.. raw:: html
<style type="text/css">
.none { background-color: #FFCCCC }
.partial { background-color: #FFFF99 }
.good { background-color: #CCFF99 }
</style>
.. role:: none
.. role:: partial
.. role:: good
==================
OpenMP Support
==================
Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang supports offloading to X86_64, AArch64 and PPC64[LE] devices.
Support for Cuda devices is not ready yet.
The status of major OpenMP 4.5 features support in Clang.
Standalone directives
=====================
* #pragma omp [for] simd: :good:`Complete`.
* #pragma omp declare simd: :partial:`Partial`. We support parsing/semantic
analysis + generation of special attributes for X86 target, but still
missing the LLVM pass for vectorization.
* #pragma omp taskloop [simd]: :good:`Complete`.
* #pragma omp target [enter|exit] data: :good:`Complete`.
* #pragma omp target update: :good:`Complete`.
* #pragma omp target: :partial:`Partial`. No support for the `depend` clauses.
* #pragma omp declare target: :partial:`Partial`. No full codegen support.
* #pragma omp teams: :good:`Complete`.
* #pragma omp distribute [simd]: :good:`Complete`.
* #pragma omp distribute parallel for [simd]: :good:`Complete`.
Combined directives
===================
* #pragma omp parallel for simd: :good:`Complete`.
* #pragma omp target parallel: :partial:`Partial`. No support for the `depend` clauses.
* #pragma omp target parallel for [simd]: :partial:`Partial`. No support for the `depend` clauses.
* #pragma omp target simd: :partial:`Partial`. No support for the `depend` clauses.
* #pragma omp target teams: :partial:`Partial`. No support for the `depend` clauses.
* #pragma omp teams distribute [simd]: :good:`Complete`.
* #pragma omp target teams distribute [simd]: :partial:`Partial`. No support for the and `depend` clauses.
* #pragma omp teams distribute parallel for [simd]: :good:`Complete`.
* #pragma omp target teams distribute parallel for [simd]: :partial:`Partial`. No full codegen support.
Clang does not support any constructs/updates from upcoming OpenMP 5.0 except for `reduction`-based clauses in the `task` and `target`-based directives.
In addition, the LLVM OpenMP runtime `libomp` supports the OpenMP Tools Interface (OMPT) on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and mac OS.

@ -163,6 +163,15 @@ Attribute Changes in Clang
- The presence of __attribute__((availability(...))) on a declaration no longer
implies default visibility for that declaration on macOS.
- Clang now supports configuration files. These are collections of driver
options, which can be applied by specifying the configuration file, either
using command line option `--config foo.cfg` or encoding it into executable
name `foo-clang`. Clang behaves as if the options from this file were inserted
before the options specified in command line. This feature is primary intended
to facilitate cross compilation. Details can be found in
`Clang Compiler User's Manual
<http://clang.llvm.org/docs/UsersManual.html#configuration-files>`.
- ...
Windows Support
@ -209,7 +218,7 @@ OpenCL C Language Changes in Clang
OpenMP Support in Clang
----------------------------------
- Added options `-f[no]-openmp-simd` that support code emission only foe OpenMP
- Added options `-f[no]-openmp-simd` that support code emission only for OpenMP
SIMD-based directives, like `#pragma omp simd`, `#pragma omp parallel for simd`
etc. The code is emitted only for simd-based part of the combined directives
and clauses.
@ -222,6 +231,13 @@ OpenMP Support in Clang
- Added support for `reduction`-based clauses on `task`-based directives from
upcoming OpenMP 5.0.
- The LLVM OpenMP runtime `libomp` now supports the OpenMP Tools Interface (OMPT)
on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and macOS. If you observe
a measurable performance impact on one of your applications without a tool
attached, please rebuild the runtime library with `-DLIBOMP_OMPT_SUPPORT=OFF` and
file a bug at `LLVM's Bugzilla <https://bugs.llvm.org/>`_ or send a message to the
`OpenMP development list <http://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev>`_.
Internal API Changes
--------------------

@ -39,6 +39,7 @@ Using Clang as a Compiler
SourceBasedCodeCoverage
Modules
MSVCCompatibility
OpenMPSupport
ThinLTO
CommandGuide/index
FAQ

@ -549,6 +549,7 @@ def Aligned : InheritableAttr {
Keyword<"_Alignas">]>,
Accessor<"isDeclspec",[Declspec<"align">]>];
let Documentation = [Undocumented];
let DuplicatesAllowedWhileMerging = 1;
}
def AlignValue : Attr {

@ -1357,15 +1357,15 @@ TARGET_BUILTIN(__builtin_ia32_vpshrdvw128_maskz, "V8sV8sV8sV8sUc", "", "avx512vl
TARGET_BUILTIN(__builtin_ia32_vpshrdvw256_maskz, "V16sV16sV16sV16sUs", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdvw512_maskz, "V32sV32sV32sV32sUi", "", "avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdd128_mask, "V4iV4iV4iiV4iUc", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdd256_mask, "V8iV8iV8iiV8iUc", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdd512_mask, "V16iV16iV16iiV16iUs", "", "avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdq128_mask, "V2LLiV2LLiV2LLiiV2LLiUc", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdq256_mask, "V4LLiV4LLiV4LLiiV4LLiUc", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdq512_mask, "V8LLiV8LLiV8LLiiV8LLiUc", "", "avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdw128_mask, "V8sV8sV8siV8sUc", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdw256_mask, "V16sV16sV16siV16sUs", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdw512_mask, "V32sV32sV32siV32sUi", "", "avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdd128_mask, "V4iV4iV4iIiV4iUc", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdd256_mask, "V8iV8iV8iIiV8iUc", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdd512_mask, "V16iV16iV16iIiV16iUs", "", "avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdq128_mask, "V2LLiV2LLiV2LLiIiV2LLiUc", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdq256_mask, "V4LLiV4LLiV4LLiIiV4LLiUc", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdq512_mask, "V8LLiV8LLiV8LLiIiV8LLiUc", "", "avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdw128_mask, "V8sV8sV8sIiV8sUc", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdw256_mask, "V16sV16sV16sIiV16sUs", "", "avx512vl,avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_vpshrdw512_mask, "V32sV32sV32sIiV32sUi", "", "avx512vbmi2")
TARGET_BUILTIN(__builtin_ia32_pmovswb512_mask, "V32cV32sV32cUi", "", "avx512bw")
TARGET_BUILTIN(__builtin_ia32_pmovuswb512_mask, "V32cV32sV32cUi", "", "avx512bw")

@ -444,8 +444,7 @@ def TautologicalInRangeCompare : DiagGroup<"tautological-constant-in-range-compa
TautologicalUnsignedEnumZeroCompare]>;
def TautologicalOutOfRangeCompare : DiagGroup<"tautological-constant-out-of-range-compare">;
def TautologicalConstantCompare : DiagGroup<"tautological-constant-compare",
[TautologicalInRangeCompare,
TautologicalOutOfRangeCompare]>;
[TautologicalOutOfRangeCompare]>;
def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
@ -719,7 +718,6 @@ def IntToPointerCast : DiagGroup<"int-to-pointer-cast",
def Move : DiagGroup<"move", [PessimizingMove, RedundantMove, SelfMove]>;
def Extra : DiagGroup<"extra", [
TautologicalInRangeCompare,
MissingFieldInitializers,
IgnoredQualifiers,
InitializerOverrides,

@ -398,7 +398,6 @@ TYPE_TRAIT_2(__builtin_types_compatible_p, TypeCompatible, KEYNOCXX)
KEYWORD(__builtin_va_arg , KEYALL)
KEYWORD(__extension__ , KEYALL)
KEYWORD(__float128 , KEYALL)
ALIAS("_Float128", __float128 , KEYNOCXX)
KEYWORD(__imag , KEYALL)
KEYWORD(__int128 , KEYALL)
KEYWORD(__label__ , KEYALL)

@ -32,27 +32,39 @@ private:
const CheckName Check;
const std::string Name;
const std::string Category;
bool SuppressonSink;
const CheckerBase *Checker;
bool SuppressOnSink;
virtual void anchor();
public:
BugType(class CheckName check, StringRef name, StringRef cat)
: Check(check), Name(name), Category(cat), SuppressonSink(false) {}
BugType(const CheckerBase *checker, StringRef name, StringRef cat)
: Check(checker->getCheckName()), Name(name), Category(cat),
SuppressonSink(false) {}
virtual ~BugType() {}
// FIXME: Should these be made strings as well?
public:
BugType(CheckName Check, StringRef Name, StringRef Cat)
: Check(Check), Name(Name), Category(Cat), Checker(nullptr),
SuppressOnSink(false) {}
BugType(const CheckerBase *Checker, StringRef Name, StringRef Cat)
: Check(Checker->getCheckName()), Name(Name), Category(Cat),
Checker(Checker), SuppressOnSink(false) {}
virtual ~BugType() = default;
StringRef getName() const { return Name; }
StringRef getCategory() const { return Category; }
StringRef getCheckName() const { return Check.getName(); }
StringRef getCheckName() const {
// FIXME: This is a workaround to ensure that the correct check name is used
// The check names are set after the constructors are run.
// In case the BugType object is initialized in the checker's ctor
// the Check field will be empty. To circumvent this problem we use
// CheckerBase whenever it is possible.
StringRef CheckName =
Checker ? Checker->getCheckName().getName() : Check.getName();
assert(!CheckName.empty() && "Check name is not set properly.");
return CheckName;
}
/// isSuppressOnSink - Returns true if bug reports associated with this bug
/// type should be suppressed if the end node of the report is post-dominated
/// by a sink node.
bool isSuppressOnSink() const { return SuppressonSink; }
void setSuppressOnSink(bool x) { SuppressonSink = x; }
bool isSuppressOnSink() const { return SuppressOnSink; }
void setSuppressOnSink(bool x) { SuppressOnSink = x; }
virtual void FlushReports(BugReporter& BR);
};
@ -74,7 +86,7 @@ public:
StringRef getDescription() const { return desc; }
};
} // end GR namespace
} // end ento namespace
} // end clang namespace
#endif

@ -891,12 +891,14 @@ bool Decl::AccessDeclContextSanity() const {
// 4. the context is not a record
// 5. it's invalid
// 6. it's a C++0x static_assert.
// 7. it's a block literal declaration
if (isa<TranslationUnitDecl>(this) ||
isa<TemplateTypeParmDecl>(this) ||
isa<NonTypeTemplateParmDecl>(this) ||
!isa<CXXRecordDecl>(getDeclContext()) ||
isInvalidDecl() ||
isa<StaticAssertDecl>(this) ||
isa<BlockDecl>(this) ||
// FIXME: a ParmVarDecl can have ClassTemplateSpecialization
// as DeclContext (?).
isa<ParmVarDecl>(this) ||

@ -478,6 +478,8 @@ void ODRHash::AddFunctionDecl(const FunctionDecl *Function) {
// TODO: Fix hashing for class methods.
if (isa<CXXMethodDecl>(Function)) return;
// And friend functions.
if (Function->getFriendObjectKind()) return;
// Skip functions that are specializations or in specialization context.
const DeclContext *DC = Function;

@ -915,7 +915,11 @@ EmitCheckedMixedSignMultiply(CodeGenFunction &CGF, const clang::Expr *Op1,
Overflow = CGF.Builder.CreateOr(Overflow, TruncOverflow);
}
Result = CGF.Builder.CreateTrunc(UnsignedResult, ResTy);
// Negate the product if it would be negative in infinite precision.
Result = CGF.Builder.CreateSelect(
IsNegative, CGF.Builder.CreateNeg(UnsignedResult), UnsignedResult);
Result = CGF.Builder.CreateTrunc(Result, ResTy);
}
assert(Overflow && Result && "Missing overflow or result");

@ -229,6 +229,11 @@ public:
Builder->getModuleDebugInfo()->completeRequiredType(RD);
}
void HandleImplicitImportDecl(ImportDecl *D) override {
if (!D->getImportedOwningModule())
Builder->getModuleDebugInfo()->EmitImportDecl(*D);
}
/// Emit a container holding the serialized AST.
void HandleTranslationUnit(ASTContext &Ctx) override {
assert(M && VMContext && Builder);

@ -817,10 +817,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
DefineFloatMacros(Builder, "FLT", &TI.getFloatFormat(), "F");
DefineFloatMacros(Builder, "DBL", &TI.getDoubleFormat(), "");
DefineFloatMacros(Builder, "LDBL", &TI.getLongDoubleFormat(), "L");
if (TI.hasFloat128Type())
// FIXME: Switch away from the non-standard "Q" when we can
DefineFloatMacros(Builder, "FLT128", &TI.getFloat128Format(), "Q");
// Define a __POINTER_WIDTH__ macro for stdint.h.
Builder.defineMacro("__POINTER_WIDTH__",

@ -2009,18 +2009,21 @@ bool Lexer::LexAngledStringLiteral(Token &Result, const char *CurPtr) {
const char *AfterLessPos = CurPtr;
char C = getAndAdvanceChar(CurPtr, Result);
while (C != '>') {
// Skip escaped characters.
if (C == '\\' && CurPtr < BufferEnd) {
// Skip the escaped character.
getAndAdvanceChar(CurPtr, Result);
} else if (C == '\n' || C == '\r' || // Newline.
(C == 0 && (CurPtr-1 == BufferEnd || // End of file.
isCodeCompletionPoint(CurPtr-1)))) {
// Skip escaped characters. Escaped newlines will already be processed by
// getAndAdvanceChar.
if (C == '\\')
C = getAndAdvanceChar(CurPtr, Result);
if (C == '\n' || C == '\r' || // Newline.
(C == 0 && (CurPtr-1 == BufferEnd || // End of file.
isCodeCompletionPoint(CurPtr-1)))) {
// If the filename is unterminated, then it must just be a lone <
// character. Return this as such.
FormTokenWithChars(Result, AfterLessPos, tok::less);
return true;
} else if (C == 0) {
}
if (C == 0) {
NulCharacter = CurPtr-1;
}
C = getAndAdvanceChar(CurPtr, Result);

@ -105,8 +105,10 @@ void Preprocessor::CachingLex(Token &Result) {
}
void Preprocessor::EnterCachingLexMode() {
if (InCachingLexMode())
if (InCachingLexMode()) {
assert(CurLexerKind == CLK_CachingLexer && "Unexpected lexer kind");
return;
}
PushIncludeMacroStack();
CurLexerKind = CLK_CachingLexer;

@ -444,6 +444,7 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) {
}
CurPPLexer = nullptr;
recomputeCurLexerKind();
return true;
}

@ -143,72 +143,43 @@ void Scope::dumpImpl(raw_ostream &OS) const {
if (HasFlags)
OS << "Flags: ";
while (Flags) {
if (Flags & FnScope) {
OS << "FnScope";
Flags &= ~FnScope;
} else if (Flags & BreakScope) {
OS << "BreakScope";
Flags &= ~BreakScope;
} else if (Flags & ContinueScope) {
OS << "ContinueScope";
Flags &= ~ContinueScope;
} else if (Flags & DeclScope) {
OS << "DeclScope";
Flags &= ~DeclScope;
} else if (Flags & ControlScope) {
OS << "ControlScope";
Flags &= ~ControlScope;
} else if (Flags & ClassScope) {
OS << "ClassScope";
Flags &= ~ClassScope;
} else if (Flags & BlockScope) {
OS << "BlockScope";
Flags &= ~BlockScope;
} else if (Flags & TemplateParamScope) {
OS << "TemplateParamScope";
Flags &= ~TemplateParamScope;
} else if (Flags & FunctionPrototypeScope) {
OS << "FunctionPrototypeScope";
Flags &= ~FunctionPrototypeScope;
} else if (Flags & FunctionDeclarationScope) {
OS << "FunctionDeclarationScope";
Flags &= ~FunctionDeclarationScope;
} else if (Flags & AtCatchScope) {
OS << "AtCatchScope";
Flags &= ~AtCatchScope;
} else if (Flags & ObjCMethodScope) {
OS << "ObjCMethodScope";
Flags &= ~ObjCMethodScope;
} else if (Flags & SwitchScope) {
OS << "SwitchScope";
Flags &= ~SwitchScope;
} else if (Flags & TryScope) {
OS << "TryScope";
Flags &= ~TryScope;
} else if (Flags & FnTryCatchScope) {
OS << "FnTryCatchScope";
Flags &= ~FnTryCatchScope;
} else if (Flags & SEHTryScope) {
OS << "SEHTryScope";
Flags &= ~SEHTryScope;
} else if (Flags & SEHExceptScope) {
OS << "SEHExceptScope";
Flags &= ~SEHExceptScope;
} else if (Flags & OpenMPDirectiveScope) {
OS << "OpenMPDirectiveScope";
Flags &= ~OpenMPDirectiveScope;
} else if (Flags & OpenMPLoopDirectiveScope) {
OS << "OpenMPLoopDirectiveScope";
Flags &= ~OpenMPLoopDirectiveScope;
} else if (Flags & OpenMPSimdDirectiveScope) {
OS << "OpenMPSimdDirectiveScope";
Flags &= ~OpenMPSimdDirectiveScope;
}
std::pair<unsigned, const char *> FlagInfo[] = {
{FnScope, "FnScope"},
{BreakScope, "BreakScope"},
{ContinueScope, "ContinueScope"},
{DeclScope, "DeclScope"},
{ControlScope, "ControlScope"},
{ClassScope, "ClassScope"},
{BlockScope, "BlockScope"},
{TemplateParamScope, "TemplateParamScope"},
{FunctionPrototypeScope, "FunctionPrototypeScope"},
{FunctionDeclarationScope, "FunctionDeclarationScope"},
{AtCatchScope, "AtCatchScope"},
{ObjCMethodScope, "ObjCMethodScope"},
{SwitchScope, "SwitchScope"},
{TryScope, "TryScope"},
{FnTryCatchScope, "FnTryCatchScope"},
{OpenMPDirectiveScope, "OpenMPDirectiveScope"},
{OpenMPLoopDirectiveScope, "OpenMPLoopDirectiveScope"},
{OpenMPSimdDirectiveScope, "OpenMPSimdDirectiveScope"},
{EnumScope, "EnumScope"},
{SEHTryScope, "SEHTryScope"},
{SEHExceptScope, "SEHExceptScope"},
{SEHFilterScope, "SEHFilterScope"},
{CompoundStmtScope, "CompoundStmtScope"},
{ClassInheritanceScope, "ClassInheritanceScope"}};
if (Flags)
OS << " | ";
for (auto Info : FlagInfo) {
if (Flags & Info.first) {
OS << Info.second;
Flags &= ~Info.first;
if (Flags)
OS << " | ";
}
}
assert(Flags == 0 && "Unknown scope flags");
if (HasFlags)
OS << '\n';

@ -502,6 +502,10 @@ DeduceTemplateArguments(Sema &S,
SmallVectorImpl<DeducedTemplateArgument> &Deduced) {
assert(Arg.isCanonical() && "Argument type must be canonical");
// Treat an injected-class-name as its underlying template-id.
if (auto *Injected = dyn_cast<InjectedClassNameType>(Arg))
Arg = Injected->getInjectedSpecializationType();
// Check whether the template argument is a dependent template-id.
if (const TemplateSpecializationType *SpecArg
= dyn_cast<TemplateSpecializationType>(Arg)) {

@ -4160,7 +4160,8 @@ void Sema::BuildVariableInstantiation(
// it right away if the type contains 'auto'.
if ((!isa<VarTemplateSpecializationDecl>(NewVar) &&
!InstantiatingVarTemplate &&
!(OldVar->isInline() && OldVar->isThisDeclarationADefinition())) ||
!(OldVar->isInline() && OldVar->isThisDeclarationADefinition() &&
!NewVar->isThisDeclarationADefinition())) ||
NewVar->getType()->isUndeducedType())
InstantiateVariableInitializer(NewVar, OldVar, TemplateArgs);

@ -2900,8 +2900,13 @@ void ento::registerNewDeleteLeaksChecker(CheckerManager &mgr) {
mgr.getCurrentCheckName();
// We currently treat NewDeleteLeaks checker as a subchecker of NewDelete
// checker.
if (!checker->ChecksEnabled[MallocChecker::CK_NewDeleteChecker])
if (!checker->ChecksEnabled[MallocChecker::CK_NewDeleteChecker]) {
checker->ChecksEnabled[MallocChecker::CK_NewDeleteChecker] = true;
// FIXME: This does not set the correct name, but without this workaround
// no name will be set at all.
checker->CheckNames[MallocChecker::CK_NewDeleteChecker] =
mgr.getCurrentCheckName();
}
}
#define REGISTER_CHECKER(name) \

@ -64,7 +64,7 @@ private:
CheckerContext &C) const;
void reportLeakedVALists(const RegionVector &LeakedVALists, StringRef Msg1,
StringRef Msg2, CheckerContext &C, ExplodedNode *N,
bool ForceReport = false) const;
bool ReportUninit = false) const;
void checkVAListStartCall(const CallEvent &Call, CheckerContext &C,
bool IsCopy) const;
@ -267,15 +267,19 @@ void ValistChecker::reportUninitializedAccess(const MemRegion *VAList,
void ValistChecker::reportLeakedVALists(const RegionVector &LeakedVALists,
StringRef Msg1, StringRef Msg2,
CheckerContext &C, ExplodedNode *N,
bool ForceReport) const {
bool ReportUninit) const {
if (!(ChecksEnabled[CK_Unterminated] ||
(ChecksEnabled[CK_Uninitialized] && ForceReport)))
(ChecksEnabled[CK_Uninitialized] && ReportUninit)))
return;
for (auto Reg : LeakedVALists) {
if (!BT_leakedvalist) {
BT_leakedvalist.reset(new BugType(CheckNames[CK_Unterminated],
"Leaked va_list",
categories::MemoryError));
// FIXME: maybe creating a new check name for this type of bug is a better
// solution.
BT_leakedvalist.reset(
new BugType(CheckNames[CK_Unterminated].getName().empty()
? CheckNames[CK_Uninitialized]
: CheckNames[CK_Unterminated],
"Leaked va_list", categories::MemoryError));
BT_leakedvalist->setSuppressOnSink(true);
}
@ -375,7 +379,7 @@ void ValistChecker::checkVAListEndCall(const CallEvent &Call,
std::shared_ptr<PathDiagnosticPiece> ValistChecker::ValistBugVisitor::VisitNode(
const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC,
BugReport &BR) {
BugReport &) {
ProgramStateRef State = N->getState();
ProgramStateRef StatePrev = PrevN->getState();

@ -1720,13 +1720,6 @@ void *smallocWarn(size_t size) {
}
}
char *dupstrWarn(const char *s) {
const int len = strlen(s);
char *p = (char*) smallocWarn(len + 1);
strcpy(p, s); // expected-warning{{String copy function overflows destination buffer}}
return p;
}
int *radar15580979() {
int *data = (int *)malloc(32);
int *p = data ?: (int*)malloc(32); // no warning

@ -0,0 +1,4 @@
// PR32732
struct B {
// <- code completion
};

@ -0,0 +1,13 @@
// Note: the run lines follow their respective tests, since line/column
// matter in this test.
#include "comments.h"
struct A {
// <- code completion
/* <- code completion */
};
// RUN: %clang_cc1 -I %S/Inputs -fsyntax-only -code-completion-at=%s:7:6 %s
// RUN: %clang_cc1 -I %S/Inputs -fsyntax-only -code-completion-at=%s:8:6 %s
// RUN: %clang_cc1 -I %S/Inputs -fsyntax-only -code-completion-at=%S/Inputs/comments.h:3:6 %s

@ -373,7 +373,9 @@ int test_mixed_sign_mull_overflow_unsigned(int x, unsigned y) {
// CHECK-NEXT: [[NotNull:%.*]] = icmp ne i32 [[UnsignedResult]], 0
// CHECK-NEXT: [[Underflow:%.*]] = and i1 [[IsNeg]], [[NotNull]]
// CHECK-NEXT: [[OFlow:%.*]] = or i1 [[UnsignedOFlow]], [[Underflow]]
// CHECK-NEXT: store i32 [[UnsignedResult]], i32* %{{.*}}, align 4
// CHECK-NEXT: [[NegatedResult:%.*]] = sub i32 0, [[UnsignedResult]]
// CHECK-NEXT: [[Result:%.*]] = select i1 [[IsNeg]], i32 [[NegatedResult]], i32 [[UnsignedResult]]
// CHECK-NEXT: store i32 [[Result]], i32* %{{.*}}, align 4
// CHECK: br i1 [[OFlow]]
unsigned result;
@ -432,7 +434,9 @@ long long test_mixed_sign_mulll_overflow_trunc_unsigned(long long x, unsigned lo
// CHECK-NEXT: [[OVERFLOW_PRE_TRUNC:%.*]] = or i1 {{.*}}, [[UNDERFLOW]]
// CHECK-NEXT: [[TRUNC_OVERFLOW:%.*]] = icmp ugt i64 [[UNSIGNED_RESULT]], 4294967295
// CHECK-NEXT: [[OVERFLOW:%.*]] = or i1 [[OVERFLOW_PRE_TRUNC]], [[TRUNC_OVERFLOW]]
// CHECK-NEXT: trunc i64 [[UNSIGNED_RESULT]] to i32
// CHECK-NEXT: [[NEGATED:%.*]] = sub i64 0, [[UNSIGNED_RESULT]]
// CHECK-NEXT: [[RESULT:%.*]] = select i1 {{.*}}, i64 [[NEGATED]], i64 [[UNSIGNED_RESULT]]
// CHECK-NEXT: trunc i64 [[RESULT]] to i32
// CHECK-NEXT: store
unsigned result;
if (__builtin_mul_overflow(y, x, &result))

@ -58,14 +58,22 @@ template<typename T> struct X {
static int a;
static inline int b;
static int c;
static const int d;
static int e;
};
// CHECK: @_ZN1XIiE1aE = linkonce_odr global i32 10
// CHECK: @_ZN1XIiE1bE = global i32 20
// CHECK-NOT: @_ZN1XIiE1cE
// CHECK: @_ZN1XIiE1dE = linkonce_odr constant i32 40
// CHECK: @_ZN1XIiE1eE = linkonce_odr global i32 50
template<> inline int X<int>::a = 10;
int &use3 = X<int>::a;
template<> int X<int>::b = 20;
template<> inline int X<int>::c = 30;
template<typename T> constexpr int X<T>::d = 40;
template<typename T> inline int X<T>::e = 50;
const int *use_x_int_d = &X<int>::d;
const int *use_x_int_e = &X<int>::e;
template<typename T> struct Y;
template<> struct Y<int> {

Binary file not shown.

@ -187,7 +187,7 @@ void foo() {
// CHECK: !DIGlobalVariable(name: "anon_enum", {{.*}}, type: ![[ANON_ENUM:[0-9]+]]
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[NS]],
// CHECK-SAME: line: 16
// CHECK-SAME: line: 19
// CHECK: !DIGlobalVariable(name: "GlobalUnion",
// CHECK-SAME: type: ![[GLOBAL_UNION:[0-9]+]]

@ -1,4 +1,7 @@
/* -*- C++ -*- */
#include "dummy.h"
namespace DebugCXX {
// Records.
struct Struct {

@ -0,0 +1,14 @@
template <class T>
struct iterator {
void Compare(const iterator &x) { }
friend void Check(iterator) {}
};
template <class T = int> struct Box {
iterator<T> I;
void test() {
Check(I);
I.Compare(I);
}
};

@ -0,0 +1,6 @@
#include "Box.h"
void Peek() {
Box<> Gift;
Gift.test();
}

@ -0,0 +1,5 @@
#include "Box.h"
void x() {
Box<> Unused;
//Unused.test();
}

@ -0,0 +1,7 @@
#include "Box.h"
#include "M2.h"
void Party() {
Box<> Present;
Present.test();
}

@ -0,0 +1,15 @@
module Box {
header "Box.h"
}
module Module1 {
header "M1.h"
}
module Module2 {
header "M2.h"
}
module Module3 {
header "M3.h"
}

@ -5,12 +5,13 @@
// Modules:
// RUN: rm -rf %t
// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debugger-tuning=lldb -debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
// RUN: cat %t-mod.ll | FileCheck %s
// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-MOD %s
// PCH:
// RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
// RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -debugger-tuning=lldb -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
// RUN: cat %t-pch.ll | FileCheck %s
// RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-NEG %s
@ -18,6 +19,9 @@
@import DebugCXX;
#endif
// CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
// CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
// CHECK: distinct !DICompileUnit(language: DW_LANG_{{.*}}C_plus_plus,
// CHECK-SAME: isOptimized: false,
// CHECK-NOT: splitDebugFilename:
@ -27,6 +31,8 @@
// CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE")
// CHECK: !DINamespace(name: "DebugCXX"
// CHECK-MOD: ![[DEBUGCXX:.*]] = !DIModule(scope: null, name: "DebugCXX
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
// CHECK-NOT: name:
// CHECK-SAME: )
@ -150,4 +156,11 @@
// CHECK-SAME: name: "WithSpecializedBase<float>",
// CHECK-SAME: flags: DIFlagFwdDecl,
// CHECK-MOD: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: ![[DEBUGCXX]],
// CHECK-MOD-SAME: entity: ![[DUMMY:[0-9]+]],
// CHECK-MOD-SAME: line: 3)
// CHECK-MOD: ![[DUMMY]] = !DIModule(scope: null, name: "dummy",
// CHECK-MOD: distinct !DICompileUnit(language: DW_LANG_ObjC_plus_plus,
// CHECK-MOD-SAME: splitDebugFilename: "{{.*}}dummy{{.*}}.pcm",
// CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: "PureForwardDecl"

@ -0,0 +1,22 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/modules.cache \
// RUN: -I %S/Inputs/odr_hash-Friend \
// RUN: -emit-obj -o /dev/null \
// RUN: -fmodules \
// RUN: -fimplicit-module-maps \
// RUN: -fmodules-cache-path=%t/modules.cache \
// RUN: -std=c++11 -x c++ %s -verify
// PR35939: MicrosoftMangle.cpp triggers an assertion failure on this test.
// UNSUPPORTED: system-windows
// expected-no-diagnostics
#include "Box.h"
#include "M1.h"
#include "M3.h"
void Run() {
Box<> Present;
}

@ -0,0 +1,119 @@
// Clear and create directories
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: mkdir %t/cache
// RUN: mkdir %t/Inputs
// Build first header file
// RUN: echo "#define FIRST" >> %t/Inputs/first.h
// RUN: cat %s >> %t/Inputs/first.h
// Build second header file
// RUN: echo "#define SECOND" >> %t/Inputs/second.h
// RUN: cat %s >> %t/Inputs/second.h
// Test that each header can compile
// RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 -fblocks %t/Inputs/first.h
// RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 -fblocks %t/Inputs/second.h
// Build module map file
// RUN: echo "module FirstModule {" >> %t/Inputs/module.map
// RUN: echo " header \"first.h\"" >> %t/Inputs/module.map
// RUN: echo "}" >> %t/Inputs/module.map
// RUN: echo "module SecondModule {" >> %t/Inputs/module.map
// RUN: echo " header \"second.h\"" >> %t/Inputs/module.map
// RUN: echo "}" >> %t/Inputs/module.map
// Run test
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
// RUN: -fmodules-cache-path=%t/cache -x c++ -I%t/Inputs \
// RUN: -verify %s -std=c++11 -fblocks
#if !defined(FIRST) && !defined(SECOND)
#include "first.h"
#include "second.h"
#endif
// Used for testing
#if defined(FIRST)
#define ACCESS public:
#elif defined(SECOND)
#define ACCESS private:
#endif
// TODO: S1, S2, and S3 should generate errors.
namespace Blocks {
#if defined(FIRST)
struct S1 {
void (^block)(int x) = ^(int x) { };
};
#elif defined(SECOND)
struct S1 {
void (^block)(int x) = ^(int y) { };
};
#else
S1 s1;
#endif
#if defined(FIRST)
struct S2 {
int (^block)(int x) = ^(int x) { return x + 1; };
};
#elif defined(SECOND)
struct S2 {
int (^block)(int x) = ^(int x) { return x; };
};
#else
S2 s2;
#endif
#if defined(FIRST)
struct S3 {
void run(int (^block)(int x));
};
#elif defined(SECOND)
struct S3 {
void run(int (^block)(int x, int y));
};
#else
S3 s3;
#endif
#define DECLS \
int (^block)(int x) = ^(int x) { return x + x; }; \
void run(int (^block)(int x, int y));
#if defined(FIRST) || defined(SECOND)
struct Valid1 {
DECLS
};
#else
Valid1 v1;
#endif
#if defined(FIRST) || defined(SECOND)
struct Invalid1 {
DECLS
ACCESS
};
#else
Invalid1 i1;
// expected-error@second.h:* {{'Blocks::Invalid1' has different definitions in different modules; first difference is definition in module 'SecondModule' found private access specifier}}
// expected-note@first.h:* {{but in 'FirstModule' found public access specifier}}
#endif
#undef DECLS
}
// Keep macros contained to one file.
#ifdef FIRST
#undef FIRST
#endif
#ifdef SECOND
#undef SECOND
#endif
#ifdef ACCESS
#undef ACCESS
#endif

@ -9,40 +9,40 @@
// RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
// RUN: | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
// RUN: | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-host-defines-filtered
// RUN: | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-host-defines-filtered
// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
// RUN: | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
// RUN: | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-device-defines-filtered
// RUN: | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-device-defines-filtered
// RUN: diff %t/i386-host-defines-filtered %t/i386-device-defines-filtered
// RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
// RUN: | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
// RUN: | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
// RUN: | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
// RUN: | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
// RUN: | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/x86_64-device-defines-filtered
// RUN: | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-device-defines-filtered
// RUN: diff %t/x86_64-host-defines-filtered %t/x86_64-device-defines-filtered
// RUN: %clang --cuda-host-only -nocudainc -target powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
// RUN: | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
// RUN: | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/powerpc64-host-defines-filtered
// RUN: | grep -v '__LDBL\|_LONG_DOUBLE' > %t/powerpc64-host-defines-filtered
// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
// RUN: | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
// RUN: | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/powerpc64-device-defines-filtered
// RUN: | grep -v '__LDBL\|_LONG_DOUBLE' > %t/powerpc64-device-defines-filtered
// RUN: diff %t/powerpc64-host-defines-filtered %t/powerpc64-device-defines-filtered
// RUN: %clang --cuda-host-only -nocudainc -target i386-windows-msvc -x cuda -E -dM -o - /dev/null \
// RUN: | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
// RUN: | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-msvc-host-defines-filtered
// RUN: | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-msvc-host-defines-filtered
// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target i386-windows-msvc -x cuda -E -dM -o - /dev/null \
// RUN: | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
// RUN: | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/i386-msvc-device-defines-filtered
// RUN: | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-msvc-device-defines-filtered
// RUN: diff %t/i386-msvc-host-defines-filtered %t/i386-msvc-device-defines-filtered
// RUN: %clang --cuda-host-only -nocudainc -target x86_64-windows-msvc -x cuda -E -dM -o - /dev/null \
// RUN: | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
// RUN: | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/x86_64-msvc-host-defines-filtered
// RUN: | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-msvc-host-defines-filtered
// RUN: %clang --cuda-device-only -nocudainc -nocudalib -target x86_64-windows-msvc -x cuda -E -dM -o - /dev/null \
// RUN: | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
// RUN: | grep -v '__FLT128\|__LDBL\|_LONG_DOUBLE' > %t/x86_64-msvc-device-defines-filtered
// RUN: | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-msvc-device-defines-filtered
// RUN: diff %t/x86_64-msvc-host-defines-filtered %t/x86_64-msvc-device-defines-filtered

@ -1,22 +0,0 @@
// RUN: %clang_cc1 -verify %s
// RUN: %clang_cc1 -triple powerpc64-linux -verify %s
// RUN: %clang_cc1 -triple i686-windows-gnu -verify %s
// RUN: %clang_cc1 -triple x86_64-windows-gnu -verify %s
// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify %s
#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
_Float128 f;
_Float128 tiny = __FLT128_EPSILON__;
int g(int x, _Float128 *y) {
return x + *y;
}
// expected-no-diagnostics
#else
_Float128 f; // expected-error {{__float128 is not supported on this target}}
float tiny = __FLT128_EPSILON__; // expected-error{{use of undeclared identifier}}
int g(int x, _Float128 *y) { // expected-error {{__float128 is not supported on this target}}
return x + *y;
}
#endif // defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)

@ -2,8 +2,8 @@
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-constant-in-range-compare -DTEST -verify -x c++ %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-type-limit-compare -DTEST -verify %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-type-limit-compare -DTEST -verify -x c++ %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -DTEST -verify %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -DTEST -verify -x c++ %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -verify -x c++ %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify -x c++ %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s

@ -309,6 +309,17 @@ namespace dependent {
template int New(int);
}
namespace injected_class_name {
template<typename T = void> struct A {
A();
template<typename U> A(A<U>);
};
A<int> a;
A b = a;
using T = decltype(a);
using T = decltype(b);
}
#else
// expected-no-diagnostics

@ -21,3 +21,14 @@ struct C { char a[16]; };
static_assert(sizeof(my_union<A, B, C>) == 16, "");
static_assert(alignof(my_union<A, B, C>) == 8, "");
namespace PR35028 {
template<class X, int Alignment> struct alignas(X) alignas(long long) alignas(long double) alignas(Alignment) Aligned {
union {
long long align1;
long double align2;
char data[sizeof(X)];
};
};
Aligned<int, 1> a;
}

@ -16,3 +16,14 @@ namespace CompleteType {
constexpr int n = X<true>::value;
}
template <typename T> struct A {
static const int n;
static const int m;
constexpr int f() { return n; }
constexpr int g() { return n; }
};
template <typename T> constexpr int A<T>::n = sizeof(A) + sizeof(T);
template <typename T> inline constexpr int A<T>::m = sizeof(A) + sizeof(T);
static_assert(A<int>().f() == 5);
static_assert(A<int>().g() == 5);

@ -476,6 +476,8 @@ TEST_F(LexerTest, GetBeginningOfTokenWithEscapedNewLine) {
TEST_F(LexerTest, AvoidPastEndOfStringDereference) {
std::vector<Token> LexedTokens = Lex(" // \\\n");
EXPECT_TRUE(LexedTokens.empty());
EXPECT_TRUE(Lex("#include <\\\\").empty());
EXPECT_TRUE(Lex("#include <\\\\\n").empty());
}
TEST_F(LexerTest, StringizingRasString) {