Skip to content

Commit

Permalink
Merge from 'master' to 'sycl-web' (intel#54)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in clang/include/clang/Basic/DiagnosticGroups.td
  • Loading branch information
bader committed Nov 18, 2019
2 parents e24ca96 + 2d739f9 commit 9259d27
Show file tree
Hide file tree
Showing 178 changed files with 3,663 additions and 1,388 deletions.
Empty file.
Empty file modified clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.h
100755 → 100644
Empty file.
5 changes: 3 additions & 2 deletions clang-tools-extra/clangd/Preamble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ buildPreamble(PathRef FileName, CompilerInvocation &CI,
compileCommandsAreEqual(Inputs.CompileCommand, OldCompileCommand) &&
OldPreamble->Preamble.CanReuse(CI, ContentsBuffer.get(), Bounds,
Inputs.FS.get())) {
vlog("Reusing preamble for file {0}", llvm::Twine(FileName));
vlog("Reusing preamble for {0}", FileName);
return OldPreamble;
}
vlog("Preamble for file {0} cannot be reused. Attempting to rebuild it.",
vlog(OldPreamble ? "Rebuilding invalidated preamble for {0}"
: "Building first preamble for {0}",
FileName);

trace::Span Tracer("BuildPreamble");
Expand Down
21 changes: 21 additions & 0 deletions clang/docs/ClangCommandLineReference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2430,10 +2430,31 @@ Enable XNACK (AMDGPU only)

ARM
---

.. option:: -ffixed-r6

Reserve the r6 register (ARM only)

.. option:: -ffixed-r7

Reserve the r7 register (ARM only)

.. option:: -ffixed-r8

Reserve the r8 register (ARM only)

.. option:: -ffixed-r9

Reserve the r9 register (ARM only)

.. option:: -ffixed-r10

Reserve the r10 register (ARM only)

.. option:: -ffixed-r11

Reserve the r11 register (ARM only)

.. option:: -mexecute-only, -mno-execute-only, -mpure-code

Disallow generation of data access to code sections (ARM only)
Expand Down
18 changes: 18 additions & 0 deletions clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,10 @@ the configuration (without a prefix: ``Auto``).
f(MyMap[{composite, key}]); f(MyMap[{ composite, key }]);
new int[3]{1, 2, 3}; new int[3]{ 1, 2, 3 };

**DeriveLineEnding** (``bool``)
Analyze the formatted file for the most used line ending (``\r\n``
or ``\n``). ``UseCRLF`` is only used as a fallback if none can be derived.

**DerivePointerAlignment** (``bool``)
If ``true``, analyze the formatted file for the most common
alignment of ``&`` and ``*``.
Expand Down Expand Up @@ -2257,6 +2261,16 @@ the configuration (without a prefix: ``Auto``).
true: false:
for (auto v : values) {} vs. for(auto v: values) {}

**SpaceBeforeSquareBrackets** (``bool``)
If ``true``, spaces will be before ``[``.
Lambdas will not be affected. Only the first ``[`` will get a space added.

.. code-block:: c++

true: false:
int a [5]; vs. int a[5];
int a [5][5]; vs. int a[5][5];

**SpaceInEmptyBlock** (``bool``)
If ``true``, spaces will be inserted into ``{}``.

Expand Down Expand Up @@ -2409,6 +2423,10 @@ the configuration (without a prefix: ``Auto``).
For example: OpenSSL STACK_OF, BSD LIST_ENTRY.

**UseCRLF** (``bool``)
Use ``\r\n`` instead of ``\n`` for line breaks.
Also used as fallback if ``DeriveLineEnding`` is true.

**UseTab** (``UseTabStyle``)
The way to use tab characters in the resulting file.

Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ def warn_drv_msp430_hwmult_no_device : Warning<"no MCU device specified, but "
"specify a MSP430 device, or -mhwmult to set hardware multiply type "
"explicitly.">, InGroup<InvalidCommandLineArgument>;

// Frame pointer reservation.
def err_reserved_frame_pointer : Error<
"'%0' has been specified but '%1' is used as the frame pointer for this target">;

def warn_drv_libstdcxx_not_found : Warning<
"include path for libstdc++ headers not found; pass '-stdlib=libc++' on the "
"command line to use the libc++ standard library instead">,
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticGroups.td
Original file line number Diff line number Diff line change
Expand Up @@ -1120,3 +1120,6 @@ def CTADMaybeUnsupported : DiagGroup<"ctad-maybe-unsupported">;
def FortifySource : DiagGroup<"fortify-source">;

def IntelFPGA : DiagGroup<"intel-fpga">;

// Register reservation.
def FixedRegs : DiagGroup<"fixed-registers">;
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -7744,6 +7744,8 @@ let CategoryName = "Inline Assembly Issue" in {
def err_asm_unknown_register_name : Error<"unknown register name '%0' in asm">;
def err_asm_invalid_global_var_reg : Error<"register '%0' unsuitable for "
"global register variables on this target">;
def err_asm_missing_fixed_reg_opt : Error<"-ffixed-%0 is required for "
"global named register variable declaration">;
def err_asm_register_size_mismatch : Error<"size of register '%0' does not "
"match variable size">;
def err_asm_bad_register_type : Error<"bad type for named register variable">;
Expand Down
6 changes: 6 additions & 0 deletions clang/include/clang/Basic/TargetInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,12 @@ class TargetInfo : public virtual TransferrableTargetInfo,
return true;
}

/// Check if the register is reserved globally
///
/// This function returns true if the register passed in RegName is reserved
/// using the corresponding -ffixed-RegName option.
virtual bool isRegisterReservedGlobally(StringRef) const { return true; }

// validateOutputConstraint, validateInputConstraint - Checks that
// a constraint is valid and provides information about it.
// FIXME: These should return a real error instead of just true/false.
Expand Down
3 changes: 2 additions & 1 deletion clang/include/clang/Driver/Distro.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Distro {
UbuntuCosmic,
UbuntuDisco,
UbuntuEoan,
UbuntuFocal,
UnknownDistro
};

Expand Down Expand Up @@ -118,7 +119,7 @@ class Distro {
}

bool IsUbuntu() const {
return DistroVal >= UbuntuHardy && DistroVal <= UbuntuEoan;
return DistroVal >= UbuntuHardy && DistroVal <= UbuntuFocal;
}

bool IsAlpineLinux() const {
Expand Down
5 changes: 3 additions & 2 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2316,8 +2316,9 @@ def mrestrict_it: Flag<["-"], "mrestrict-it">, Group<m_arm_Features_Group>,
def mno_restrict_it: Flag<["-"], "mno-restrict-it">, Group<m_arm_Features_Group>,
HelpText<"Allow generation of deprecated IT blocks for ARMv8. It is off by default for ARMv8 Thumb mode">;
def marm : Flag<["-"], "marm">, Alias<mno_thumb>;
def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group<m_arm_Features_Group>,
HelpText<"Reserve the r9 register (ARM only)">;
foreach i = {6-11} in
def ffixed_r#i : Flag<["-"], "ffixed-r"#i>, Group<m_arm_Features_Group>,
HelpText<"Reserve the r"#i#" register (ARM only)">;
def mno_movt : Flag<["-"], "mno-movt">, Group<m_arm_Features_Group>,
HelpText<"Disallow use of movt/movw pairs (ARM only)">;
def mcrc : Flag<["-"], "mcrc">, Group<m_Group>,
Expand Down
13 changes: 11 additions & 2 deletions clang/include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,15 @@ struct FormatStyle {
/// \endcode
bool SpacesInSquareBrackets;

/// If ``true``, spaces will be before ``[``.
/// Lambdas will not be affected. Only the first ``[`` will get a space added.
/// \code
/// true: false:
/// int a [5]; vs. int a[5];
/// int a [5][5]; vs. int a[5][5];
/// \endcode
bool SpaceBeforeSquareBrackets;

/// Supported language standards for parsing and formatting C++ constructs.
/// \code
/// Latest: vector<set<int>>
Expand Down Expand Up @@ -2150,10 +2159,10 @@ struct FormatStyle {
SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses &&
SpacesInParentheses == R.SpacesInParentheses &&
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets &&
Standard == R.Standard && TabWidth == R.TabWidth &&
StatementMacros == R.StatementMacros && UseTab == R.UseTab &&
UseCRLF == R.UseCRLF &&
TypenameMacros == R.TypenameMacros;
UseCRLF == R.UseCRLF && TypenameMacros == R.TypenameMacros;
}

llvm::Optional<FormatStyle> GetLanguageStyle(LanguageKind Language) const;
Expand Down
Empty file.
32 changes: 32 additions & 0 deletions clang/lib/Basic/Targets/ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,38 @@ ArrayRef<TargetInfo::GCCRegAlias> ARMTargetInfo::getGCCRegAliases() const {
return llvm::makeArrayRef(GCCRegAliases);
}

bool ARMTargetInfo::validateGlobalRegisterVariable(
StringRef RegName, unsigned RegSize, bool &HasSizeMismatch) const {
bool isValid = llvm::StringSwitch<bool>(RegName)
.Case("r6", true)
.Case("r7", true)
.Case("r8", true)
.Case("r9", true)
.Case("r10", true)
.Case("r11", true)
.Case("sp", true)
.Default(false);
HasSizeMismatch = false;
return isValid;
}

bool ARMTargetInfo::isRegisterReservedGlobally(StringRef RegName) const {
// The "sp" register does not have a -ffixed-sp option,
// so reserve it unconditionally.
if (RegName.equals("sp"))
return true;

// reserve rN (N:6-11) registers only if the corresponding
// +reserve-rN feature is found
const std::vector<std::string> &Features = getTargetOpts().Features;
const std::string SearchFeature = "+reserve-" + RegName.str();
for (const std::string &Feature : Features) {
if (Feature.compare(SearchFeature) == 0)
return true;
}
return false;
}

bool ARMTargetInfo::validateAsmConstraint(
const char *&Name, TargetInfo::ConstraintInfo &Info) const {
switch (*Name) {
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Basic/Targets/ARM.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public TargetInfo {

ArrayRef<const char *> getGCCRegNames() const override;
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize,
bool &HasSizeMismatch) const override;
bool isRegisterReservedGlobally(StringRef RegName) const override;
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &Info) const override;
std::string convertConstraint(const char *&Constraint) const override;
Expand Down
13 changes: 8 additions & 5 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,8 @@ llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty,
SourceLocation Loc = AliasDecl->getLocation();
return DBuilder.createTypedef(Src, OS.str(), getOrCreateFile(Loc),
getLineNumber(Loc),
getDeclContextDescriptor(AliasDecl));
getDeclContextDescriptor(AliasDecl),
/* Alignment */ None);
}

llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
Expand All @@ -1143,9 +1144,10 @@ llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
SourceLocation Loc = Ty->getDecl()->getLocation();

// Typedefs are derived from some other type.
return DBuilder.createTypedef(Underlying, Ty->getDecl()->getName(),
getOrCreateFile(Loc), getLineNumber(Loc),
getDeclContextDescriptor(Ty->getDecl()));
return DBuilder.createTypedef(
Underlying, Ty->getDecl()->getName(), getOrCreateFile(Loc),
getLineNumber(Loc), getDeclContextDescriptor(Ty->getDecl()),
getDeclAlignIfRequired(Ty->getDecl(), CGM.getContext()));
}

static unsigned getDwarfCC(CallingConv CC) {
Expand Down Expand Up @@ -2324,7 +2326,8 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCTypeParamType *Ty,
return DBuilder.createTypedef(
getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
getDeclContextDescriptor(Ty->getDecl()));
getDeclContextDescriptor(Ty->getDecl()),
/* Alignment */ None);
}

/// \return true if Getter has the default name for the property PD.
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/Distro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
.Case("cosmic", Distro::UbuntuCosmic)
.Case("disco", Distro::UbuntuDisco)
.Case("eoan", Distro::UbuntuEoan)
.Case("focal", Distro::UbuntuFocal)
.Default(Distro::UnknownDistro);
if (Version != Distro::UnknownDistro)
return Version;
Expand Down
38 changes: 33 additions & 5 deletions clang/lib/Driver/ToolChains/Arch/ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,39 @@ void arm::getARMTargetFeatures(const ToolChain &TC,
Features.push_back("+strict-align");
}

// llvm does not support reserving registers in general. There is support
// for reserving r9 on ARM though (defined as a platform-specific register
// in ARM EABI).
if (Args.hasArg(options::OPT_ffixed_r9))
Features.push_back("+reserve-r9");
// Do not allow r9 reservation with -frwpi.
if (Args.hasArg(options::OPT_ffixed_r9) && Args.hasArg(options::OPT_frwpi)) {
Arg *A = Args.getLastArg(options::OPT_ffixed_r9);
Arg *B = Args.getLastArg(options::OPT_frwpi);
D.Diag(diag::err_opt_not_valid_with_opt)
<< A->getAsString(Args) << B->getAsString(Args);
}

// The compiler can still use a FP in certain circumstances,
// even when frame pointer elimination is enabled. Thus we should
// not allow to reserve a target's FP register.
const llvm::opt::OptSpecifier RestrictFPOpt =
(Triple.isOSDarwin() || (!Triple.isOSWindows() && Triple.isThumb()))
? options::OPT_ffixed_r7
: options::OPT_ffixed_r11;
if (Args.hasArg(RestrictFPOpt)) {
const std::string OptStr =
Args.getLastArg(RestrictFPOpt)->getAsString(Args);
const unsigned int SubStrIndex = strlen("ffixed-r");
D.Diag(diag::err_reserved_frame_pointer)
<< OptStr << OptStr.substr(SubStrIndex);
}

// Reservation of general purpose registers.
#define HANDLE_FFIXED_R(n) \
if (Args.hasArg(options::OPT_ffixed_r##n)) \
Features.push_back("+reserve-r" #n)
HANDLE_FFIXED_R(6);
HANDLE_FFIXED_R(7);
HANDLE_FFIXED_R(8);
HANDLE_FFIXED_R(9);
HANDLE_FFIXED_R(10);
HANDLE_FFIXED_R(11);

// The kext linker doesn't know how to deal with movw/movt.
if (KernelOrKext || Args.hasArg(options::OPT_mno_movt))
Expand Down
12 changes: 8 additions & 4 deletions clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,8 @@ template <> struct MappingTraits<FormatStyle> {
Style.SpacesInCStyleCastParentheses);
IO.mapOptional("SpacesInParentheses", Style.SpacesInParentheses);
IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
IO.mapOptional("SpaceBeforeSquareBrackets",
Style.SpaceBeforeSquareBrackets);
IO.mapOptional("Standard", Style.Standard);
IO.mapOptional("StatementMacros", Style.StatementMacros);
IO.mapOptional("TabWidth", Style.TabWidth);
Expand Down Expand Up @@ -813,6 +815,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true;
LLVMStyle.SpaceBeforeAssignmentOperators = true;
LLVMStyle.SpaceBeforeCpp11BracedList = false;
LLVMStyle.SpaceBeforeSquareBrackets = false;
LLVMStyle.SpacesInAngles = false;

LLVMStyle.PenaltyBreakAssignment = prec::Assignment;
Expand Down Expand Up @@ -1354,10 +1357,11 @@ class Formatter : public TokenAnalyzer {

WhitespaceManager Whitespaces(
Env.getSourceManager(), Style,
Style.DeriveLineEnding ?
inputUsesCRLF(Env.getSourceManager().getBufferData(Env.getFileID()),
Style.UseCRLF) :
Style.UseCRLF);
Style.DeriveLineEnding
? inputUsesCRLF(
Env.getSourceManager().getBufferData(Env.getFileID()),
Style.UseCRLF)
: Style.UseCRLF);
ContinuationIndenter Indenter(Style, Tokens.getKeywords(),
Env.getSourceManager(), Whitespaces, Encoding,
BinPackInconclusiveFunctions);
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2694,7 +2694,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
// Space between the type and the *
// operator void*(), operator char*(), operator Foo*() dependant
// on PointerAlignment style.
return (Style.PointerAlignment == FormatStyle::PAS_Right);
return (Style.PointerAlignment != FormatStyle::PAS_Left);
const auto SpaceRequiredForArrayInitializerLSquare =
[](const FormatToken &LSquareTok, const FormatStyle &Style) {
return Style.SpacesInContainerLiterals ||
Expand Down Expand Up @@ -2724,7 +2724,9 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
!Right.isOneOf(TT_ObjCMethodExpr, TT_LambdaLSquare,
TT_DesignatedInitializerLSquare,
TT_StructuredBindingLSquare, TT_AttributeSquare) &&
!Left.isOneOf(tok::numeric_constant, TT_DictLiteral))
!Left.isOneOf(tok::numeric_constant, TT_DictLiteral) &&
!(!Left.is(tok::r_square) && Style.SpaceBeforeSquareBrackets &&
Right.is(TT_ArraySubscriptLSquare)))
return false;
if (Left.is(tok::l_brace) && Right.is(tok::r_brace))
return !Left.Children.empty(); // No spaces in "{}".
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7017,6 +7017,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
Diag(E->getExprLoc(), diag::err_asm_invalid_global_var_reg) << Label;
else if (HasSizeMismatch)
Diag(E->getExprLoc(), diag::err_asm_register_size_mismatch) << Label;
else if (!TI.isRegisterReservedGlobally(Label))
Diag(E->getExprLoc(), diag::err_asm_missing_fixed_reg_opt) << Label;
}

if (!R->isIntegralType(Context) && !R->isPointerType()) {
Expand Down
Empty file modified clang/lib/StaticAnalyzer/Checkers/Yaml.h
100755 → 100644
Empty file.
14 changes: 14 additions & 0 deletions clang/test/CodeGenCXX/debug-info-template-align.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Test for debug info related to DW_AT_alignment attribute in the typedef operator
// Supported: -O0, standalone DI
// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple x86_64-linux-gnu %s -o - \
// RUN: -O0 -disable-llvm-passes \
// RUN: -debug-info-kind=standalone \
// RUN: | FileCheck %s

// CHECK: DIDerivedType(tag: DW_TAG_typedef, {{.*}}, align: 512

typedef char __attribute__((__aligned__(64))) alchar;

int main() {
alchar newChar;
}
Loading

0 comments on commit 9259d27

Please sign in to comment.