[llvm-branch-commits] [clang] 85ee70e - Clang] Fix expansion of response files in -Wp after integrated-cc1 change

2020-01-23 Thread Hans Wennborg via llvm-branch-commits

Author: Alexandre Ganea
Date: 2020-01-23T18:17:22+01:00
New Revision: 85ee70e86456e3bcb3c706c404db497c5a448602

URL: 
https://github.com/llvm/llvm-project/commit/85ee70e86456e3bcb3c706c404db497c5a448602
DIFF: 
https://github.com/llvm/llvm-project/commit/85ee70e86456e3bcb3c706c404db497c5a448602.diff

LOG: Clang] Fix expansion of response files in -Wp after integrated-cc1 change

After rGb4a99a061f517e60985667e39519f60186cbb469, passing a response file such 
as -Wp,@a.rsp wasn't working anymore because .rsp expansion happens inside 
clang's main() function.

This patch adds response file expansion in the -cc1 tool.

Differential Revision: https://reviews.llvm.org/D73120

(cherry picked from commit 68d7f06092e56b17eb0cddf560a9d9fe8afb7dd8)

Added: 


Modified: 
clang/include/clang/Driver/Driver.h
clang/test/Driver/Wp-args.c
clang/tools/driver/driver.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index fd25663bd358..6c3feaba0568 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -208,7 +208,7 @@ class Driver {
   /// When the clangDriver lib is used through clang.exe, this provides a
   /// shortcut for executing the -cc1 command-line directly, in the same
   /// process.
-  typedef int (*CC1ToolFunc)(ArrayRef argv);
+  typedef int (*CC1ToolFunc)(SmallVectorImpl &ArgV);
   CC1ToolFunc CC1Main = nullptr;
 
 private:

diff  --git a/clang/test/Driver/Wp-args.c b/clang/test/Driver/Wp-args.c
index e01e2a2651f0..587b7b83e4ca 100644
--- a/clang/test/Driver/Wp-args.c
+++ b/clang/test/Driver/Wp-args.c
@@ -19,3 +19,13 @@
 // MMD: "-cc1"
 // MMD-NOT: -MMD
 // MMD: "-dependency-file" "Wp-args.d"
+
+// Ensure response files are properly expanded with -Wp
+// RUN: echo -DTEST > %t.rsp
+// RUN: %clang -Wp,@%t.rsp -E %s | FileCheck -check-prefix RSP %s
+
+#ifdef TEST
+void foo();
+#endif
+
+// RSP: foo()

diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 39f6c7f62be4..4457e40ff04b 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -241,8 +241,6 @@ static void getCLEnvVarOptions(std::string &EnvValue, 
llvm::StringSaver &Saver,
   *NumberSignPtr = '=';
 }
 
-static int ExecuteCC1Tool(ArrayRef argv);
-
 static void SetBackdoorDriverOutputsFromEnvVars(Driver &TheDriver) {
   // Handle CC_PRINT_OPTIONS and CC_PRINT_OPTIONS_FILE.
   TheDriver.CCPrintOptions = !!::getenv("CC_PRINT_OPTIONS");
@@ -313,21 +311,27 @@ static void SetInstallDir(SmallVectorImpl 
&argv,
 TheDriver.setInstalledDir(InstalledPathParent);
 }
 
-static int ExecuteCC1Tool(ArrayRef argv) {
+static int ExecuteCC1Tool(SmallVectorImpl &ArgV) {
   // If we call the cc1 tool from the clangDriver library (through
   // Driver::CC1Main), we need to clean up the options usage count. The options
   // are currently global, and they might have been used previously by the
   // driver.
   llvm::cl::ResetAllOptionOccurrences();
-  StringRef Tool = argv[1];
-  void *GetExecutablePathVP = (void *)(intptr_t) GetExecutablePath;
+
+  llvm::BumpPtrAllocator A;
+  llvm::StringSaver Saver(A);
+  llvm::cl::ExpandResponseFiles(Saver, &llvm::cl::TokenizeGNUCommandLine, ArgV,
+/*MarkEOLs=*/false);
+  StringRef Tool = ArgV[1];
+  void *GetExecutablePathVP = (void *)(intptr_t)GetExecutablePath;
   if (Tool == "-cc1")
-return cc1_main(argv.slice(2), argv[0], GetExecutablePathVP);
+return cc1_main(makeArrayRef(ArgV).slice(2), ArgV[0], GetExecutablePathVP);
   if (Tool == "-cc1as")
-return cc1as_main(argv.slice(2), argv[0], GetExecutablePathVP);
+return cc1as_main(makeArrayRef(ArgV).slice(2), ArgV[0],
+  GetExecutablePathVP);
   if (Tool == "-cc1gen-reproducer")
-return cc1gen_reproducer_main(argv.slice(2), argv[0], GetExecutablePathVP);
-
+return cc1gen_reproducer_main(makeArrayRef(ArgV).slice(2), ArgV[0],
+  GetExecutablePathVP);
   // Reject unknown tools.
   llvm::errs() << "error: unknown integrated tool '" << Tool << "'. "
<< "Valid tools include '-cc1' and '-cc1as'.\n";



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] a3982a5 - [test] Fix lld/test/ELF/riscv-pcrel-hilo-error.s after D73211

2020-01-23 Thread Hans Wennborg via llvm-branch-commits

Author: James Clarke
Date: 2020-01-23T18:27:38+01:00
New Revision: a3982a59ce34039f63fff35c6c0562cf6fd5c771

URL: 
https://github.com/llvm/llvm-project/commit/a3982a59ce34039f63fff35c6c0562cf6fd5c771
DIFF: 
https://github.com/llvm/llvm-project/commit/a3982a59ce34039f63fff35c6c0562cf6fd5c771.diff

LOG: [test] Fix lld/test/ELF/riscv-pcrel-hilo-error.s after D73211

(cherry picked from commit ddfe8751b16a1d57b0586fb48d1109c98234bc3f)

Added: 


Modified: 
lld/test/ELF/riscv-pcrel-hilo-error.s

Removed: 




diff  --git a/lld/test/ELF/riscv-pcrel-hilo-error.s 
b/lld/test/ELF/riscv-pcrel-hilo-error.s
index bfc205520bd8..1557ac77bb7e 100644
--- a/lld/test/ELF/riscv-pcrel-hilo-error.s
+++ b/lld/test/ELF/riscv-pcrel-hilo-error.s
@@ -4,4 +4,10 @@
 
 # CHECK: error: R_RISCV_PCREL_LO12 relocation points to an absolute symbol: 
external
 
+# We provide a dummy %pcrel_hi referred to by external to appease the
+# assembler, but make external weak so --defsym can still override it at link
+# time.
+.weak external
+external:
+auipc sp,%pcrel_hi(external)
 addi sp,sp,%pcrel_lo(external)



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 8634a82 - [RISCV] Fix evaluating %pcrel_lo against global and weak symbols

2020-01-23 Thread Hans Wennborg via llvm-branch-commits

Author: James Clarke
Date: 2020-01-23T18:27:29+01:00
New Revision: 8634a82910eba78279a69fcba0925d3a602a0563

URL: 
https://github.com/llvm/llvm-project/commit/8634a82910eba78279a69fcba0925d3a602a0563
DIFF: 
https://github.com/llvm/llvm-project/commit/8634a82910eba78279a69fcba0925d3a602a0563.diff

LOG: [RISCV] Fix evaluating %pcrel_lo against global and weak symbols

Summary:
Previously, we would erroneously turn %pcrel_lo(label), where label has
a %pcrel_hi against a weak symbol, into %pcrel_lo(label + offset), as
evaluatePCRelLo would believe the target independent logic was going to
fold it. Moreover, even if that were fixed, shouldForceRelocation lacks
an MCAsmLayout and thus cannot evaluate the %pcrel_hi fixup to a value
and check the symbol, so we would then erroneously constant-fold the
%pcrel_lo whilst leaving the %pcrel_hi intact. After D72197, this same
sequence also occurs for symbols with global binding, which is triggered
in real-world code.

Instead, as discussed in D71978, we introduce a new FKF_IsTarget flag to
avoid these kinds of issues. All the resolution logic happens in one
place, with no coordination required between RISCAsmBackend and
RISCVMCExpr to ensure they implement the same logic twice. Although the
implementation of %pcrel_hi can be left as target independent, we make
it target dependent to ensure that they are handled identically to
%pcrel_lo, otherwise we risk one of them being constant folded but the
other being preserved. This also allows us to properly support fixup
pairs where the instructions are in different fragments.

Reviewers: asb, lenary, efriedma

Reviewed By: efriedma

Subscribers: arichardson, hiraditya, rbar, johnrusso, simoncook, sabuasal, 
niosHD, kito-cheng, shiva0217, MaskRay, zzheng, edward-jones, rogfer01, 
MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, 
s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73211

(cherry picked from commit 3f5976c97dbfefb4669abcf968bd79a9a64c18e0)

Added: 


Modified: 
llvm/include/llvm/MC/MCAsmBackend.h
llvm/include/llvm/MC/MCFixupKindInfo.h
llvm/lib/MC/MCAssembler.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h
llvm/test/MC/RISCV/pcrel-fixups.s
llvm/test/MC/RISCV/pcrel-lo12-invalid.s
llvm/test/MC/RISCV/rv32i-aliases-valid.s
llvm/test/MC/RISCV/rv32i-valid.s
llvm/test/MC/RISCV/rv64i-aliases-valid.s

Removed: 




diff  --git a/llvm/include/llvm/MC/MCAsmBackend.h 
b/llvm/include/llvm/MC/MCAsmBackend.h
index ed7d5c7f01f4..bf41420f2a5a 100644
--- a/llvm/include/llvm/MC/MCAsmBackend.h
+++ b/llvm/include/llvm/MC/MCAsmBackend.h
@@ -108,6 +108,14 @@ class MCAsmBackend {
 return false;
   }
 
+  virtual bool evaluateTargetFixup(const MCAssembler &Asm,
+   const MCAsmLayout &Layout,
+   const MCFixup &Fixup, const MCFragment *DF,
+   const MCValue &Target, uint64_t &Value,
+   bool &WasForced) {
+llvm_unreachable("Need to implement hook if target has custom fixups");
+  }
+
   /// Apply the \p Value for given \p Fixup into the provided data fragment, at
   /// the offset specified by the fixup and following the fixup kind as
   /// appropriate. Errors (such as an out of range fixup value) should be

diff  --git a/llvm/include/llvm/MC/MCFixupKindInfo.h 
b/llvm/include/llvm/MC/MCFixupKindInfo.h
index 0ea34866db6a..0d57441ce0dc 100644
--- a/llvm/include/llvm/MC/MCFixupKindInfo.h
+++ b/llvm/include/llvm/MC/MCFixupKindInfo.h
@@ -19,7 +19,10 @@ struct MCFixupKindInfo {
 FKF_IsPCRel = (1 << 0),
 
 /// Should this fixup kind force a 4-byte aligned effective PC value?
-FKF_IsAlignedDownTo32Bits = (1 << 1)
+FKF_IsAlignedDownTo32Bits = (1 << 1),
+
+/// Should this fixup be evaluated in a target dependent manner?
+FKF_IsTarget = (1 << 2)
   };
 
   /// A target specific name for the fixup kind. The names will be unique for

diff  --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index b30137aafb8d..75ec27975564 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -217,6 +217,13 @@ bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
   }
 
   assert(getBackendPtr() && "Expected assembler backend");
+  bool IsTarget = getBackendPtr()->getFixupKindInfo(Fixup.getKind()).Flags &
+  MCFixupKindInfo::FKF_IsTarget;
+
+  if (IsTarget)
+return getBackend().evaluateTargetFixup(*this, Layout, Fixup, DF, Target,
+Value, WasForced);
+
   bool IsPCRel = getBackendPtr()->getFixupKindInfo(

[llvm-branch-commits] [clang] 318677e - [Sema] Avoid Wrange-loop-analysis false positives

2020-01-23 Thread Hans Wennborg via llvm-branch-commits

Author: Mark de Wever
Date: 2020-01-23T20:04:04+01:00
New Revision: 318677e78def0023d210a29f4b3cf648e02f9fdc

URL: 
https://github.com/llvm/llvm-project/commit/318677e78def0023d210a29f4b3cf648e02f9fdc
DIFF: 
https://github.com/llvm/llvm-project/commit/318677e78def0023d210a29f4b3cf648e02f9fdc.diff

LOG: [Sema] Avoid Wrange-loop-analysis false positives

When Wrange-loop-analysis issues a diagnostic on a dependent type in a
template the diagnostic may not be valid for all instantiations. Therefore
the diagnostic is suppressed during the instantiation. Non dependent types
still issue a diagnostic.

The same can happen when using macros. Therefore the diagnostic is
disabled for macros.

Fixes https://bugs.llvm.org/show_bug.cgi?id=44556

Differential Revision: https://reviews.llvm.org/D73007

(cherry picked from commit 41fcd17250fa0526e4b7fd2c7df7721b0f79b683)

Added: 


Modified: 
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/warn-range-loop-analysis.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index d6c3af9e84c8..ff6481006280 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -2838,6 +2838,9 @@ static void DiagnoseForRangeConstVariableCopies(Sema 
&SemaRef,
 ///Suggest "const foo &x" to prevent the copy.
 static void DiagnoseForRangeVariableCopies(Sema &SemaRef,
const CXXForRangeStmt *ForStmt) {
+  if (SemaRef.inTemplateInstantiation())
+return;
+
   if (SemaRef.Diags.isIgnored(diag::warn_for_range_const_reference_copy,
   ForStmt->getBeginLoc()) &&
   SemaRef.Diags.isIgnored(diag::warn_for_range_variable_always_copy,
@@ -2860,6 +2863,9 @@ static void DiagnoseForRangeVariableCopies(Sema &SemaRef,
   if (!InitExpr)
 return;
 
+  if (InitExpr->getExprLoc().isMacroID())
+return;
+
   if (VariableType->isReferenceType()) {
 DiagnoseForRangeReferenceVariableCopies(SemaRef, VD,
 
ForStmt->getRangeInit()->getType());

diff  --git a/clang/test/SemaCXX/warn-range-loop-analysis.cpp 
b/clang/test/SemaCXX/warn-range-loop-analysis.cpp
index 53b0ca288194..951844c953ef 100644
--- a/clang/test/SemaCXX/warn-range-loop-analysis.cpp
+++ b/clang/test/SemaCXX/warn-range-loop-analysis.cpp
@@ -454,3 +454,75 @@ void test10() {
   // expected-note@-2 {{'Bar'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:17-[[@LINE-3]]:18}:" "
 }
+
+template 
+void test_template_function() {
+  // In a template instantiation the diagnostics should not be emitted for
+  // loops with dependent types.
+  Container C;
+  for (const Bar &x : C) {}
+  // expected-warning@-1 {{always a copy}}
+  // expected-note@-2 {{'Bar'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:18-[[@LINE-3]]:19}:""
+
+  Container Dependent;
+  for (const T &x : Dependent) {}
+}
+template void test_template_function();
+
+template 
+struct test_template_struct {
+  static void static_member() {
+Container C;
+for (const Bar &x : C) {}
+// expected-warning@-1 {{always a copy}}
+// expected-note@-2 {{'Bar'}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:21}:""
+
+Container Dependent;
+for (const T &x : Dependent) {}
+  }
+
+  void member() {
+Container C;
+for (const Bar &x : C) {}
+// expected-warning@-1 {{always a copy}}
+// expected-note@-2 {{'Bar'}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:21}:""
+
+Container Dependent;
+for (const T &x : Dependent) {}
+  }
+};
+template struct test_template_struct;
+
+struct test_struct_with_templated_member {
+  void member() {
+Container C;
+for (const Bar &x : C) {}
+// expected-warning@-1 {{always a copy}}
+// expected-note@-2 {{'Bar'}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:21}:""
+  }
+
+  template 
+  void template_member() {
+Container C;
+for (const Bar &x : C) {}
+// expected-warning@-1 {{always a copy}}
+// expected-note@-2 {{'Bar'}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:21}:""
+
+Container Dependent;
+for (const T &x : Dependent) {}
+  }
+};
+template void test_struct_with_templated_member::template_member();
+
+#define TEST_MACRO\
+  void test_macro() { \
+Container C; \
+for (const Bar &x : C) {} \
+  }
+
+TEST_MACRO



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] b079266 - Revert "PR17164: Change clang's default behavior from -flax-vector-conversions=all to -flax-vector-conversions=integer."

2020-01-23 Thread Hans Wennborg via llvm-branch-commits

Author: Mitch Phillips
Date: 2020-01-23T20:13:31+01:00
New Revision: b079266dcb6d1ee6446d074ebd1d212a13ce0665

URL: 
https://github.com/llvm/llvm-project/commit/b079266dcb6d1ee6446d074ebd1d212a13ce0665
DIFF: 
https://github.com/llvm/llvm-project/commit/b079266dcb6d1ee6446d074ebd1d212a13ce0665.diff

LOG: Revert "PR17164: Change clang's default behavior from 
-flax-vector-conversions=all to -flax-vector-conversions=integer."

This patch broke the Sanitizer buildbots. Please see the commit's
differential revision for more information
(https://reviews.llvm.org/D67678).

This reverts commit b72a8c65e4e34779b6bc9e466203f553f5294486.

(cherry picked from commit edd4398f4cd33a305afbca76ac4e6590e9337f4d)

Added: 


Modified: 
clang/docs/CommandGuide/clang.rst
clang/include/clang/Basic/LangOptions.def
clang/test/Headers/altivec-header.c
clang/test/Headers/arm-neon-header.c
clang/test/Headers/x86-intrinsics-headers.c
clang/test/Headers/x86intrin-2.c
clang/test/Headers/x86intrin.c
clang/test/Sema/vector-assign.c
clang/test/Sema/vector-cast.c
clang/test/Sema/vector-ops.c

Removed: 




diff  --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index 6947450beb43..7b0873600fc3 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -278,18 +278,9 @@ Language Selection and Mode Options
  Make all string literals default to writable.  This disables uniquing of
  strings and other optimizations.
 
-.. option:: -flax-vector-conversions, -flax-vector-conversions=, 
-fno-lax-vector-conversions
+.. option:: -flax-vector-conversions
 
  Allow loose type checking rules for implicit vector conversions.
- Possible values of :
-
- - ``none``: allow no implicit conversions between vectors
- - ``integer``: allow implicit bitcasts between integer vectors of the same
-   overall bit-width
- - ``all``: allow implicit bitcasts between any vectors of the same
-   overall bit-width
-
-  defaults to ``integer`` if unspecified.
 
 .. option:: -fblocks
 

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 4bbe6ea26fba..068f206f4484 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -121,7 +121,7 @@ BENIGN_LANGOPT(PascalStrings, 1, 0, "Pascal string support")
 LANGOPT(WritableStrings   , 1, 0, "writable string support")
 LANGOPT(ConstStrings  , 1, 0, "const-qualified string support")
 ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
- LaxVectorConversionKind::Integer, "lax vector conversions")
+ LaxVectorConversionKind::All, "lax vector conversions")
 LANGOPT(ConvergentFunctions, 1, 1, "Assume convergent functions")
 LANGOPT(AltiVec   , 1, 0, "AltiVec-style vector initializers")
 LANGOPT(ZVector   , 1, 0, "System z vector extensions")

diff  --git a/clang/test/Headers/altivec-header.c 
b/clang/test/Headers/altivec-header.c
index aa85a33d26da..00e5f444de7c 100644
--- a/clang/test/Headers/altivec-header.c
+++ b/clang/test/Headers/altivec-header.c
@@ -1,5 +1,5 @@
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -flax-vector-conversions=none -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -flax-vector-conversions=all -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec 
-ffreestanding -emit-llvm -x c++ -o - %s | FileCheck %s
 
 #include 

diff  --git a/clang/test/Headers/arm-neon-header.c 
b/clang/test/Headers/arm-neon-header.c
index 8626a883fdf3..f6362886010a 100644
--- a/clang/test/Headers/arm-neon-header.c
+++ b/clang/test/Headers/arm-neon-header.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -flax-vector-conversions=all -Wvector-conversions -ffreestanding 
%s
+// RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -Wvector-conversions -ffreestanding %s
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -flax-vector-conversions=none -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 
-fsyntax-only -Wvector-conversions -ffreestanding %s
 

diff  --git a/clang/test/Headers/x86-intrinsics-headers.c 
b/clang/test/Headers/x86-intrinsics-headers.c
index 2efd3505bca6..59ca354e1160 100644
--- a/clang/test/Headers/x86-intrinsics-headers.c
+++ b/clang/test/Headers/x86-intrinsics-headers.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -ffreestanding -flax-vector-conversions=all %s
+// RUN: %clang_cc1 -fsyntax-only -ffr

Re: [llvm-branch-commits] [llvm] 138451c - [StackColoring] Remap FixedStackPseudoSourceValue frame index referenced by MachineMemOperand

2020-01-23 Thread Fāng-ruì Sòng via llvm-branch-commits
Sorry. I will check with you next time:)

On Wed, Jan 22, 2020 at 8:38 AM Hans Wennborg  wrote:
>
> Thanks! But please check with me before pushing to the release branch.
>
> On Tue, Jan 21, 2020 at 12:22 PM Fangrui Song via llvm-branch-commits
>  wrote:
> >
> >
> > Author: Fangrui Song
> > Date: 2020-01-21T12:14:27-08:00
> > New Revision: 138451c771abe013b7b99650faeb7ae6010f7a8d
> >
> > URL: 
> > https://github.com/llvm/llvm-project/commit/138451c771abe013b7b99650faeb7ae6010f7a8d
> > DIFF: 
> > https://github.com/llvm/llvm-project/commit/138451c771abe013b7b99650faeb7ae6010f7a8d.diff
> >
> > LOG: [StackColoring] Remap FixedStackPseudoSourceValue frame index 
> > referenced by MachineMemOperand
> >
> > StackColoring::remapInstructions() remaps MachineOperand frame index (e.g. 
> > %stack.1 -> %stack.0)
> > but does not remap FixedStackPseudoSourceValue frame index (e.g. store 4 
> > into %stack.1.ap2.i.i)
> > referenced by MachineMemoryOperand.
> >
> > This can cause an assertion failure when LiveDebugValues references a dead 
> > stack object.
> >
> > It is difficult to craft a test case. -g, va_copy and stack-coloring are 
> > required.
> > I can only reproduce it on ppc32.
> >
> > (cherry picked from commit eaab1bf21e1d6803fd217fe6052537fc33b06837)
> > (cherry picked from commit 854f7be20a0cb1a95671a16d6cc8200107ee25f4)
> > (cherry picked from commit 7a8b0b1595e7dc878b48cf9bbaa652087a6895db)
> >
> > Added:
> > llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir
> >
> > Modified:
> > llvm/lib/CodeGen/StackColoring.cpp
> >
> > Removed:
> >
> >
> >
> > 
> > diff  --git a/llvm/lib/CodeGen/StackColoring.cpp 
> > b/llvm/lib/CodeGen/StackColoring.cpp
> > index b6e81116286f..40bc36c3030b 100644
> > --- a/llvm/lib/CodeGen/StackColoring.cpp
> > +++ b/llvm/lib/CodeGen/StackColoring.cpp
> > @@ -960,6 +960,7 @@ void StackColoring::remapInstructions(DenseMap > int> &SlotRemap) {
> >}
> >
> >// Remap all instructions to the new stack slots.
> > +  std::vector> 
> > SSRefs(MFI->getObjectIndexEnd());
> >for (MachineBasicBlock &BB : *MF)
> >  for (MachineInstr &I : BB) {
> >// Skip lifetime markers. We'll remove them soon.
> > @@ -1025,6 +1026,16 @@ void StackColoring::remapInstructions(DenseMap > int> &SlotRemap) {
> >SmallVector NewMMOs;
> >bool ReplaceMemOps = false;
> >for (MachineMemOperand *MMO : I.memoperands()) {
> > +// Collect MachineMemOperands which reference
> > +// FixedStackPseudoSourceValues with old frame indices.
> > +if (const auto *FSV = 
> > dyn_cast_or_null(
> > +MMO->getPseudoValue())) {
> > +  int FI = FSV->getFrameIndex();
> > +  auto To = SlotRemap.find(FI);
> > +  if (To != SlotRemap.end())
> > +SSRefs[FI].push_back(MMO);
> > +}
> > +
> >  // If this memory location can be a slot remapped here,
> >  // we remove AA information.
> >  bool MayHaveConflictingAAMD = false;
> > @@ -1062,6 +1073,14 @@ void StackColoring::remapInstructions(DenseMap > int> &SlotRemap) {
> >  I.setMemRefs(*MF, NewMMOs);
> >  }
> >
> > +  // Rewrite MachineMemOperands that reference old frame indices.
> > +  for (auto E : enumerate(SSRefs)) {
> > +const PseudoSourceValue *NewSV =
> > +MF->getPSVManager().getFixedStack(SlotRemap[E.index()]);
> > +for (MachineMemOperand *Ref : E.value())
> > +  Ref->setValue(NewSV);
> > +  }
> > +
> >// Update the location of C++ catch objects for the MSVC personality 
> > routine.
> >if (WinEHFuncInfo *EHInfo = MF->getWinEHFuncInfo())
> >  for (WinEHTryBlockMapEntry &TBME : EHInfo->TryBlockMap)
> >
> > diff  --git a/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir 
> > b/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir
> > new file mode 100644
> > index ..0085369e1978
> > --- /dev/null
> > +++ b/llvm/test/CodeGen/PowerPC/stack-coloring-vararg.mir
> > @@ -0,0 +1,171 @@
> > +# RUN: llc -run-pass=stack-coloring %s -o - | FileCheck %s
> > +
> > +## Test %stack.1 is merged into %stack.0 and there is no MemoryMemOperand
> > +## referencing %stack.1. This regression test is sensitive to the 
> > StackColoring
> > +## algorithm. Please adjust or delete this test if the merging strategy
> > +## changes.
> > +
> > +# CHECK:{{^}}stack:
> > +# CHECK-NEXT: - { id: 0,
> > +# CHECK-NOT:  - { id: 1,
> > +# CHECK:  - { id: 2,
> > +# CHECK-NOT: %stack.1
> > +
> > +--- |
> > +  ; ModuleID = ''
> > +  source_filename = ""
> > +  target datalayout = "E-m:e-p:32:32-i64:64-n32"
> > +  target triple = "powerpc-unknown-freebsd13.0"
> > +
> > +  %struct.__va_list_tag = type { i8, i8, i16, i8*, i8* }
> > +  ; Function Attrs: argmemonly nounwind willreturn
> > +  declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #0
> > +  define dso_local void @atf_tc_fail_nonfatal(i8* %fmt, ...) !dbg !3 {
> >

[llvm-branch-commits] [clang] ed63454 - Update documentation and release notes to match the state of

2020-01-23 Thread Richard Smith via llvm-branch-commits

Author: Richard Smith
Date: 2020-01-23T12:26:43-08:00
New Revision: ed63454d984f2262ce332b9b15d49917be3eac98

URL: 
https://github.com/llvm/llvm-project/commit/ed63454d984f2262ce332b9b15d49917be3eac98
DIFF: 
https://github.com/llvm/llvm-project/commit/ed63454d984f2262ce332b9b15d49917be3eac98.diff

LOG: Update documentation and release notes to match the state of
-flax-vector-conversions on the Clang 10 release branch.

Added: 


Modified: 
clang/docs/CommandGuide/clang.rst
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/CommandGuide/clang.rst 
b/clang/docs/CommandGuide/clang.rst
index 7b0873600fc3..6947450beb43 100644
--- a/clang/docs/CommandGuide/clang.rst
+++ b/clang/docs/CommandGuide/clang.rst
@@ -278,9 +278,18 @@ Language Selection and Mode Options
  Make all string literals default to writable.  This disables uniquing of
  strings and other optimizations.
 
-.. option:: -flax-vector-conversions
+.. option:: -flax-vector-conversions, -flax-vector-conversions=, 
-fno-lax-vector-conversions
 
  Allow loose type checking rules for implicit vector conversions.
+ Possible values of :
+
+ - ``none``: allow no implicit conversions between vectors
+ - ``integer``: allow implicit bitcasts between integer vectors of the same
+   overall bit-width
+ - ``all``: allow implicit bitcasts between any vectors of the same
+   overall bit-width
+
+  defaults to ``integer`` if unspecified.
 
 .. option:: -fblocks
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8c48724e7c66..caa6abd4b791 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -102,14 +102,13 @@ Non-comprehensive list of changes in this release
   the found gcc installation is older than 4.7.0. Add ``-fno-use-init-array`` 
to
   get the old behavior (``.ctors``).
 
-* Lax vector conversions involving floating-point vectors have been disabled
-  by default, and can no longer be enabled with ``-flax-vector-conversions``.
-  This matches the behavior of these flags in GCC, but code relying on implicit
-  vector bitcasts between integer and floating-point types that used to compile
-  with older versions of Clang is no longer accepted by default in Clang 10.
-  The old behavior can be restored with ``-flax-vector-conversions=all``.
-  In a future release of Clang, we intend to change the default to
-  ``-fno-lax-vector-conversions``.
+* The behavior of the flag ``-flax-vector-conversions`` has been modified to
+  more closely match GCC, as described below. In Clang 10 onwards, command 
lines
+  specifying this flag do not permit implicit vector bitcasts between integer
+  vectors and floating-point vectors. Such conversions are still permitted by
+  default, however, and the default can be explicitly requested with the
+  Clang-specific flag ``-flax-vector-conversions=all``. In a future release of
+  Clang, we intend to change the default to ``-fno-lax-vector-conversions``.
 
 New Compiler Flags
 --
@@ -142,19 +141,21 @@ Modified Compiler Flags
   to the ``-march`` flag, overriding the target provided by ``-triple``.
 
 - ``-flax-vector-conversions`` has been split into three 
diff erent levels of
-  laxness:
+  laxness, and has been updated to match the GCC semantics:
 
-  - ``-flax-vector-conversions=all``: This is Clang's historical default, and
+  - ``-flax-vector-conversions=all``: This is Clang's current default, and
 permits implicit vector conversions (performed as bitcasts) between any
 two vector types of the same overall bit-width.
+Former synonym: ``-flax-vector-conversions`` (Clang <= 9).
 
-  - ``-flax-vector-conversions=integer``: This is Clang's current default,
-and permits implicit vector conversions (performed as bitcasts) between
-any two integer vector types of the same overall bit-width.
-Synonym: ``-flax-vector-conversions``.
+  - ``-flax-vector-conversions=integer``: This permits implicit vector
+conversions (performed as bitcasts) between any two integer vector types of
+the same overall bit-width.
+Synonym: ``-flax-vector-conversions`` (Clang >= 10).
 
   - ``-flax-vector-conversions=none``: Do not perform any implicit bitcasts
-between vector types. Synonym: ``-fno-lax-vector-conversions``.
+between vector types.
+Synonym: ``-fno-lax-vector-conversions``.
 
 New Pragmas in Clang
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] 26fd69a - [ELF] --no-dynamic-linker: don't emit undefined weak symbols to .dynsym

2020-01-23 Thread Hans Wennborg via llvm-branch-commits

Author: Fangrui Song
Date: 2020-01-23T23:06:55+01:00
New Revision: 26fd69afd9f3c6bb48b8a4e60578ea8ae919593f

URL: 
https://github.com/llvm/llvm-project/commit/26fd69afd9f3c6bb48b8a4e60578ea8ae919593f
DIFF: 
https://github.com/llvm/llvm-project/commit/26fd69afd9f3c6bb48b8a4e60578ea8ae919593f.diff

LOG: [ELF] --no-dynamic-linker: don't emit undefined weak symbols to .dynsym

I felt really sad to push this commit for my selfish purpose to make
glibc -static-pie build with lld. Some code constructs in glibc require
R_X86_64_GOTPCREL/R_X86_64_REX_GOTPCRELX referencing undefined weak to
be resolved to a GOT entry not relocated by R_X86_64_GLOB_DAT (GNU ld
behavior), e.g.

csu/libc-start.c
  if (__pthread_initialize_minimal != NULL)
__pthread_initialize_minimal ();

elf/dl-object.c
  void
  _dl_add_to_namespace_list (struct link_map *new, Lmid_t nsid)
  {
/* We modify the list of loaded objects.  */
__rtld_lock_lock_recursive (GL(dl_load_write_lock));

Emitting a GLOB_DAT will make the address equal &__ehdr_start (true
value) and cause elf/ldconfig to segfault. glibc really should move away
from weak references, which do not have defined semantics.

Temporarily special case --no-dynamic-linker.

(cherry picked from commit 0fbf28f7aae0ceb70071cac56de345e3ff04439c)

Added: 
lld/test/ELF/weak-undef-no-dynamic-linker.s

Modified: 
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/Symbols.cpp

Removed: 




diff  --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index 06ba88a83dd4..ef1edbcd1992 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -169,6 +169,7 @@ struct Configuration {
   bool mipsN32Abi = false;
   bool mmapOutputFile;
   bool nmagic;
+  bool noDynamicLinker = false;
   bool noinhibitExec;
   bool nostdlib;
   bool oFormatBinary;

diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 23da749d3078..25330832339c 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -602,8 +602,13 @@ static DiscardPolicy getDiscard(opt::InputArgList &args) {
 
 static StringRef getDynamicLinker(opt::InputArgList &args) {
   auto *arg = args.getLastArg(OPT_dynamic_linker, OPT_no_dynamic_linker);
-  if (!arg || arg->getOption().getID() == OPT_no_dynamic_linker)
+  if (!arg)
+return "";
+  if (arg->getOption().getID() == OPT_no_dynamic_linker) {
+// --no-dynamic-linker suppresses undefined weak symbols in .dynsym
+config->noDynamicLinker = true;
 return "";
+  }
   return arg->getValue();
 }
 

diff  --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index f0f6121009a5..0dcf34722d33 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -278,7 +278,11 @@ bool Symbol::includeInDynsym() const {
   if (computeBinding() == STB_LOCAL)
 return false;
   if (!isDefined() && !isCommon())
-return true;
+// This should unconditionally return true, unfortunately glibc -static-pie
+// expects undefined weak symbols not to exist in .dynsym, e.g.
+// __pthread_mutex_lock reference in _dl_add_to_namespace_list,
+// __pthread_initialize_minimal reference in csu/libc-start.c.
+return !(config->noDynamicLinker && isUndefWeak());
 
   return exportDynamic || inDynamicList;
 }

diff  --git a/lld/test/ELF/weak-undef-no-dynamic-linker.s 
b/lld/test/ELF/weak-undef-no-dynamic-linker.s
new file mode 100644
index ..fa6936e1ef39
--- /dev/null
+++ b/lld/test/ELF/weak-undef-no-dynamic-linker.s
@@ -0,0 +1,15 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: ld.lld -pie %t.o -o %t
+# RUN: llvm-readobj --dyn-syms %t | FileCheck %s
+# RUN: ld.lld -pie --no-dynamic-linker %t.o -o %t
+# RUN: llvm-readobj --dyn-syms %t | FileCheck --check-prefix=NO %s
+
+## With --no-dynamic-linker, don't emit undefined weak symbols to .dynsym .
+## This will suppress a relocation.
+# CHECK: Name: foo
+# NO-NOT: Name: foo
+
+.weak foo
+cmpq $0, foo@GOTPCREL(%rip)
+callq foo



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 2dd6b91 - [clang][IFS][test] Temporary work around for in-process cc1 ASAN issues.

2020-01-23 Thread Hans Wennborg via llvm-branch-commits

Author: Puyan Lotfi
Date: 2020-01-23T23:38:30+01:00
New Revision: 2dd6b91f35edb967f329f0437b53ea14395aa770

URL: 
https://github.com/llvm/llvm-project/commit/2dd6b91f35edb967f329f0437b53ea14395aa770
DIFF: 
https://github.com/llvm/llvm-project/commit/2dd6b91f35edb967f329f0437b53ea14395aa770.diff

LOG: [clang][IFS][test] Temporary work around for in-process cc1 ASAN issues.

When using in-process cc1, the Clang Interface Stubs pipeline setup
exposes an ASAN bug. I am still investigating this issue but want to
green the bots for now. I don't think this is a huge issue since the
Clang Interface Stubs Driver setup code is the only code path that sets
up such a pipeline (ie N cc1's for N c files followed by another N cc1's
for to generate stub files for the same N c files).

This issue is being discussed in https://reviews.llvm.org/D69825.
If a resolution is not found soon, a bugzilla filling will be in order.

(cherry picked from commit c38e42527b21acee8d01a016d5bfa2fb83202e29)

Added: 


Modified: 
clang/test/InterfaceStubs/driver-test.c
clang/test/InterfaceStubs/driver-test2.c

Removed: 




diff  --git a/clang/test/InterfaceStubs/driver-test.c 
b/clang/test/InterfaceStubs/driver-test.c
index 9ca5577a5c20..894d896bb219 100644
--- a/clang/test/InterfaceStubs/driver-test.c
+++ b/clang/test/InterfaceStubs/driver-test.c
@@ -1,8 +1,17 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: shell
 
+// NOTE: -fno-integrated-cc1 has been added to work around an ASAN failure
+//   caused by in-process cc1 invocation. Clang InterfaceStubs is not the
+//   culprit, but Clang Interface Stubs' Driver pipeline setup uncovers an
+//   existing ASAN issue when invoking multiple normal cc1 jobs along with
+//   multiple Clang Interface Stubs cc1 jobs together.
+//   There is currently a discussion of this going on at:
+// https://reviews.llvm.org/D69825
 // RUN: mkdir -p %t; cd %t
-// RUN: %clang -target x86_64-unknown-linux-gnu -x c -S -emit-interface-stubs 
%s %S/object.c %S/weak.cpp && \
+// RUN: %clang -target x86_64-unknown-linux-gnu -x c -S \
+// RUN:   -fno-integrated-cc1 \
+// RUN: -emit-interface-stubs %s %S/object.c %S/weak.cpp && \
 // RUN: llvm-nm %t/a.out.ifso 2>&1 | FileCheck --check-prefix=CHECK-IFS %s
 
 // CHECK-IFS-DAG: data

diff  --git a/clang/test/InterfaceStubs/driver-test2.c 
b/clang/test/InterfaceStubs/driver-test2.c
index c3a3b31b212d..905b27922264 100644
--- a/clang/test/InterfaceStubs/driver-test2.c
+++ b/clang/test/InterfaceStubs/driver-test2.c
@@ -1,10 +1,19 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: shell
 
+// NOTE: -fno-integrated-cc1 has been added to work around an ASAN failure
+//   caused by in-process cc1 invocation. Clang InterfaceStubs is not the
+//   culprit, but Clang Interface Stubs' Driver pipeline setup uncovers an
+//   existing ASAN issue when invoking multiple normal cc1 jobs along with
+//   multiple Clang Interface Stubs cc1 jobs together.
+//   There is currently a discussion of this going on at:
+// https://reviews.llvm.org/D69825
 // RUN: mkdir -p %t; cd %t
 // RUN: %clang -target x86_64-unknown-linux-gnu -c -emit-interface-stubs \
+// RUN:   -fno-integrated-cc1 \
 // RUN:   %s %S/object.c %S/weak.cpp
 // RUN: %clang -emit-interface-stubs -emit-merged-ifs \
+// RUN:   -fno-integrated-cc1 \
 // RUN:   %t/driver-test2.o %t/object.o %t/weak.o -S -o - 2>&1 | FileCheck %s
 
 // CHECK-DAG: data



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 57f70e3 - [Concepts] Fix ConceptSpecializationExpr profiling crash

2020-01-23 Thread Saar Raz via llvm-branch-commits

Author: Saar Raz
Date: 2020-01-24T02:28:20+02:00
New Revision: 57f70e387e362d988937b6627461d781ecf09e50

URL: 
https://github.com/llvm/llvm-project/commit/57f70e387e362d988937b6627461d781ecf09e50
DIFF: 
https://github.com/llvm/llvm-project/commit/57f70e387e362d988937b6627461d781ecf09e50.diff

LOG: [Concepts] Fix ConceptSpecializationExpr profiling crash

ConceptSpecializationExprs (CSEs) were being created with nullptr
TemplateArgsAsWritten during TemplateTemplateParmDecl canonicalization, and
we were relying on them during profiling which caused sporadic crashes
in test/CXX/.../temp.arg.template/p3-2a.cpp introduced in D44352.

Change profiling of CSEs to instead rely on the actual converted template
arguments and concept named.

(cherry picked from commit 8a3446746098ba29348bb8f85357dd0b466a6d6e)

Added: 


Modified: 
clang/lib/AST/StmtProfile.cpp

Removed: 




diff  --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 2aa5106e90fa..c0b0f3b0b064 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -1335,9 +1335,9 @@ void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
 void StmtProfiler::VisitConceptSpecializationExpr(
const ConceptSpecializationExpr *S) 
{
   VisitExpr(S);
-  VisitDecl(S->getFoundDecl());
-  VisitTemplateArguments(S->getTemplateArgsAsWritten()->getTemplateArgs(),
- S->getTemplateArgsAsWritten()->NumTemplateArgs);
+  VisitDecl(S->getNamedConcept());
+  for (const TemplateArgument &Arg : S->getTemplateArguments())
+VisitTemplateArgument(Arg);
 }
 
 static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] ab514b9 - Remove redundant CXXScopeSpec from TemplateIdAnnotation.

2020-01-23 Thread Saar Raz via llvm-branch-commits

Author: Richard Smith
Date: 2020-01-24T02:28:20+02:00
New Revision: ab514b91196345ba4c61026e4997871e85ddd97d

URL: 
https://github.com/llvm/llvm-project/commit/ab514b91196345ba4c61026e4997871e85ddd97d
DIFF: 
https://github.com/llvm/llvm-project/commit/ab514b91196345ba4c61026e4997871e85ddd97d.diff

LOG: Remove redundant CXXScopeSpec from TemplateIdAnnotation.

A TemplateIdAnnotation represents only a template-id, not a
nested-name-specifier plus a template-id. Don't make a redundant copy of
the CXXScopeSpec and store it on the template-id annotation.

This slightly improves error recovery by more properly handling the case
where we would form an invalid CXXScopeSpec while parsing a typename
specifier, instead of accidentally putting the token stream into a
broken "annot_template_id with a scope specifier, but with no preceding
annot_cxxscope token" state.

(cherry picked from commit a42fd84cff265b7e9faa3fe42885ee171393e4db)

Added: 


Modified: 
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/ParsedTemplate.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseTemplate.cpp
clang/lib/Parse/ParseTentative.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp
clang/test/Parser/cxx-decl.cpp
clang/test/SemaTemplate/ms-delayed-default-template-args.cpp
clang/test/SemaTemplate/rdar9173693.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index b7bed4713992..182024ea5108 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -3079,13 +3079,13 @@ class Parser : public CodeCompletionHandler {
SourceLocation &RAngleLoc);
   bool ParseTemplateParameterList(unsigned Depth,
   SmallVectorImpl &TemplateParams);
-  bool isStartOfTemplateTypeParameter(bool &ScopeError);
+  TPResult isStartOfTemplateTypeParameter();
   NamedDecl *ParseTemplateParameter(unsigned Depth, unsigned Position);
   NamedDecl *ParseTypeParameter(unsigned Depth, unsigned Position);
   NamedDecl *ParseTemplateTemplateParameter(unsigned Depth, unsigned Position);
   NamedDecl *ParseNonTypeTemplateParameter(unsigned Depth, unsigned Position);
   bool isTypeConstraintAnnotation();
-  bool TryAnnotateTypeConstraint(CXXScopeSpec &SS);
+  bool TryAnnotateTypeConstraint();
   NamedDecl *
   ParseConstrainedTemplateTypeParameter(unsigned Depth, unsigned Position);
   void DiagnoseMisplacedEllipsis(SourceLocation EllipsisLoc,
@@ -3111,7 +3111,8 @@ class Parser : public CodeCompletionHandler {
UnqualifiedId &TemplateName,
bool AllowTypeAnnotation = true,
bool TypeConstraint = false);
-  void AnnotateTemplateIdTokenAsType(bool IsClassName = false);
+  void AnnotateTemplateIdTokenAsType(CXXScopeSpec &SS,
+ bool IsClassName = false);
   bool ParseTemplateArgumentList(TemplateArgList &TemplateArgs);
   ParsedTemplateArgument ParseTemplateTemplateArgument();
   ParsedTemplateArgument ParseTemplateArgument();

diff  --git a/clang/include/clang/Sema/ParsedTemplate.h 
b/clang/include/clang/Sema/ParsedTemplate.h
index 0874905b38a5..82d00494b0d6 100644
--- a/clang/include/clang/Sema/ParsedTemplate.h
+++ b/clang/include/clang/Sema/ParsedTemplate.h
@@ -139,9 +139,8 @@ namespace clang {
   /// Information about a template-id annotation
   /// token.
   ///
-  /// A template-id annotation token contains the template declaration,
-  /// template arguments, whether those template arguments were types,
-  /// expressions, or template names, and the source locations for important
+  /// A template-id annotation token contains the template name,
+  /// template arguments, and the source locations for important
   /// tokens. All of the information about template arguments is allocated
   /// directly after this structure.
   /// A template-id annotation token can also be generated by a type-constraint
@@ -152,9 +151,6 @@ namespace clang {
   : private llvm::TrailingObjects {
 friend TrailingObjects;
-/// The nested-name-specifier that precedes the template name.
-CXXScopeSpec SS;
-
 /// TemplateKWLoc - The location of the template keyword.
 /// For e.g. typename T::template Y
 SourceLocation TemplateKWLoc;
@@ -195,16 +191,15 @@ namespace clang {
 /// Creates a new TemplateIdAnnotation with NumArgs arguments and
 /// appends it to List.
 static TemplateIdAnnotation *
-Create(CXXScopeSpec SS, SourceLocation TemplateKWLoc,
-   SourceLocation TemplateNameLoc, Id