r304697 - Revert "[sanitizer-coverage] one more flavor of coverage: -fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting yet. (clang part)"

2017-06-05 Thread Renato Golin via cfe-commits
Author: rengolin
Date: Mon Jun  5 02:35:45 2017
New Revision: 304697

URL: http://llvm.org/viewvc/llvm-project?rev=304697&view=rev
Log:
Revert "[sanitizer-coverage] one more flavor of coverage: 
-fsanitize-coverage=inline-8bit-counters. Experimental so far, not documenting 
yet. (clang part)"

This reverts commit r304631, as it broke ARM/AArch64 bots for 2 days.

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/fsanitize-coverage.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=304697&r1=304696&r2=304697&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Jun  5 02:35:45 2017
@@ -293,9 +293,6 @@ def fsanitize_coverage_trace_gep
 def fsanitize_coverage_8bit_counters
 : Flag<["-"], "fsanitize-coverage-8bit-counters">,
   HelpText<"Enable frequency counters in sanitizer coverage">;
-def fsanitize_coverage_inline_8bit_counters
-: Flag<["-"], "fsanitize-coverage-inline-8bit-counters">,
-  HelpText<"Enable inline 8-bit counters in sanitizer coverage">;
 def fsanitize_coverage_trace_pc
 : Flag<["-"], "fsanitize-coverage-trace-pc">,
   HelpText<"Enable PC tracing in sanitizer coverage">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=304697&r1=304696&r2=304697&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Jun  5 02:35:45 2017
@@ -163,7 +163,6 @@ CODEGENOPT(SanitizeCoverageTracePC, 1, 0
   ///< in sanitizer coverage.
 CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0) ///< Enable PC tracing with 
guard
///< in sanitizer coverage.
-CODEGENOPT(SanitizeCoverageInline8bitCounters, 1, 0) ///< Use inline 8bit 
counters.
 CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
 CODEGENOPT(SanitizeStats , 1, 0) ///< Collect statistics for sanitizers.
 CODEGENOPT(SimplifyLibCalls  , 1, 1) ///< Set when -fbuiltin is enabled.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=304697&r1=304696&r2=304697&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Jun  5 02:35:45 2017
@@ -187,7 +187,6 @@ static void addSanitizerCoveragePass(con
   Opts.TracePC = CGOpts.SanitizeCoverageTracePC;
   Opts.TracePCGuard = CGOpts.SanitizeCoverageTracePCGuard;
   Opts.NoPrune = CGOpts.SanitizeCoverageNoPrune;
-  Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
   PM.add(createSanitizerCoverageModulePass(Opts));
 }
 

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=304697&r1=304696&r2=304697&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Mon Jun  5 02:35:45 2017
@@ -48,14 +48,13 @@ enum CoverageFeature {
   CoverageBB = 1 << 1,
   CoverageEdge = 1 << 2,
   CoverageIndirCall = 1 << 3,
-  CoverageTraceBB = 1 << 4,  // Deprecated.
+  CoverageTraceBB = 1 << 4,
   CoverageTraceCmp = 1 << 5,
   CoverageTraceDiv = 1 << 6,
   CoverageTraceGep = 1 << 7,
-  Coverage8bitCounters = 1 << 8,  // Deprecated.
+  Coverage8bitCounters = 1 << 8,
   CoverageTracePC = 1 << 9,
   CoverageTracePCGuard = 1 << 10,
-  CoverageInline8bitCounters = 1 << 12,
   CoverageNoPrune = 1 << 11,
 };
 
@@ -531,8 +530,7 @@ SanitizerArgs::SanitizerArgs(const ToolC
   }
 
   // trace-pc w/o func/bb/edge implies edge.
-  if ((CoverageFeatures &
-   (CoverageTracePC | CoverageTracePCGuard | CoverageInline8bitCounters)) 
&&
+  if ((CoverageFeatures & (CoverageTracePC | CoverageTracePCGuard)) &&
   !(CoverageFeatures & InsertionPointTypes))
 CoverageFeatures |= CoverageEdge;
 
@@ -639,7 +637,6 @@ void SanitizerArgs::addArgs(const ToolCh
 std::make_pair(Coverage8bitCounters, "-fsanitize-coverage-8bit-counters"),
 std::make_pair(CoverageTracePC, "-fsanitize-coverage-trace-pc"),
 std::make_pair(CoverageTracePCGuard, "-fsanitize-coverage-trace-pc-guard"),
-std::make_pair(CoverageInline8bitCounters, 
"-fsanitize-coverage-inline-8bit-counter

[PATCH] D33333: Emit warning when throw exception in destruct or dealloc functions which has a (possible implicit) noexcept specifier

2017-06-05 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 101373.
jyu2 added a comment.

Add more test include 1> throw/catch reference types. 2> try block. 
3>unreachable code.


https://reviews.llvm.org/D3

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/AnalysisBasedWarnings.cpp
  test/CXX/except/except.spec/p11.cpp
  test/SemaCXX/warn-throw-out-noexcept-func.cpp

Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -279,6 +279,148 @@
 }
 
 //===--===//
+// Check for throw in a non-throwing function.
+//===--===//
+enum ThrowState {
+  FoundNoPathForThrow,
+  FoundPathForThrow,
+  FoundPathWithNoThrowOutFunction,
+};
+
+static bool isThrowBeCaught(const CXXThrowExpr *Throw,
+const CXXCatchStmt *Catch) {
+  bool isCaught = false;
+  const Type *ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull();
+  const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull();
+
+  if (ThrowType->isReferenceType())
+ThrowType = ThrowType->castAs()
+ ->getPointeeType()
+ ->getUnqualifiedDesugaredType();
+  if (CaughtType && CaughtType->isReferenceType())
+CaughtType = CaughtType->castAs()
+  ->getPointeeType()
+  ->getUnqualifiedDesugaredType();
+  if (CaughtType == nullptr || CaughtType == ThrowType)
+return true;
+
+  const CXXRecordDecl *CaughtAsRecordType =
+   CaughtType->getPointeeCXXRecordDecl();
+  const CXXRecordDecl *ThrowTypeAsRecordType = ThrowType->getAsCXXRecordDecl();
+  if (CaughtAsRecordType && ThrowTypeAsRecordType)
+isCaught = ThrowTypeAsRecordType->isDerivedFrom(CaughtAsRecordType);
+  return isCaught;
+}
+
+static bool isThrowBeCaughtByHandlers(const CXXThrowExpr *CE,
+  const CXXTryStmt *TryStmt) {
+  for (unsigned H = 0; H < TryStmt->getNumHandlers(); ++H) {
+const CXXCatchStmt *CS = TryStmt->getHandler(H);
+if (isThrowBeCaught(CE, CS))
+  return true;
+  }
+  return false;
+}
+
+static bool doesThrowEscapePath(CFGBlock &Block, SourceLocation *OpLoc) {
+  bool HasThrowOutFunc = false;
+  for (const clang::CFGElement &B : Block) {
+if (B.getKind() != CFGElement::Statement)
+  continue;
+const CXXThrowExpr *CE =
+dyn_cast(B.getAs()->getStmt());
+if (!CE)
+  continue;
+
+HasThrowOutFunc = true;
+*OpLoc = CE->getThrowLoc();
+for (const CFGBlock::AdjacentBlock I : Block.succs())
+  if (I && I->getTerminator() && isa(I->getTerminator())) {
+const CXXTryStmt *Terminator = cast(I->getTerminator());
+if (isThrowBeCaughtByHandlers(CE, Terminator))
+  return false;
+  }
+  }
+  return HasThrowOutFunc;
+}
+
+static bool hasThrowOutNonThrowingFunc(SourceLocation *OpLoc, CFG *cfg) {
+
+  const unsigned ExitID = cfg->getExit().getBlockID();
+
+  SmallVector States(cfg->getNumBlockIDs(),
+ FoundNoPathForThrow);
+  States[cfg->getEntry().getBlockID()] = FoundPathWithNoThrowOutFunction;
+
+  SmallVector Stack;
+  Stack.push_back(&cfg->getEntry());
+  while (!Stack.empty()) {
+CFGBlock *CurBlock = Stack.back();
+Stack.pop_back();
+
+unsigned ID = CurBlock->getBlockID();
+ThrowState CurState = States[ID];
+if (CurState == FoundPathWithNoThrowOutFunction) {
+  if (ExitID == ID)
+continue;
+
+  if (doesThrowEscapePath(*CurBlock, OpLoc))
+CurState = FoundPathForThrow;
+}
+
+// Loop over successor blocks and add them to the Stack if their state
+// changes.
+for (const CFGBlock::AdjacentBlock I : CurBlock->succs())
+  if (I) {
+unsigned next_ID = (I)->getBlockID();
+if (next_ID == ExitID && CurState == FoundPathForThrow) {
+  States[next_ID] = CurState;
+} else if (States[next_ID] < CurState) {
+  States[next_ID] = CurState;
+  Stack.push_back(I);
+}
+  }
+  }
+  // Return true if the exit node is reachable, and only reachable through
+  // a throw expression.
+  return States[ExitID] == FoundPathForThrow;
+}
+
+static void EmitDiagForCXXThrowInNonThrowingFunc(SourceLocation OpLoc, Sema &S,
+ const FunctionDecl *FD) {
+  if (!S.getSourceManager().isInSystemHeader(OpLoc)) {
+S.Diag(OpLoc, diag::warn_throw_in_noexcept_func) << FD;
+if (S.getLangOpts().CPlusPlus11 &&
+(isa(FD) ||
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Delete ||
+ FD->getDeclName().getCXXOverloadedOperator() == OO_Array_Delete))
+  S.Diag(FD->getLocation(), diag::note_throw_in_dtor);
+else
+  S.Diag(FD->getLocation(), diag::note_throw_in_function);
+  }
+}
+
+static void chec

[PATCH] D33412: Add support for #pragma clang section

2017-06-05 Thread Javed Absar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304705: Add support for #pragma clang section (authored by 
javed.absar).

Changed prior to commit:
  https://reviews.llvm.org/D33412?vs=100846&id=101383#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33412

Files:
  cfe/trunk/docs/LanguageExtensions.rst
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/Parse/ParsePragma.cpp
  cfe/trunk/lib/Sema/SemaAttr.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeGenCXX/clang-sections-tentative.c
  cfe/trunk/test/CodeGenCXX/clang-sections.cpp
  cfe/trunk/test/Sema/pragma-clang-section.c

Index: cfe/trunk/docs/LanguageExtensions.rst
===
--- cfe/trunk/docs/LanguageExtensions.rst
+++ cfe/trunk/docs/LanguageExtensions.rst
@@ -2521,3 +2521,45 @@
 The attributes are applied to all matching declarations individually, even when
 the attribute is semantically incorrect. The attributes that aren't applied to
 any declaration are not verified semantically.
+
+Specifying section names for global objects (#pragma clang section)
+===
+
+The ``#pragma clang section`` directive provides a means to assign section-names
+to global variables, functions and static variables.
+
+The section names can be specified as:
+
+.. code-block:: c++
+
+  #pragma clang section bss="myBSS" data="myData" rodata="myRodata" text="myText"
+
+The section names can be reverted back to default name by supplying an empty
+string to the section kind, for example:
+
+.. code-block:: c++
+
+  #pragma clang section bss="" data="" text="" rodata=""
+
+The ``#pragma clang section`` directive obeys the following rules:
+
+* The pragma applies to all global variable, statics and function declarations
+  from the pragma to the end of the translation unit.
+
+* The pragma clang section is enabled automatically, without need of any flags.
+
+* This feature is only defined to work sensibly for ELF targets.
+
+* If section name is specified through _attribute_((section("myname"))), then
+  the attribute name gains precedence.
+
+* Global variables that are initialized to zero will be placed in the named
+  bss section, if one is present.
+
+* The ``#pragma clang section`` directive does not does try to infer section-kind
+  from the name. For example, naming a section "``.bss.mySec``" does NOT mean
+  it will be a bss section name.
+
+* The decision about which section-kind applies to each global is taken in the back-end.
+  Once the section-kind is known, appropriate section name, as specified by the user using
+  ``#pragma clang section`` directive, is applied to that global.
Index: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
@@ -887,9 +887,18 @@
   "missing ')' after '#pragma %0' - ignoring">, InGroup;
 def warn_pragma_expected_identifier : Warning<
   "expected identifier in '#pragma %0' - ignored">, InGroup;
+
+// '#pragma clang section' related errors
+def err_pragma_expected_clang_section_name : Error<
+  "expected one of [bss|data|rodata|text] section kind in '#pragma %0'">;
+def err_pragma_clang_section_expected_equal : Error<
+  "expected '=' following '#pragma clang section %select{invalid|bss|data|rodata|text}0'">;
+def err_pragma_clang_section_expected_name_or_clear : Error<
+  "expected section name or '\"\"' following '#pragma clang section %select{invalid|bss|data|rodata|text}0'">;
 def warn_pragma_expected_section_name : Warning<
   "expected a string literal for the section name in '#pragma %0' - ignored">,
   InGroup;
+
 def warn_pragma_expected_section_push_pop_or_name : Warning<
   "expected push, pop or a string literal for the section name in '#pragma %0' - ignored">,
   InGroup;
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -1683,6 +1683,42 @@
   let Documentation = [SectionDocs];
 }
 
+def PragmaClangBSSSection : InheritableAttr {
+  // This attribute has no spellings as it is only ever created implicitly.
+  let Spellings = [];
+  let Args = [StringArgument<"Name">];
+  let Subjects = SubjectList<[GlobalVar], ErrorDiag,
+ "ExpectedFunctionMethodOrGlobalVar">;
+  let Documentation = [Undocumented];
+}
+
+def PragmaClangDataSection : InheritableAttr {
+  // This attribute has no spellings as it is only ever created implicitly.
+  let Spellings = [];
+  let Args = [StringArgument<"

r304705 - Add support for #pragma clang section

2017-06-05 Thread Javed Absar via cfe-commits
Author: javed.absar
Date: Mon Jun  5 05:11:57 2017
New Revision: 304705

URL: http://llvm.org/viewvc/llvm-project?rev=304705&view=rev
Log:
Add support for #pragma clang section

This patch provides a means to specify section-names for global variables, 
functions and static variables, using #pragma directives. 
This feature is only defined to work sensibly for ELF targets.
One can specify section names as:
#pragma clang section bss="myBSS" data="myData" rodata="myRodata" text="myText"
One can "unspecify" a section name with empty string e.g.
#pragma clang section bss="" data="" text="" rodata=""

Reviewers: Roger Ferrer, Jonathan Roelofs, Reid Kleckner
Differential Revision: https://reviews.llvm.org/D33412


Added:
cfe/trunk/test/CodeGenCXX/clang-sections-tentative.c
cfe/trunk/test/CodeGenCXX/clang-sections.cpp
cfe/trunk/test/Sema/pragma-clang-section.c
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=304705&r1=304704&r2=304705&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Mon Jun  5 05:11:57 2017
@@ -2521,3 +2521,45 @@ whether or not an attribute is supported
 The attributes are applied to all matching declarations individually, even when
 the attribute is semantically incorrect. The attributes that aren't applied to
 any declaration are not verified semantically.
+
+Specifying section names for global objects (#pragma clang section)
+===
+
+The ``#pragma clang section`` directive provides a means to assign 
section-names
+to global variables, functions and static variables.
+
+The section names can be specified as:
+
+.. code-block:: c++
+
+  #pragma clang section bss="myBSS" data="myData" rodata="myRodata" 
text="myText"
+
+The section names can be reverted back to default name by supplying an empty
+string to the section kind, for example:
+
+.. code-block:: c++
+
+  #pragma clang section bss="" data="" text="" rodata=""
+
+The ``#pragma clang section`` directive obeys the following rules:
+
+* The pragma applies to all global variable, statics and function declarations
+  from the pragma to the end of the translation unit.
+
+* The pragma clang section is enabled automatically, without need of any flags.
+
+* This feature is only defined to work sensibly for ELF targets.
+
+* If section name is specified through _attribute_((section("myname"))), then
+  the attribute name gains precedence.
+
+* Global variables that are initialized to zero will be placed in the named
+  bss section, if one is present.
+
+* The ``#pragma clang section`` directive does not does try to infer 
section-kind
+  from the name. For example, naming a section "``.bss.mySec``" does NOT mean
+  it will be a bss section name.
+
+* The decision about which section-kind applies to each global is taken in the 
back-end.
+  Once the section-kind is known, appropriate section name, as specified by 
the user using
+  ``#pragma clang section`` directive, is applied to that global.

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=304705&r1=304704&r2=304705&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Jun  5 05:11:57 2017
@@ -1683,6 +1683,42 @@ def Section : InheritableAttr {
   let Documentation = [SectionDocs];
 }
 
+def PragmaClangBSSSection : InheritableAttr {
+  // This attribute has no spellings as it is only ever created implicitly.
+  let Spellings = [];
+  let Args = [StringArgument<"Name">];
+  let Subjects = SubjectList<[GlobalVar], ErrorDiag,
+ "ExpectedFunctionMethodOrGlobalVar">;
+  let Documentation = [Undocumented];
+}
+
+def PragmaClangDataSection : InheritableAttr {
+  // This attribute has no spellings as it is only ever created implicitly.
+  let Spellings = [];
+  let Args = [StringArgument<"Name">];
+  let Subjects = SubjectList<[GlobalVar], ErrorDiag,
+ "ExpectedFunctionMethodOrGlobalVar">;
+  let Documentation = [Undocumented];
+}
+
+def PragmaClangRodataSection : InheritableAttr {
+  // This attribute has no spellings as it is only ever created implicitly.
+  let Spellings = [];
+  let Args = [StringArgument<"Name">];
+  let 

[PATCH] D33719: Add _Float16 as a C/C++ source language type

2017-06-05 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Hi Bruno, Akira, 
Many thanks for your feedback! Apologies for the missing context. The patch 
touches many files and thus with context it is quite big (~4MB). Thought this 
would be too much if we need a few iterations. Anyway, will include it from now 
on.

I am working on a new revision and fixing an issue that I noticed while 
restructuring the regression test: it was actually not creating float16 
literals properly. About the tests and using --target=aarch64: you're right 
that there should nothing be ARM specific here, but it is just that for Aarch64 
it will show "half" IR types which I preferred, while it looks like x86 way of 
dealing with is to convert it and work on i16 types. Perhaps I need tests for 
both?

Yes, initially I wanted to unconditionally support _Float16, but now that you 
asked how about it, I agree it makes more sense to enable it for C11 and C++11 
and have:  KEYWORD(_Float16, KEYC11|KEYCXX11)

Thanks,
Sjoerd.


https://reviews.llvm.org/D33719



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


r304708 - [OpenCL] Fix pipe size in TypeInfo.

2017-06-05 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Mon Jun  5 06:27:03 2017
New Revision: 304708

URL: http://llvm.org/viewvc/llvm-project?rev=304708&view=rev
Log:
[OpenCL] Fix pipe size in TypeInfo.

Pipes are now the size of pointers rather than the size
of the type that they contain.

Patch by Simon Perretta!

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


Added:
cfe/trunk/test/Index/pipe-size.cl
Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=304708&r1=304707&r2=304708&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Jun  5 06:27:03 2017
@@ -1939,9 +1939,8 @@ TypeInfo ASTContext::getTypeInfoImpl(con
   break;
 
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = 
Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
+Align = 
Target->getPointerAlign(getTargetAddressSpace(LangAS::opencl_global));
   }
 
   }

Added: cfe/trunk/test/Index/pipe-size.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/pipe-size.cl?rev=304708&view=auto
==
--- cfe/trunk/test/Index/pipe-size.cl (added)
+++ cfe/trunk/test/Index/pipe-size.cl Mon Jun  5 06:27:03 2017
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
amdgcn-amd-amdhsa-amdgizcl %s -o - | FileCheck %s --check-prefix=AMD
+__kernel void testPipe( pipe int test )
+{
+int s = sizeof(test);
+// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store i32 8, i32* %s, align 4
+// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 4
+// SPIR: store i32 4, i32* %s, align 4
+// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 8
+// SPIR64: store i32 8, i32* %s, align 4
+// AMD: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)* addrspace(5)* %test.addr, align 4
+// AMD: store i32 8, i32 addrspace(5)* %s, align 4
+}


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


[PATCH] D33597: [OpenCL] Fix pipe size in TypeInfo.

2017-06-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304708: [OpenCL] Fix pipe size in TypeInfo. (authored by 
stulova).

Changed prior to commit:
  https://reviews.llvm.org/D33597?vs=101236&id=101388#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33597

Files:
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/test/Index/pipe-size.cl


Index: cfe/trunk/test/Index/pipe-size.cl
===
--- cfe/trunk/test/Index/pipe-size.cl
+++ cfe/trunk/test/Index/pipe-size.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple 
amdgcn-amd-amdhsa-amdgizcl %s -o - | FileCheck %s --check-prefix=AMD
+__kernel void testPipe( pipe int test )
+{
+int s = sizeof(test);
+// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store i32 8, i32* %s, align 4
+// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 4
+// SPIR: store i32 4, i32* %s, align 4
+// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)** %test.addr, align 8
+// SPIR64: store i32 8, i32* %s, align 4
+// AMD: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t 
addrspace(1)* addrspace(5)* %test.addr, align 4
+// AMD: store i32 8, i32 addrspace(5)* %s, align 4
+}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -1939,9 +1939,8 @@
   break;
 
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = 
Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
+Align = 
Target->getPointerAlign(getTargetAddressSpace(LangAS::opencl_global));
   }
 
   }


Index: cfe/trunk/test/Index/pipe-size.cl
===
--- cfe/trunk/test/Index/pipe-size.cl
+++ cfe/trunk/test/Index/pipe-size.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple spir64-unknown-unknown %s -o - | FileCheck %s --check-prefix=SPIR64
+// RUN: %clang_cc1 -x cl -O0 -cl-std=CL2.0 -emit-llvm -triple amdgcn-amd-amdhsa-amdgizcl %s -o - | FileCheck %s --check-prefix=AMD
+__kernel void testPipe( pipe int test )
+{
+int s = sizeof(test);
+// X86: store %opencl.pipe_t* %test, %opencl.pipe_t** %test.addr, align 8
+// X86: store i32 8, i32* %s, align 4
+// SPIR: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 4
+// SPIR: store i32 4, i32* %s, align 4
+// SPIR64: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)** %test.addr, align 8
+// SPIR64: store i32 8, i32* %s, align 4
+// AMD: store %opencl.pipe_t addrspace(1)* %test, %opencl.pipe_t addrspace(1)* addrspace(5)* %test.addr, align 4
+// AMD: store i32 8, i32 addrspace(5)* %s, align 4
+}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -1939,9 +1939,8 @@
   break;
 
   case Type::Pipe: {
-TypeInfo Info = getTypeInfo(cast(T)->getElementType());
-Width = Info.Width;
-Align = Info.Align;
+Width = Target->getPointerWidth(getTargetAddressSpace(LangAS::opencl_global));
+Align = Target->getPointerAlign(getTargetAddressSpace(LangAS::opencl_global));
   }
 
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33826: [clang-tidy] avoid pointer cast to more strict alignment check

2017-06-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this. How does this check compare with the 
-Wcast-align diagnostic in the Clang frontend? I believe that warning already 
covers these cases, so I'm wondering what extra value is added with this check?


Repository:
  rL LLVM

https://reviews.llvm.org/D33826



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


r304710 - [analyzer] Nullability: fix notes around synthesized ObjC property accessors.

2017-06-05 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Jun  5 07:40:03 2017
New Revision: 304710

URL: http://llvm.org/viewvc/llvm-project?rev=304710&view=rev
Log:
[analyzer] Nullability: fix notes around synthesized ObjC property accessors.

Nullable-to-nonnull checks used to crash when the custom bug visitor was trying
to add its notes to autosynthesized accessors of Objective-C properties.

Now we avoid this, mostly automatically outside of checker control, by
moving the diagnostic to the parent stack frame where the accessor has been
called.

Differential revision: https://reviews.llvm.org/D32437

Added:
cfe/trunk/test/Analysis/nullability-notes.m
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h?rev=304710&r1=304709&r2=304710&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h 
Mon Jun  5 07:40:03 2017
@@ -550,13 +550,15 @@ public:
 class PathDiagnosticCallPiece : public PathDiagnosticPiece {
   PathDiagnosticCallPiece(const Decl *callerD,
   const PathDiagnosticLocation &callReturnPos)
-: PathDiagnosticPiece(Call), Caller(callerD), Callee(nullptr),
-  NoExit(false), callReturn(callReturnPos) {}
+  : PathDiagnosticPiece(Call), Caller(callerD), Callee(nullptr),
+NoExit(false), IsCalleeAnAutosynthesizedPropertyAccessor(false),
+callReturn(callReturnPos) {}
 
   PathDiagnosticCallPiece(PathPieces &oldPath, const Decl *caller)
-: PathDiagnosticPiece(Call), Caller(caller), Callee(nullptr),
-  NoExit(true), path(oldPath) {}
-  
+  : PathDiagnosticPiece(Call), Caller(caller), Callee(nullptr),
+NoExit(true), IsCalleeAnAutosynthesizedPropertyAccessor(false),
+path(oldPath) {}
+
   const Decl *Caller;
   const Decl *Callee;
 
@@ -564,6 +566,10 @@ class PathDiagnosticCallPiece : public P
   // call exit.
   bool NoExit;
 
+  // Flag signifying that the callee function is an Objective-C autosynthesized
+  // property getter or setter.
+  bool IsCalleeAnAutosynthesizedPropertyAccessor;
+
   // The custom string, which should appear after the call Return Diagnostic.
   // TODO: Should we allow multiple diagnostics?
   std::string CallStackMessage;

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=304710&r1=304709&r2=304710&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Mon Jun  5 
07:40:03 2017
@@ -326,7 +326,7 @@ NullabilityChecker::NullabilityBugVisito
 
   // Retrieve the associated statement.
   const Stmt *S = TrackedNullab->getNullabilitySource();
-  if (!S) {
+  if (!S || S->getLocStart().isInvalid()) {
 S = PathDiagnosticLocation::getStmt(N);
   }
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp?rev=304710&r1=304709&r2=304710&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp Mon Jun  5 07:40:03 
2017
@@ -694,7 +694,30 @@ PathDiagnosticLocation::create(const Pro
   return PathDiagnosticLocation(S, SMng, P.getLocationContext());
 }
 
+static const LocationContext *
+findTopAutosynthesizedParentContext(const LocationContext *LC) {
+  assert(LC->getAnalysisDeclContext()->isBodyAutosynthesized());
+  const LocationContext *ParentLC = LC->getParent();
+  assert(ParentLC && "We don't start analysis from autosynthesized code");
+  while (ParentLC->getAnalysisDeclContext()->isBodyAutosynthesized()) {
+LC = ParentLC;
+ParentLC = LC->getParent();
+assert(ParentLC && "We don't start analysis from autosynthesized code");
+  }
+  return LC;
+}
+
 const Stmt *PathDiagnosticLocation::getStmt(const ExplodedNode *N) {
+  // We cannot place diagnostics on autosynthesized code.
+  // Put them onto the call site through which we jumped into autosynthesized
+  // code for the first time.
+  const LocationContext *LC = N->getLocationContext();
+  if (LC->getAnalysisDeclContext()->isBodyAutosynthesized()) {
+// It must be a stack frame because we only autosynthesize functions.
+return cast(findTopAutosynthesizedParentContex

[PATCH] D32437: [analyzer] Nullability: fix a crash when adding notes inside a synthesized property accessor.

2017-06-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304710: [analyzer] Nullability: fix notes around synthesized 
ObjC property accessors. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D32437?vs=100673&id=101392#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32437

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  cfe/trunk/test/Analysis/nullability-notes.m

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -550,20 +550,26 @@
 class PathDiagnosticCallPiece : public PathDiagnosticPiece {
   PathDiagnosticCallPiece(const Decl *callerD,
   const PathDiagnosticLocation &callReturnPos)
-: PathDiagnosticPiece(Call), Caller(callerD), Callee(nullptr),
-  NoExit(false), callReturn(callReturnPos) {}
+  : PathDiagnosticPiece(Call), Caller(callerD), Callee(nullptr),
+NoExit(false), IsCalleeAnAutosynthesizedPropertyAccessor(false),
+callReturn(callReturnPos) {}
 
   PathDiagnosticCallPiece(PathPieces &oldPath, const Decl *caller)
-: PathDiagnosticPiece(Call), Caller(caller), Callee(nullptr),
-  NoExit(true), path(oldPath) {}
-  
+  : PathDiagnosticPiece(Call), Caller(caller), Callee(nullptr),
+NoExit(true), IsCalleeAnAutosynthesizedPropertyAccessor(false),
+path(oldPath) {}
+
   const Decl *Caller;
   const Decl *Callee;
 
   // Flag signifying that this diagnostic has only call enter and no matching
   // call exit.
   bool NoExit;
 
+  // Flag signifying that the callee function is an Objective-C autosynthesized
+  // property getter or setter.
+  bool IsCalleeAnAutosynthesizedPropertyAccessor;
+
   // The custom string, which should appear after the call Return Diagnostic.
   // TODO: Should we allow multiple diagnostics?
   std::string CallStackMessage;
Index: cfe/trunk/test/Analysis/nullability-notes.m
===
--- cfe/trunk/test/Analysis/nullability-notes.m
+++ cfe/trunk/test/Analysis/nullability-notes.m
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -analyzer-output=text -verify %s
+
+#include "Inputs/system-header-simulator-for-nullability.h"
+
+void takesNonnull(NSObject *_Nonnull y);
+
+@interface ClassWithProperties: NSObject
+@property(copy, nullable) NSObject *x;
+-(void) method;
+@end;
+@implementation ClassWithProperties
+-(void) method {
+  // no-crash
+  NSObject *x = self.x; // expected-note{{Nullability 'nullable' is inferred}}
+  takesNonnull(x); // expected-warning{{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
+   // expected-note@-1{{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
+}
+@end
Index: cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -694,7 +694,30 @@
   return PathDiagnosticLocation(S, SMng, P.getLocationContext());
 }
 
+static const LocationContext *
+findTopAutosynthesizedParentContext(const LocationContext *LC) {
+  assert(LC->getAnalysisDeclContext()->isBodyAutosynthesized());
+  const LocationContext *ParentLC = LC->getParent();
+  assert(ParentLC && "We don't start analysis from autosynthesized code");
+  while (ParentLC->getAnalysisDeclContext()->isBodyAutosynthesized()) {
+LC = ParentLC;
+ParentLC = LC->getParent();
+assert(ParentLC && "We don't start analysis from autosynthesized code");
+  }
+  return LC;
+}
+
 const Stmt *PathDiagnosticLocation::getStmt(const ExplodedNode *N) {
+  // We cannot place diagnostics on autosynthesized code.
+  // Put them onto the call site through which we jumped into autosynthesized
+  // code for the first time.
+  const LocationContext *LC = N->getLocationContext();
+  if (LC->getAnalysisDeclContext()->isBodyAutosynthesized()) {
+// It must be a stack frame because we only autosynthesize functions.
+return cast(findTopAutosynthesizedParentContext(LC))
+->getCallSite();
+  }
+  // Otherwise, see if the node's program point directly points to a statement.
   ProgramPoint P = N->getLocation();
   if (Optional SP = P.getAs())
 return SP->getStmt();
@@ -912,6 +935,17 @@
 
   callEnterWithin = PathDiagnosticLocation::createBegin(Cal

[PATCH] D33406: PR28129 expand vector oparation to an IR constant.

2017-06-05 Thread Dinar Temirbulatov via Phabricator via cfe-commits
dtemirbulatov added a comment.

Ping. [andrew.w.kaylor, scanon] Is it OK to assume that FP exceptions are off 
by default and allow such transformation to constants in the IR since we know 
that  we would have exception with "1.00  -nan" for _mm256_cmp_ps(a, b, 15)?


https://reviews.llvm.org/D33406



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


[PATCH] D33825: [clang-tidy] signal handler must be plain old function check

2017-06-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

This check is an interesting one. The rules around what is signal safe are 
changing for C++17 to be a bit more lenient than what the rules are for C++14. 
CERT's rule is written against C++14, and so the current behavior matches the 
rule wording. However, the *intent* of the rule is to ensure that only 
signal-safe functionality is used from a signal handler, and so from that 
perspective, I can imagine a user compiling for C++17 to want the relaxed rules 
to still comply with CERT's wording. What do you think?




Comment at: clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp:22
+namespace {
+internal::Matcher notExternCSignalHandler() {
+  return functionDecl(unless(isExternC())).bind("signal_handler");

Since this is only needed once and is quite succinct, I'd just lower it into 
its usage.



Comment at: clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp:47
+
+internal::Matcher signalHandlerWithCallExpr() {
+  return functionDecl(hasDescendant(callExpr()))

Same here.



Comment at: clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp:52
+
+internal::Matcher allCallExpr() {
+  return decl(forEachDescendant(callExpr().bind("call")));

And here.



Comment at: clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp:83
+  const auto *Call = Match.getNodeAs("call");
+  const auto *Func = Call->getDirectCallee();
+  if (!Func || !Func->getDefinition())

Don't use `auto` for this one, since the type is neither complex nor spelled 
out in the initialization.



Comment at: clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp:84
+  const auto *Func = Call->getDirectCallee();
+  if (!Func || !Func->getDefinition())
+continue;

Can use `isDefined()` instead of `getDefinition()`. Then you can store off the 
`FunctionDecl *` for the definition and use it below in the call to 
`hasCxxRepr()`.



Comment at: clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp:102-103
+  }
+  SourceLocation callLoc() { return FunctionCall; }
+  SourceLocation cxxRepLoc() { return CxxRepresentation; }
+

These functions can be marked `const`.



Comment at: clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp:141
+diag(SignalHandler->getLocation(),
+ "use 'external C' prefix for signal handlers");
+diag(Result.Nodes.getNodeAs("signal_argument")->getLocation(),

'extern \"C\"'' instead of 'external C'. I'd probably reword it to: `"signal 
handlers must be 'extern \"C\""`



Comment at: clang-tidy/cert/SignalHandlerMustBePlainOldFunctionCheck.cpp:149
+diag(SingalHandler->getLocation(),
+ "do not use C++ representations in signal handlers");
+if (const auto *CxxStmt = Result.Nodes.getNodeAs("cxx_stmt"))

representations -> constructs

(same below)



Comment at: docs/clang-tidy/checks/cert-msc54-cpp.rst:24
+extern "C" void cpp_signal_handler(int sig) {
+//warning: do not use C++ representations in signal handlers
+  throw "error message";

Space between // and warning; indent the comment.



Comment at: docs/clang-tidy/checks/cert-msc54-cpp.rst:29
+void install_cpp_signal_handler() {
+if (SIG_ERR == std::signal(SIGTERM, cpp_signal_handler))
+  return;

Indent the code.


Repository:
  rL LLVM

https://reviews.llvm.org/D33825



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


r304713 - [analyzer] Don't add arrow to the inlined function's decl when it has no body.

2017-06-05 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon Jun  5 08:36:28 2017
New Revision: 304713

URL: http://llvm.org/viewvc/llvm-project?rev=304713&view=rev
Log:
[analyzer] Don't add arrow to the inlined function's decl when it has no body.

In plist output mode with alternate path diagnostics, when entering a function,
we draw an arrow from the caller to the beginning of the callee's declaration.
Upon exiting, however, we draw the arrow from the last statement in the
callee function. The former makes little sense when the declaration is
not a definition, i.e. has no body, which may happen in case the body
is coming from a body farm, eg. Objective-C autosynthesized property accessor.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/test/Analysis/nullability-notes.m

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=304713&r1=304712&r2=304713&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Mon Jun  5 08:36:28 2017
@@ -1671,9 +1671,15 @@ static bool GenerateAlternateExtensivePa
 // Add an edge to the start of the function.
 const StackFrameContext *CalleeLC = CE->getCalleeContext();
 const Decl *D = CalleeLC->getDecl();
-addEdgeToPath(PD.getActivePath(), PrevLoc,
-  PathDiagnosticLocation::createBegin(D, SM),
-  CalleeLC);
+// Add the edge only when the callee has body. We jump to the beginning
+// of the *declaration*, however we expect it to be followed by the
+// body. This isn't the case for autosynthesized property accessors in
+// Objective-C. No need for a similar extra check for CallExit points
+// because the exit edge comes from a statement (i.e. return),
+// not from declaration.
+if (D->hasBody())
+  addEdgeToPath(PD.getActivePath(), PrevLoc,
+PathDiagnosticLocation::createBegin(D, SM), CalleeLC);
 
 // Did we visit an entire call?
 bool VisitedEntireCall = PD.isWithinCall();

Modified: cfe/trunk/test/Analysis/nullability-notes.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullability-notes.m?rev=304713&r1=304712&r2=304713&view=diff
==
--- cfe/trunk/test/Analysis/nullability-notes.m (original)
+++ cfe/trunk/test/Analysis/nullability-notes.m Mon Jun  5 08:36:28 2017
@@ -1,11 +1,13 @@
 // RUN: %clang_analyze_cc1 -fblocks 
-analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced
 -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -fblocks 
-analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced
 -analyzer-output=plist -analyzer-config path-diagnostics-alternate=true -o 
%t.plist %s
+// RUN: FileCheck --input-file=%t.plist %s
 
 #include "Inputs/system-header-simulator-for-nullability.h"
 
 void takesNonnull(NSObject *_Nonnull y);
 
 @interface ClassWithProperties: NSObject
-@property(copy, nullable) NSObject *x;
+@property(copy, nullable) NSObject *x; // plist check ensures no control flow 
piece from here to 'self.x'.
 -(void) method;
 @end;
 @implementation ClassWithProperties
@@ -16,3 +18,187 @@ void takesNonnull(NSObject *_Nonnull y);
// expected-note@-1{{Nullable pointer is passed to a callee 
that requires a non-null 1st parameter}}
 }
 @end
+
+// CHECK:  diagnostics
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:path
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindcontrol
+// CHECK-NEXT:  edges
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: start
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col10
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT: end
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col22
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col22
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEX

[PATCH] D33671: [analyzer] In plist alternate mode, don't add weird control flow pieces from ObjC property declarations to uses.

2017-06-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304713: [analyzer] Don't add arrow to the inlined function's 
decl when it has no body. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D33671?vs=100693&id=101396#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33671

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
  cfe/trunk/test/Analysis/nullability-notes.m

Index: cfe/trunk/test/Analysis/nullability-notes.m
===
--- cfe/trunk/test/Analysis/nullability-notes.m
+++ cfe/trunk/test/Analysis/nullability-notes.m
@@ -1,11 +1,13 @@
 // RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -analyzer-output=plist -analyzer-config path-diagnostics-alternate=true -o %t.plist %s
+// RUN: FileCheck --input-file=%t.plist %s
 
 #include "Inputs/system-header-simulator-for-nullability.h"
 
 void takesNonnull(NSObject *_Nonnull y);
 
 @interface ClassWithProperties: NSObject
-@property(copy, nullable) NSObject *x;
+@property(copy, nullable) NSObject *x; // plist check ensures no control flow piece from here to 'self.x'.
 -(void) method;
 @end;
 @implementation ClassWithProperties
@@ -16,3 +18,187 @@
// expected-note@-1{{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
 }
 @end
+
+// CHECK:  diagnostics
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:path
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindcontrol
+// CHECK-NEXT:  edges
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: start
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col10
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT: end
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col22
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col22
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindevent
+// CHECK-NEXT:  location
+// CHECK-NEXT:  
+// CHECK-NEXT:   line16
+// CHECK-NEXT:   col22
+// CHECK-NEXT:   file0
+// CHECK-NEXT:  
+// CHECK-NEXT:  ranges
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT: 
+// CHECK-NEXT:  line16
+// CHECK-NEXT:  col22
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  line16
+// CHECK-NEXT:  col22
+// CHECK-NEXT:  file0
+// CHECK-NEXT: 
+// CHECK-NEXT:
+// CHECK-NEXT:  
+// CHECK-NEXT:  depth1
+// CHECK-NEXT:  extended_message
+// CHECK-NEXT:  Nullability 'nullable' is inferred
+// CHECK-NEXT:  message
+// CHECK-NEXT:  Nullability 'nullable' is inferred
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindcontrol
+// CHECK-NEXT:  edges
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: start
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col22
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col22
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT: end
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col3
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT:col10
+// CHECK-NEXT:file0
+// CHECK-NEXT:   
+// CHECK-NEXT:  
+// CHECK-NEXT:
+// CHECK-NEXT:   
+// CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT:  kindcontrol
+// CHECK-NEXT:  edges
+// CHECK-NEXT:   
+// CHECK-NEXT:
+// CHECK-NEXT: start
+// CHECK-NEXT:  
+// CHECK-NEXT:   
+// CHECK-NEXT:line16
+// CHECK-NEXT: 

[PATCH] D33893: Align definition of DW_OP_plus with DWARF spec [2/3]

2017-06-05 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
Herald added a subscriber: aprantl.

This patch is part of 3 patches that together form a single patch, but must be 
introduced in stages in order not to break things.
 
The way that LLVM interprets DW_OP_plus in DIExpression nodes is basically that 
of the DW_OP_plus_uconst operator since LLVM expects an unsigned constant 
operand. This unnecessarily restricts the DW_OP_plus operator, preventing it 
from being used to describe the evaluation of runtime values on the expression 
stack. These patches try to align the semantics of DW_OP_plus and DW_OP_minus 
with that of the DWARF definition, which pops two elements off the expression 
stack, performs the operation and pushes the result back on the stack.
 
This is done in three stages:
•   The first patch (LLVM) adds support for DW_OP_plus_uconst and 
changes all uses (and tests) of DW_OP_plus to use DW_OP_plus_uconst.
 
•   The second patch (Clang) contains changes to use 
DW_OP_plus_uconst instead of DW_OP_plus.
 
•   The third patch (LLVM) changes the semantics of DW_OP_plus to 
be in line with it’s DWARF meaning. It also does this for DW_OP_minus.


https://reviews.llvm.org/D33893

Files:
  lib/CodeGen/CGDebugInfo.cpp


Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3480,13 +3480,13 @@
 if (VD->hasAttr()) {
   // Here, we need an offset *into* the alloca.
   CharUnits offset = CharUnits::fromQuantity(32);
-  Expr.push_back(llvm::dwarf::DW_OP_plus);
+  Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
   // offset of __forwarding field
   offset = CGM.getContext().toCharUnitsFromBits(
   CGM.getTarget().getPointerWidth(0));
   Expr.push_back(offset.getQuantity());
   Expr.push_back(llvm::dwarf::DW_OP_deref);
-  Expr.push_back(llvm::dwarf::DW_OP_plus);
+  Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
   // offset of x field
   offset = CGM.getContext().toCharUnitsFromBits(XOffset);
   Expr.push_back(offset.getQuantity());
@@ -3594,17 +3594,17 @@
 
   SmallVector addr;
   addr.push_back(llvm::dwarf::DW_OP_deref);
-  addr.push_back(llvm::dwarf::DW_OP_plus);
+  addr.push_back(llvm::dwarf::DW_OP_plus_uconst);
   addr.push_back(offset.getQuantity());
   if (isByRef) {
 addr.push_back(llvm::dwarf::DW_OP_deref);
-addr.push_back(llvm::dwarf::DW_OP_plus);
+addr.push_back(llvm::dwarf::DW_OP_plus_uconst);
 // offset of __forwarding field
 offset =
 CGM.getContext().toCharUnitsFromBits(target.getPointerSizeInBits(0));
 addr.push_back(offset.getQuantity());
 addr.push_back(llvm::dwarf::DW_OP_deref);
-addr.push_back(llvm::dwarf::DW_OP_plus);
+addr.push_back(llvm::dwarf::DW_OP_plus_uconst);
 // offset of x field
 offset = CGM.getContext().toCharUnitsFromBits(XOffset);
 addr.push_back(offset.getQuantity());


Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3480,13 +3480,13 @@
 if (VD->hasAttr()) {
   // Here, we need an offset *into* the alloca.
   CharUnits offset = CharUnits::fromQuantity(32);
-  Expr.push_back(llvm::dwarf::DW_OP_plus);
+  Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
   // offset of __forwarding field
   offset = CGM.getContext().toCharUnitsFromBits(
   CGM.getTarget().getPointerWidth(0));
   Expr.push_back(offset.getQuantity());
   Expr.push_back(llvm::dwarf::DW_OP_deref);
-  Expr.push_back(llvm::dwarf::DW_OP_plus);
+  Expr.push_back(llvm::dwarf::DW_OP_plus_uconst);
   // offset of x field
   offset = CGM.getContext().toCharUnitsFromBits(XOffset);
   Expr.push_back(offset.getQuantity());
@@ -3594,17 +3594,17 @@
 
   SmallVector addr;
   addr.push_back(llvm::dwarf::DW_OP_deref);
-  addr.push_back(llvm::dwarf::DW_OP_plus);
+  addr.push_back(llvm::dwarf::DW_OP_plus_uconst);
   addr.push_back(offset.getQuantity());
   if (isByRef) {
 addr.push_back(llvm::dwarf::DW_OP_deref);
-addr.push_back(llvm::dwarf::DW_OP_plus);
+addr.push_back(llvm::dwarf::DW_OP_plus_uconst);
 // offset of __forwarding field
 offset =
 CGM.getContext().toCharUnitsFromBits(target.getPointerSizeInBits(0));
 addr.push_back(offset.getQuantity());
 addr.push_back(llvm::dwarf::DW_OP_deref);
-addr.push_back(llvm::dwarf::DW_OP_plus);
+addr.push_back(llvm::dwarf::DW_OP_plus_uconst);
 // offset of x field
 offset = CGM.getContext().toCharUnitsFromBits(XOffset);
 addr.push_back(offset.getQuantity());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33828: [analyzer] Don't crash when the code tries to construct an Objective-C object in AllocaRegion.

2017-06-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 101401.
NoQ added a comment.

Turn the comment into an assertion.


https://reviews.llvm.org/D33828

Files:
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/DynamicTypePropagation.m


Index: test/Analysis/DynamicTypePropagation.m
===
--- test/Analysis/DynamicTypePropagation.m
+++ test/Analysis/DynamicTypePropagation.m
@@ -4,6 +4,9 @@
 #  error Compiler does not support Objective-C generics?
 #endif
 
+typedef __typeof(sizeof(int)) size_t;
+void *memset(void *, int, size_t);
+
 #define nil 0
 typedef unsigned long NSUInteger;
 typedef int BOOL;
@@ -21,6 +24,7 @@
 @end
 
 @interface NSArray : NSObject
+- (void) init;
 - (BOOL)contains:(ObjectType)obj;
 - (ObjectType)getObjAtIndex:(NSUInteger)idx;
 - (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
@@ -55,3 +59,11 @@
   // MyType!
   [element myFunction:0 myParam:0 ];
 }
+
+// Do not try this at home! The analyzer shouldn't crash though when it
+// tries to figure out the dynamic type behind the alloca's return value.
+void testAlloca(size_t NSArrayClassSizeWeKnowSomehow) {
+  NSArray *arr = __builtin_alloca(NSArrayClassSizeWeKnowSomehow);
+  memset(arr, 0, NSArrayClassSizeWeKnowSomehow);
+  [arr init]; // no-crash
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -957,6 +957,12 @@
 return RuntimeDefinition();
 
   DynamicTypeInfo DTI = getDynamicTypeInfo(getState(), Receiver);
+  if (!DTI.isValid()) {
+assert(isa(Receiver) &&
+   "Unhandled untyped region class!");
+return RuntimeDefinition();
+  }
+
   QualType DynType = DTI.getType();
   CanBeSubClassed = DTI.canBeASubClass();
   ReceiverT = dyn_cast(DynType.getCanonicalType());


Index: test/Analysis/DynamicTypePropagation.m
===
--- test/Analysis/DynamicTypePropagation.m
+++ test/Analysis/DynamicTypePropagation.m
@@ -4,6 +4,9 @@
 #  error Compiler does not support Objective-C generics?
 #endif
 
+typedef __typeof(sizeof(int)) size_t;
+void *memset(void *, int, size_t);
+
 #define nil 0
 typedef unsigned long NSUInteger;
 typedef int BOOL;
@@ -21,6 +24,7 @@
 @end
 
 @interface NSArray : NSObject
+- (void) init;
 - (BOOL)contains:(ObjectType)obj;
 - (ObjectType)getObjAtIndex:(NSUInteger)idx;
 - (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
@@ -55,3 +59,11 @@
   // MyType!
   [element myFunction:0 myParam:0 ];
 }
+
+// Do not try this at home! The analyzer shouldn't crash though when it
+// tries to figure out the dynamic type behind the alloca's return value.
+void testAlloca(size_t NSArrayClassSizeWeKnowSomehow) {
+  NSArray *arr = __builtin_alloca(NSArrayClassSizeWeKnowSomehow);
+  memset(arr, 0, NSArrayClassSizeWeKnowSomehow);
+  [arr init]; // no-crash
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -957,6 +957,12 @@
 return RuntimeDefinition();
 
   DynamicTypeInfo DTI = getDynamicTypeInfo(getState(), Receiver);
+  if (!DTI.isValid()) {
+assert(isa(Receiver) &&
+   "Unhandled untyped region class!");
+return RuntimeDefinition();
+  }
+
   QualType DynType = DTI.getType();
   CanBeSubClassed = DTI.canBeASubClass();
   ReceiverT = dyn_cast(DynType.getCanonicalType());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-05 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 101402.
ABataev added a comment.

Added DeclContext parameter to constructors of ImplicitParamDecl class.


https://reviews.llvm.org/D33735

Files:
  include/clang/AST/Decl.h
  lib/AST/ASTImporter.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclObjC.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGCXXABI.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/captured-statements.c
  test/CodeGenCXX/captured-statements.cpp

Index: test/CodeGenCXX/captured-statements.cpp
===
--- test/CodeGenCXX/captured-statements.cpp
+++ test/CodeGenCXX/captured-statements.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3
@@ -194,3 +194,18 @@
 void call_test_captured_linkage() {
   test_captured_linkage();
 }
+
+// CHECK-1-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-1-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-2-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-2-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-3-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-3-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-4-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-4-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-5-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-5-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-6-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-6-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
+// CHECK-7-DAG: !DILocalVariable(name: "this", {{.*}}, flags: DIFlagArtificial | DIFlagObjectPointer)
+// CHECK-7-DAG: !DILocalVariable(name: "__context", {{.*}}, flags: DIFlagArtificial)
Index: test/CodeGen/captured-statements.c
===
--- test/CodeGen/captured-statements.c
+++ test/CodeGen/captured-statements.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
@@ -98,3 +98,8 @@
 // CHECK-GLOBALS:   load i32, i32* @global
 // CHECK-GLOBALS:   load i32, i32* @
 // CHECK-GLOBALS:   load i32, i32* @e
+
+// CHECK-GLOBALS-NOT: DIFlagObjectPointer
+// CHECK-1-NOT: DIFlagObjectPointer
+// CHECK-2-NOT: DIFlagObjectPointer
+// CHECK-3-NOT: DIFlagObjectPointer
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -967,6 +967,7 @@
 
 void ASTDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) {
   VisitVarDecl(D);
+  Record.push_back(D->getParameterKind());
   Code = serialization::DECL_IMPLICIT_PARAM;
 }
 
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1278,6 +1278,8 @@
 
 void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) {
   VisitVarDecl(PD);
+  PD->ParamKind =
+  static_cast(Record.readInt());
 }
 
 void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -3956,8 +3956,9 @@
   DeclContext *DC = CapturedDecl::castToDeclContext(CD);
   IdentifierInfo *ParamName = &Context.Idents.get("__context");
   QualType ParamType = Context.getPointerType(Context.getTagDeclType(RD));
-  ImplicitParamDecl *Param
-= ImplicitParamDecl::Create(Context, DC, Loc, ParamName, ParamType);
+  ImplicitPar

[PATCH] D33877: [test] Fix baremetal test to allow any -resource-dir

2017-06-05 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM... thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D33877



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


[PATCH] D33259: Don't defer to the GCC driver for linking arm-baremetal

2017-06-05 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In https://reviews.llvm.org/D33259#772184, @mgorny wrote:

> This causes a test failure with non-standard CLANG_RESOURCE_DIR:


https://reviews.llvm.org/D33877

(thanks for the patch)


https://reviews.llvm.org/D33259



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


r304715 - [test] Fix baremetal test to allow any -resource-dir

2017-06-05 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Mon Jun  5 09:13:37 2017
New Revision: 304715

URL: http://llvm.org/viewvc/llvm-project?rev=304715&view=rev
Log:
[test] Fix baremetal test to allow any -resource-dir

The baremetal test (r303873) has been added with expectance of very
specific -resource-dir. However, the test itself nor the BareMetal
driver does not enforce any specific -resource-dir, making this
constraint invalid. It already has been altered twice -- in r303910 for
Windows compatibility, and in r304085 for systems using lib64. To
account for even more systems, just use [[RESOURCE_DIR]] like a number
of other tests do. This is needed for Gentoo where RESOURCE_DIR starts
with ../ (uses relative path to a parent directory).

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

Modified:
cfe/trunk/test/Driver/baremetal.cpp

Modified: cfe/trunk/test/Driver/baremetal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/baremetal.cpp?rev=304715&r1=304714&r2=304715&view=diff
==
--- cfe/trunk/test/Driver/baremetal.cpp (original)
+++ cfe/trunk/test/Driver/baremetal.cpp Mon Jun  5 09:13:37 2017
@@ -5,13 +5,13 @@
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
 // CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" 
"-cc1" "-triple" "thumbv6m-none--eabi"
-// CHECK-V6M-C-SAME: "-resource-dir" 
"[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]"
+// CHECK-V6M-C-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
 // CHECK-V6M-C-SAME: "-internal-isystem" 
"[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include"
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld" "{{.*}}.o" "-Bstatic"
-// CHECK-V6M-C-SAME: 
"-L[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"


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


[PATCH] D33877: [test] Fix baremetal test to allow any -resource-dir

2017-06-05 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304715: [test] Fix baremetal test to allow any -resource-dir 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D33877?vs=101351&id=101403#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33877

Files:
  cfe/trunk/test/Driver/baremetal.cpp


Index: cfe/trunk/test/Driver/baremetal.cpp
===
--- cfe/trunk/test/Driver/baremetal.cpp
+++ cfe/trunk/test/Driver/baremetal.cpp
@@ -5,13 +5,13 @@
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
 // CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" 
"-cc1" "-triple" "thumbv6m-none--eabi"
-// CHECK-V6M-C-SAME: "-resource-dir" 
"[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]"
+// CHECK-V6M-C-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
 // CHECK-V6M-C-SAME: "-internal-isystem" 
"[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include"
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld" "{{.*}}.o" "-Bstatic"
-// CHECK-V6M-C-SAME: 
"-L[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"


Index: cfe/trunk/test/Driver/baremetal.cpp
===
--- cfe/trunk/test/Driver/baremetal.cpp
+++ cfe/trunk/test/Driver/baremetal.cpp
@@ -5,13 +5,13 @@
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
 // CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none--eabi"
-// CHECK-V6M-C-SAME: "-resource-dir" "[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]"
+// CHECK-V6M-C-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
 // CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include"
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld" "{{.*}}.o" "-Bstatic"
-// CHECK-V6M-C-SAME: "-L[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33893: Align definition of DW_OP_plus with DWARF spec [2/3]

2017-06-05 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Thanks, this LGTM!


https://reviews.llvm.org/D33893



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


[PATCH] D33852: Enable __declspec(selectany) on linux

2017-06-05 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: include/clang/Basic/Attr.td:2421
 
-def SelectAny : InheritableAttr, TargetSpecificAttr {
+def SelectAny : InheritableAttr, TargetSpecificAttr {
   let Spellings = [Declspec<"selectany">, GCC<"selectany">];

majnemer wrote:
> selectany should work on targets other than "x86", "x86_64", "arm", "thumb", 
> etc. I think it is only necessary to require that it be a COFF or ELF target.
Should we allow other OSes than Win32 and Linux?


https://reviews.llvm.org/D33852



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


Re: [PATCH] D33660: [coroutines] Fix assertion during -Wuninitialized analysis

2017-06-05 Thread David Blaikie via cfe-commits
On Mon, May 29, 2017 at 3:28 PM Eric Fiselier via Phabricator via
cfe-commits  wrote:

> EricWF created this revision.
>
> @rsmith Is there a better place to put this test?
>
>
> https://reviews.llvm.org/D33660
>
> Files:
>   lib/Sema/SemaCoroutine.cpp
>   test/SemaCXX/coreturn.cpp
>   test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
>
>
> Index: test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
> ===
> --- /dev/null
> +++ test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
> @@ -0,0 +1,44 @@
> +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14
> -fcoroutines-ts -fsyntax-only -Wall -Wextra -Wuninitialized  -fblocks
>

A test case that tests only "this doesn't crash" is usually a bit of a hint
to me, at least, that something's under-tested. I assume there's some
specific behavior that's desired more than "does anything other than
crashing" that should be being tested for here?


> +#include "Inputs/std-coroutine.h"
> +
> +using namespace std::experimental;
> +
> +
> +struct A {
> +  bool await_ready() { return true; }
> +  int await_resume() { return 42; }
> +  template 
> +  void await_suspend(F) {}
> +};
> +
> +
> +struct coro_t {
> +  struct promise_type {
> +coro_t get_return_object() { return {}; }
> +suspend_never initial_suspend() { return {}; }
> +suspend_never final_suspend() { return {}; }
> +A yield_value(int) { return {}; }
> +void return_void() {}
> +static void unhandled_exception() {}
> +  };
> +};
> +
> +coro_t f(int n) {
> +  if (n == 0)
> +co_return;
> +  co_yield 42;
> +  int x = co_await A{};
> +}
> +
> +template 
> +coro_t g(int n) {
> +  if (n == 0)
> +co_return;
> +  co_yield 42;
> +  int x = co_await Await{};
> +}
> +
> +int main() {
> +  f(0);
> +  g(0);
> +}
> Index: test/SemaCXX/coreturn.cpp
> ===
> --- test/SemaCXX/coreturn.cpp
> +++ test/SemaCXX/coreturn.cpp
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14
> -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type
> -verify -fblocks -Wno-unreachable-code -Wno-unused-value
> +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14
> -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type
> -verify -fblocks -Wall -Wextra -Wno-error=unreachable-code
>  #include "Inputs/std-coroutine.h"
>
>  using std::experimental::suspend_always;
> Index: lib/Sema/SemaCoroutine.cpp
> ===
> --- lib/Sema/SemaCoroutine.cpp
> +++ lib/Sema/SemaCoroutine.cpp
> @@ -437,6 +437,7 @@
>if (VD->isInvalidDecl())
>  return nullptr;
>ActOnUninitializedDecl(VD);
> +  FD->addDecl(VD);
>assert(!VD->isInvalidDecl());
>return VD;
>  }
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r304190 - Diagnose attempts to build a preprocessed module that defines an unavailable submodule.

2017-06-05 Thread David Blaikie via cfe-commits
On Mon, May 29, 2017 at 10:23 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue May 30 00:22:59 2017
> New Revision: 304190
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304190&view=rev
> Log:
> Diagnose attempts to build a preprocessed module that defines an
> unavailable submodule.
>
> The errors we would otherwise get are incomprehensible, as we would enter
> the
> module but not make its contents visible to itself.
>
> Added:
> cfe/trunk/test/Modules/preprocess-unavailable.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> cfe/trunk/lib/Lex/Pragma.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=304190&r1=304189&r2=304190&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue May 30
> 00:22:59 2017
> @@ -525,6 +525,8 @@ def err_pp_module_begin_without_module_e
>  def err_pp_module_end_without_module_begin : Error<
>"no matching '#pragma clang module begin' for this "
>"'#pragma clang module end'">;
> +def note_pp_module_begin_here : Note<
> +  "entering module '%0' due to this pragma">;
>
>  def err_defined_macro_name : Error<"'defined' cannot be used as a macro
> name">;
>  def err_paste_at_start : Error<
>
> Modified: cfe/trunk/lib/Lex/Pragma.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=304190&r1=304189&r2=304190&view=diff
>
> ==
> --- cfe/trunk/lib/Lex/Pragma.cpp (original)
> +++ cfe/trunk/lib/Lex/Pragma.cpp Tue May 30 00:22:59 2017
> @@ -1407,6 +1407,24 @@ struct PragmaModuleBeginHandler : public
>M = NewM;
>  }
>
> +// If the module isn't available, it doesn't make sense to enter it.
> +if (!M->isAvailable()) {
> +  Module::Requirement Requirement;
> +  Module::UnresolvedHeaderDirective MissingHeader;
> +  (void)M->isAvailable(PP.getLangOpts(), PP.getTargetInfo(),
> +   Requirement, MissingHeader);
>

This looks a tad weird ^ should this function have a different name (or a
version of the function that only does the side-effecting work that I'm
guessing is desired here)?


> +  if (MissingHeader.FileNameLoc.isValid()) {
> +PP.Diag(MissingHeader.FileNameLoc,
> diag::err_module_header_missing)
> +  << MissingHeader.IsUmbrella << MissingHeader.FileName;
> +  } else {
> +PP.Diag(M->DefinitionLoc, diag::err_module_unavailable)
> +  << M->getFullModuleName() << Requirement.second <<
> Requirement.first;
> +  }
> +  PP.Diag(BeginLoc, diag::note_pp_module_begin_here)
> +<< M->getTopLevelModuleName();
> +  return;
> +}
> +
>  // Enter the scope of the submodule.
>  PP.EnterSubmodule(M, BeginLoc, /*ForPragma*/true);
>  PP.EnterAnnotationToken(SourceRange(BeginLoc,
> ModuleName.back().second),
>
> Added: cfe/trunk/test/Modules/preprocess-unavailable.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess-unavailable.cpp?rev=304190&view=auto
>
> ==
> --- cfe/trunk/test/Modules/preprocess-unavailable.cpp (added)
> +++ cfe/trunk/test/Modules/preprocess-unavailable.cpp Tue May 30 00:22:59
> 2017
> @@ -0,0 +1,12 @@
> +// RUN: %clang_cc1 -x c++-module-map %s -fmodule-name=a -verify
> +module a {
> +  module b {
> +requires cplusplus11
> +  }
> +}
> +#pragma clang module contents
> +// expected-error@3 {{module 'a.b' requires feature 'cplusplus11'}}
> +#pragma clang module begin a.b // expected-note {{entering module 'a' due
> to this pragma}}
> +int f();
> +int g() { f(); }
> +#pragma clang module end // expected-error {{no matching '#pragma clang
> module begin'}}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D33708: [test] [libcxx] Disable MSVC++'s compare(a, b) implies !compare(b, a) assertion in predicate application count tests

2017-06-05 Thread David Blaikie via cfe-commits
Alternatively, you could disable the check (or change the count it checks)
if this is defined. (& if you disable the check when this is defined, you
could change an existing build/test config (or add a new one) to have this
disabled)

On Tue, May 30, 2017 at 8:19 PM Billy Robert O'Neal III via Phabricator via
cfe-commits  wrote:

> BillyONeal abandoned this revision.
> BillyONeal added a comment.
>
> Stephan pointed out that the force include breaks this. Backing it out for
> now :(
>
>
> https://reviews.llvm.org/D33708
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33900: Print registered targets in clang's version information

2017-06-05 Thread Dimitry Andric via Phabricator via cfe-commits
dim created this revision.

Other llvm tools display their registered targets when showing version
information, but for some reason clang has never done this.

To support this, https://reviews.llvm.org/D33899 adds the llvm parts, which 
make it possible to
print version information to arbitrary raw_ostreams.  This change adds
a call to printRegisteredTargetsForVersion in clang's PrintVersion, and
adds a raw_ostream parameter to two other PrintVersion functions.


https://reviews.llvm.org/D33900

Files:
  lib/Driver/Driver.cpp
  tools/clang-format/ClangFormat.cpp
  tools/clang-offload-bundler/ClangOffloadBundler.cpp


Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -915,8 +915,7 @@
   return false;
 }
 
-static void PrintVersion() {
-  raw_ostream &OS = outs();
+static void PrintVersion(raw_ostream &OS) {
   OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n';
 }
 
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -328,8 +328,7 @@
 }  // namespace format
 }  // namespace clang
 
-static void PrintVersion() {
-  raw_ostream &OS = outs();
+static void PrintVersion(raw_ostream &OS) {
   OS << clang::getClangToolFullVersion("clang-format") << '\n';
 }
 
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
+#include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1116,6 +1117,10 @@
 
   // Print out the install directory.
   OS << "InstalledDir: " << InstalledDir << '\n';
+
+  // Print registered targets.
+  OS << '\n';
+  llvm::TargetRegistry::printRegisteredTargetsForVersion(OS);
 }
 
 /// PrintDiagnosticCategories - Implement the --print-diagnostic-categories


Index: tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -915,8 +915,7 @@
   return false;
 }
 
-static void PrintVersion() {
-  raw_ostream &OS = outs();
+static void PrintVersion(raw_ostream &OS) {
   OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n';
 }
 
Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -328,8 +328,7 @@
 }  // namespace format
 }  // namespace clang
 
-static void PrintVersion() {
-  raw_ostream &OS = outs();
+static void PrintVersion(raw_ostream &OS) {
   OS << clang::getClangToolFullVersion("clang-format") << '\n';
 }
 
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
+#include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1116,6 +1117,10 @@
 
   // Print out the install directory.
   OS << "InstalledDir: " << InstalledDir << '\n';
+
+  // Print registered targets.
+  OS << '\n';
+  llvm::TargetRegistry::printRegisteredTargetsForVersion(OS);
 }
 
 /// PrintDiagnosticCategories - Implement the --print-diagnostic-categories
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D33750: CGCleanup: (NFC) add a test that used to trigger broken IR

2017-06-05 Thread David Blaikie via cfe-commits
On Wed, May 31, 2017 at 5:45 PM Gor Nishanov via Phabricator via
cfe-commits  wrote:

> GorNishanov created this revision.
>
> Coroutine related test that used to trigger broken IR prior to r304335.
>
>
> https://reviews.llvm.org/D33750
>
> Files:
>   test/CodeGenCoroutines/coro-await-domination.cpp
>
>
> Index: test/CodeGenCoroutines/coro-await-domination.cpp
> ===
> --- /dev/null
> +++ test/CodeGenCoroutines/coro-await-domination.cpp
> @@ -0,0 +1,38 @@
> +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts
> -std=c++14 -emit-llvm %s -o - | FileCheck %s

+#include "Inputs/coroutine.h"
> +
> +using namespace std::experimental;
> +
> +struct coro {
> +  struct promise_type {
> +coro get_return_object();
> +suspend_never initial_suspend();
> +suspend_never final_suspend();
> +void return_void();
> +static void unhandled_exception();
> +  };
> +};
> +
> +struct A {
> +  ~A();
> +  bool await_ready();
> +  int await_resume() { return 8; }
> +  template  void await_suspend(F);
> +};
> +
> +extern "C" void consume(int);
> +
> +// Verifies that domination is properly built during cleanup.
> +// Without CGCleanup.cpp fix verifier was reporting:
> +// Instruction does not dominate all uses!
> +//  %tmp.exprcleanup = alloca i32*, align 8
> +//  store i32* %x, i32** %tmp.exprcleanup, align 8
> +
> +
> +// CHECK-LABEL: f(
>

This doesn't seem to check much. Should this test check that the IR
instructions have the 'good' layout, more than that the verifier doesn't
fail?

Or is that already tested by the test case added in r304335? In that case I
wouldn't add this test. If the change can/is tested in isolation in Clang,
that should be sufficient/tends to be how testing is done in the regression
test suites in the LLVM project. (the test-suite is the place for
broader/end-to-end testing)


> +extern "C" coro f(int) {
> +  int x = 42;
> +  x = co_await A{};
> +  consume(x);
> +}
> +
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D33765: Show correct column nr. when multi-byte utf8 chars are used.

2017-06-05 Thread David Blaikie via cfe-commits
Is it right to only change the behavior of this caller? Presumably other
callers (like getSpellingColumnNumber, getExpansionColumnNumber, etc)
probably want the same handling? Do any callers /not/ want this behavior?

On Thu, Jun 1, 2017 at 3:14 AM Erik Verbruggen via Phabricator via
cfe-commits  wrote:

> erikjv created this revision.
>
> Previously, the column number in a diagnostic would be the byte position
> in the line. This results in incorrect column numbers when a multi-byte
> UTF-8 character would be present in the input. By ignoring all bytes
> starting with 0b10 the correct column number is created.
>
> This fixes PR21144.
>
>
> https://reviews.llvm.org/D33765
>
> Files:
>   include/clang/Basic/SourceManager.h
>   lib/Basic/SourceManager.cpp
>   test/Misc/diag-utf8.cpp
>
>
> Index: test/Misc/diag-utf8.cpp
> ===
> --- /dev/null
> +++ test/Misc/diag-utf8.cpp
> @@ -0,0 +1,11 @@
> +// RUN: not %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
> +
> +struct Foo { int member; };
> +
> +void f(Foo foo)
> +{
> +"ideeen" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:7:14: error:
> invalid operands to binary expression ('const char *' and 'Foo')
> +"ideëen" << foo; // CHECK: {{.*[/\\]}}diag-utf8.cpp:8:14: error:
> invalid operands to binary expression ('const char *' and 'Foo')
> +}
> +
> +
> Index: lib/Basic/SourceManager.cpp
> ===
> --- lib/Basic/SourceManager.cpp
> +++ lib/Basic/SourceManager.cpp
> @@ -1055,11 +1055,22 @@
>return Buffer->getBufferStart() + (CharDataInvalid? 0 : LocInfo.second);
>  }
>
> +static unsigned correctForMultiByteChars(const char *Buf, unsigned
> LineStart,
> + unsigned Column)
> +{
> +unsigned CorrectedColumn = Column;
> +for (unsigned I = 0; I < Column; ++I) {
> +if ((Buf[LineStart + I] & 0xc0) == 0x80)
> +--CorrectedColumn;
> +}
> +return CorrectedColumn;
> +}
>
>  /// getColumnNumber - Return the column # for the specified file position.
>  /// this is significantly cheaper to compute than the line number.
>  unsigned SourceManager::getColumnNumber(FileID FID, unsigned FilePos,
> -bool *Invalid) const {
> +bool *Invalid,
> +bool BytePosition) const {
>bool MyInvalid = false;
>llvm::MemoryBuffer *MemBuf = getBuffer(FID, &MyInvalid);
>if (Invalid)
> @@ -1093,14 +1104,18 @@
>  if (Buf[FilePos - 1] == '\r' || Buf[FilePos - 1] == '\n')
>--FilePos;
>}
> -  return FilePos - LineStart + 1;
> +  unsigned Column = FilePos - LineStart + 1;
> +  return BytePosition ? Column : correctForMultiByteChars(Buf,
> LineStart,
> +  Column);
>  }
>}
>
>unsigned LineStart = FilePos;
>while (LineStart && Buf[LineStart-1] != '\n' && Buf[LineStart-1] !=
> '\r')
>  --LineStart;
> -  return FilePos-LineStart+1;
> +  unsigned Column = FilePos - LineStart + 1;
> +  return BytePosition ? Column : correctForMultiByteChars(Buf, LineStart,
> +  Column);
>  }
>
>  // isInvalid - Return the result of calling loc.isInvalid(), and
> @@ -1425,7 +1440,8 @@
>unsigned LineNo = getLineNumber(LocInfo.first, LocInfo.second,
> &Invalid);
>if (Invalid)
>  return PresumedLoc();
> -  unsigned ColNo  = getColumnNumber(LocInfo.first, LocInfo.second,
> &Invalid);
> +  unsigned ColNo  = getColumnNumber(LocInfo.first, LocInfo.second,
> &Invalid,
> +false);
>if (Invalid)
>  return PresumedLoc();
>
> Index: include/clang/Basic/SourceManager.h
> ===
> --- include/clang/Basic/SourceManager.h
> +++ include/clang/Basic/SourceManager.h
> @@ -1275,7 +1275,8 @@
>/// on a file sloc, so you must choose a spelling or expansion location
>/// before calling this method.
>unsigned getColumnNumber(FileID FID, unsigned FilePos,
> -   bool *Invalid = nullptr) const;
> +   bool *Invalid = nullptr,
> +   bool BytePosition = true) const;
>unsigned getSpellingColumnNumber(SourceLocation Loc,
> bool *Invalid = nullptr) const;
>unsigned getExpansionColumnNumber(SourceLocation Loc,
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33448: [CodeGen] Add thumb-mode to target-features for arm/thumb triples.

2017-06-05 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

I've discovered another problem while doing an ARM bootstrap build with mixed 
ARM/Thumb codegen. With https://reviews.llvm.org/D33898 , the bootstrap build 
with mixed ARM/Thumb code works properly. After that's in I'll finally commit 
this patch.


https://reviews.llvm.org/D33448



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


Re: [clang-tools-extra] r304583 - [clang-tidy] Add `const` to operator() to fix a warning.

2017-06-05 Thread David Blaikie via cfe-commits
what was the warning?

On Fri, Jun 2, 2017 at 11:48 AM Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Fri Jun  2 13:47:50 2017
> New Revision: 304583
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304583&view=rev
> Log:
> [clang-tidy] Add `const` to operator() to fix a warning.
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h
>
> Modified: clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h?rev=304583&r1=304582&r2=304583&view=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/misc/LambdaFunctionNameCheck.h Fri
> Jun  2 13:47:50 2017
> @@ -25,7 +25,7 @@ namespace misc {
>  class LambdaFunctionNameCheck : public ClangTidyCheck {
>  public:
>struct SourceRangeLessThan {
> -bool operator()(const SourceRange &L, const SourceRange &R) {
> +bool operator()(const SourceRange &L, const SourceRange &R) const {
>if (L.getBegin() == R.getBegin()) {
>  return L.getEnd() < R.getEnd();
>}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33721: [ARM] Add support for target("arm") and target("thumb").

2017-06-05 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 101427.
fhahn marked an inline comment as done.
fhahn added a comment.

use else if


https://reviews.llvm.org/D33721

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/arm-target-attr.c


Index: test/CodeGen/arm-target-attr.c
===
--- /dev/null
+++ test/CodeGen/arm-target-attr.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck 
--check-prefix CHECKPOS %s
+// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck 
--check-prefix CHECKNEG %s
+// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck 
--check-prefix CHECKPOS %s
+// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck 
--check-prefix CHECKNEG %s
+
+__attribute__((target("arm"))) void test_target_arm() {
+  // CHECKPOS: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]]
+  // CHECKNEG: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]]
+}
+
+__attribute__((target("thumb"))) void test_target_thumb() {
+  // CHECKPOS: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]]
+  // CHECKNEG: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]]
+}
+
+// CHECKPOS: attributes [[ARM_ATTRS]] = { {{.*}} 
"target-features"="{{.*}}-thumb-mode{{.*}}"
+// CHECKPOS: attributes [[THUMB_ATTRS]] = { {{.*}} 
"target-features"="{{.*}}+thumb-mode{{.*}}"
+// CHECKNEG-NOT: attributes [[ARM_ATTRS]] = { {{.*}} 
"target-features"="{{.*}}+thumb-mode{{.*}}"
+// CHECKNEG-NOT: attributes [[THUMB_ATTRS]] = { {{.*}} 
"target-features"="{{.*}}-thumb-mode{{.*}}"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5438,7 +5438,17 @@
   if (Feature[0] == '+')
 Features[Feature.drop_front(1)] = true;
 
-return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+// Convert user-provided arm and thumb GNU target attributes to
+// [-|+]thumb-mode target features respectively.
+std::vector UpdatedFeaturesVec(FeaturesVec);
+for (auto &Feature : UpdatedFeaturesVec) {
+  if (Feature.compare("+arm") == 0)
+Feature = "-thumb-mode";
+  else if (Feature.compare("+thumb") == 0)
+Feature = "+thumb-mode";
+}
+
+return TargetInfo::initFeatureMap(Features, Diags, CPU, 
UpdatedFeaturesVec);
   }
 
   bool handleTargetFeatures(std::vector &Features,


Index: test/CodeGen/arm-target-attr.c
===
--- /dev/null
+++ test/CodeGen/arm-target-attr.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKPOS %s
+// RUN: %clang_cc1 -triple thumb-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKNEG %s
+// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKPOS %s
+// RUN: %clang_cc1 -triple arm-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix CHECKNEG %s
+
+__attribute__((target("arm"))) void test_target_arm() {
+  // CHECKPOS: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]]
+  // CHECKNEG: define void @test_target_arm() [[ARM_ATTRS:#[0-9]+]]
+}
+
+__attribute__((target("thumb"))) void test_target_thumb() {
+  // CHECKPOS: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]]
+  // CHECKNEG: define void @test_target_thumb() [[THUMB_ATTRS:#[0-9]+]]
+}
+
+// CHECKPOS: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="{{.*}}-thumb-mode{{.*}}"
+// CHECKPOS: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="{{.*}}+thumb-mode{{.*}}"
+// CHECKNEG-NOT: attributes [[ARM_ATTRS]] = { {{.*}} "target-features"="{{.*}}+thumb-mode{{.*}}"
+// CHECKNEG-NOT: attributes [[THUMB_ATTRS]] = { {{.*}} "target-features"="{{.*}}-thumb-mode{{.*}}"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -5438,7 +5438,17 @@
   if (Feature[0] == '+')
 Features[Feature.drop_front(1)] = true;
 
-return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+// Convert user-provided arm and thumb GNU target attributes to
+// [-|+]thumb-mode target features respectively.
+std::vector UpdatedFeaturesVec(FeaturesVec);
+for (auto &Feature : UpdatedFeaturesVec) {
+  if (Feature.compare("+arm") == 0)
+Feature = "-thumb-mode";
+  else if (Feature.compare("+thumb") == 0)
+Feature = "+thumb-mode";
+}
+
+return TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec);
   }
 
   bool handleTargetFeatures(std::vector &Features,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r299921 - [lsan] Enable LSan on arm Linux, clang part

2017-06-05 Thread David Blaikie via cfe-commits
This change seemed to be buggy (& I assume missing test coverage to
demonstrate that). Galina fixed it in
http://llvm.org/viewvc/llvm-project?rev=304663&view=rev based on a compiler
warning.

Can you add test coverage to this code to exercise these untested codepaths?

On Tue, Apr 11, 2017 at 12:34 AM Maxim Ostapenko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: chefmax
> Date: Tue Apr 11 02:22:11 2017
> New Revision: 299921
>
> URL: http://llvm.org/viewvc/llvm-project?rev=299921&view=rev
> Log:
> [lsan] Enable LSan on arm Linux, clang part
>
> This is a compiler part of https://reviews.llvm.org/D29586. Enable LSan
> on arm Linux.
>
> Differential Revision: https://reviews.llvm.org/D31760
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains/Linux.cpp
> cfe/trunk/test/Driver/fsanitize.c
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=299921&r1=299920&r2=299921&view=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Tue Apr 11 02:22:11 2017
> @@ -864,6 +864,9 @@ SanitizerMask Linux::getSupportedSanitiz
> getTriple().getArch() == llvm::Triple::ppc64le;
>const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 ||
>   getTriple().getArch() ==
> llvm::Triple::aarch64_be;
> +  const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm ||
> + llvm::Triple::thumb || llvm::Triple::armeb ||
> + llvm::Triple::thumbeb;
>SanitizerMask Res = ToolChain::getSupportedSanitizers();
>Res |= SanitizerKind::Address;
>Res |= SanitizerKind::KernelAddress;
> @@ -871,7 +874,7 @@ SanitizerMask Linux::getSupportedSanitiz
>Res |= SanitizerKind::SafeStack;
>if (IsX86_64 || IsMIPS64 || IsAArch64)
>  Res |= SanitizerKind::DataFlow;
> -  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86)
> +  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch)
>  Res |= SanitizerKind::Leak;
>if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
>  Res |= SanitizerKind::Thread;
>
> Modified: cfe/trunk/test/Driver/fsanitize.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=299921&r1=299920&r2=299921&view=diff
>
> ==
> --- cfe/trunk/test/Driver/fsanitize.c (original)
> +++ cfe/trunk/test/Driver/fsanitize.c Tue Apr 11 02:22:11 2017
> @@ -237,6 +237,30 @@
>  // RUN: %clang -target i686-linux-gnu -fsanitize=address,leak
> -fno-sanitize=address %s -### 2>&1 | FileCheck %s
> --check-prefix=CHECK-SANA-SANL-NO-SANA-X86
>  // CHECK-SANA-SANL-NO-SANA-X86: "-fsanitize=leak"
>
> +// RUN: %clang -target arm-linux-gnu -fsanitize=leak %s -### 2>&1 |
> FileCheck %s --check-prefix=CHECK-SANL-ARM
> +// CHECK-SANL-ARM: "-fsanitize=leak"
> +
> +// RUN: %clang -target arm-linux-gnu -fsanitize=address,leak
> -fno-sanitize=address %s -### 2>&1 | FileCheck %s
> --check-prefix=CHECK-SANA-SANL-NO-SANA-ARM
> +// CHECK-SANA-SANL-NO-SANA-ARM: "-fsanitize=leak"
> +
> +// RUN: %clang -target thumb-linux -fsanitize=leak %s -### 2>&1 |
> FileCheck %s --check-prefix=CHECK-SANL-THUMB
> +// CHECK-SANL-THUMB: "-fsanitize=leak"
> +
> +// RUN: %clang -target thumb-linux -fsanitize=address,leak
> -fno-sanitize=address %s -### 2>&1 | FileCheck %s
> --check-prefix=CHECK-SANA-SANL-NO-SANA-THUMB
> +// CHECK-SANA-SANL-NO-SANA-THUMB: "-fsanitize=leak"
> +
> +// RUN: %clang -target armeb-linux-gnu -fsanitize=leak %s -### 2>&1 |
> FileCheck %s --check-prefix=CHECK-SANL-ARMEB
> +// CHECK-SANL-ARMEB: "-fsanitize=leak"
> +
> +// RUN: %clang -target armeb-linux-gnu -fsanitize=address,leak
> -fno-sanitize=address %s -### 2>&1 | FileCheck %s
> --check-prefix=CHECK-SANA-SANL-NO-SANA-ARMEB
> +// CHECK-SANA-SANL-NO-SANA-ARMEB: "-fsanitize=leak"
> +
> +// RUN: %clang -target thumbeb-linux -fsanitize=leak %s -### 2>&1 |
> FileCheck %s --check-prefix=CHECK-SANL-THUMBEB
> +// CHECK-SANL-THUMBEB: "-fsanitize=leak"
> +
> +// RUN: %clang -target thumbeb-linux -fsanitize=address,leak
> -fno-sanitize=address %s -### 2>&1 | FileCheck %s
> --check-prefix=CHECK-SANA-SANL-NO-SANA-THUMBEB
> +// CHECK-SANA-SANL-NO-SANA-THUMBEB: "-fsanitize=leak"
> +
>  // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 |
> FileCheck %s --check-prefix=CHECK-MSAN
>  // CHECK-MSAN: "-fno-assume-sane-operator-new"
>  // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 |
> FileCheck %s --check-prefix=CHECK-ASAN
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

Re: r304663 - Fixed warning: enum constant in boolean context.

2017-06-05 Thread David Blaikie via cfe-commits
I followed up on the original commit (r299921) to request that as well.

On Sat, Jun 3, 2017 at 1:26 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Can we get a testcase for this bug? Seems like we can't have any coverage
> for the case where IsArmArch is supposed to be false.
>
>
> On 3 Jun 2017 9:47 am, "Galina Kistanova via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: gkistanova
> Date: Sat Jun  3 11:47:06 2017
> New Revision: 304663
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304663&view=rev
> Log:
> Fixed warning: enum constant in boolean context.
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains/Linux.cpp
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=304663&r1=304662&r2=304663&view=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Sat Jun  3 11:47:06 2017
> @@ -822,8 +822,9 @@ SanitizerMask Linux::getSupportedSanitiz
>const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 ||
>   getTriple().getArch() ==
> llvm::Triple::aarch64_be;
>const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm ||
> - llvm::Triple::thumb || llvm::Triple::armeb ||
> - llvm::Triple::thumbeb;
> + getTriple().getArch() == llvm::Triple::thumb ||
> + getTriple().getArch() == llvm::Triple::armeb ||
> + getTriple().getArch() == llvm::Triple::thumbeb;
>SanitizerMask Res = ToolChain::getSupportedSanitizers();
>Res |= SanitizerKind::Address;
>Res |= SanitizerKind::Fuzzer;
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33478: [libclang] When getting platform availabilities, merge multiple declarations if possible

2017-06-05 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: tools/libclang/CIndex.cpp:7322
+
+  for (int I = 0, E = AvailabilityAttrs.size(); I < E && I < availability_size;
+   ++I) {

rdwampler wrote:
> arphaman wrote:
> > You can use a ranged for loop here if you use `take_front`, e.g.
> > 
> > ```
> > for (const auto *Avail : AvailabilityAttrs.take_front(availability_size))
> > ```
> I would need to covert this to an `ArrayRef`, I believe. Also, I would need 
> to check `availability_size` is in bounds. Would something like the following 
> be preferred:
> ```
> int N = 0;
> for (const auto *Avail : AvailabilityAttrs) {
>   if (N < availability_size) {
> // populate availability
> N++;
>   }
> }
> ```
Right, sorry I forgot about the `N`.
I think that you can use 
`llvm::enumerate(llvm::makeArrayRef(AvailabilityAttrs).take_front(availability_size))`
 to get rid of `N` as well, as you can the index and the attribute pointer from 
the loop variable.
Btw, The `take_front(N)` will ensure that you will only iterate either over the 
first N attributes or all of the attributes if `N > AvailabilityAttrs.size()`, 
so you won't need to check `N` in the loop.


https://reviews.llvm.org/D33478



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


[PATCH] D33875: PR27037: Use correct CVR qualifier on an upcast on method pointer call

2017-06-05 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik added a comment.

Hi, Richard.
Could you PTAL to this?


https://reviews.llvm.org/D33875



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


Re: r299921 - [lsan] Enable LSan on arm Linux, clang part

2017-06-05 Thread Maxim Ostapenko via cfe-commits

On 05/06/17 20:16, David Blaikie wrote:
This change seemed to be buggy (& I assume missing test coverage to 
demonstrate that). Galina fixed it in 
http://llvm.org/viewvc/llvm-project?rev=304663&view=rev based on a 
compiler warning.


Oh, right, I've missed that. Sorry!



Can you add test coverage to this code to exercise these untested 
codepaths?


But doesn't https://reviews.llvm.org/rL299921 introduce testcases for 
arm, thumb, armeb and thumbeb targets to clang driver? Or perhaps I'm 
missing something?


-Maxim



On Tue, Apr 11, 2017 at 12:34 AM Maxim Ostapenko via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:


Author: chefmax
Date: Tue Apr 11 02:22:11 2017
New Revision: 299921

URL: http://llvm.org/viewvc/llvm-project?rev=299921&view=rev
Log:
[lsan] Enable LSan on arm Linux, clang part

This is a compiler part of https://reviews.llvm.org/D29586. Enable
LSan on arm Linux.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=299921&r1=299920&r2=299921&view=diff

==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Tue Apr 11 02:22:11 2017
@@ -864,6 +864,9 @@ SanitizerMask Linux::getSupportedSanitiz
getTriple().getArch() ==
llvm::Triple::ppc64le;
   const bool IsAArch64 = getTriple().getArch() ==
llvm::Triple::aarch64 ||
  getTriple().getArch() ==
llvm::Triple::aarch64_be;
+  const bool IsArmArch = getTriple().getArch() ==
llvm::Triple::arm ||
+ llvm::Triple::thumb ||
llvm::Triple::armeb ||
+ llvm::Triple::thumbeb;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::KernelAddress;
@@ -871,7 +874,7 @@ SanitizerMask Linux::getSupportedSanitiz
   Res |= SanitizerKind::SafeStack;
   if (IsX86_64 || IsMIPS64 || IsAArch64)
 Res |= SanitizerKind::DataFlow;
-  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch)
 Res |= SanitizerKind::Leak;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;

Modified: cfe/trunk/test/Driver/fsanitize.c
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=299921&r1=299920&r2=299921&view=diff

==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Tue Apr 11 02:22:11 2017
@@ -237,6 +237,30 @@
 // RUN: %clang -target i686-linux-gnu -fsanitize=address,leak
-fno-sanitize=address %s -### 2>&1 | FileCheck %s
--check-prefix=CHECK-SANA-SANL-NO-SANA-X86
 // CHECK-SANA-SANL-NO-SANA-X86: "-fsanitize=leak"

+// RUN: %clang -target arm-linux-gnu -fsanitize=leak %s -### 2>&1
| FileCheck %s --check-prefix=CHECK-SANL-ARM
+// CHECK-SANL-ARM: "-fsanitize=leak"
+
+// RUN: %clang -target arm-linux-gnu -fsanitize=address,leak
-fno-sanitize=address %s -### 2>&1 | FileCheck %s
--check-prefix=CHECK-SANA-SANL-NO-SANA-ARM
+// CHECK-SANA-SANL-NO-SANA-ARM: "-fsanitize=leak"
+
+// RUN: %clang -target thumb-linux -fsanitize=leak %s -### 2>&1 |
FileCheck %s --check-prefix=CHECK-SANL-THUMB
+// CHECK-SANL-THUMB: "-fsanitize=leak"
+
+// RUN: %clang -target thumb-linux -fsanitize=address,leak
-fno-sanitize=address %s -### 2>&1 | FileCheck %s
--check-prefix=CHECK-SANA-SANL-NO-SANA-THUMB
+// CHECK-SANA-SANL-NO-SANA-THUMB: "-fsanitize=leak"
+
+// RUN: %clang -target armeb-linux-gnu -fsanitize=leak %s -###
2>&1 | FileCheck %s --check-prefix=CHECK-SANL-ARMEB
+// CHECK-SANL-ARMEB: "-fsanitize=leak"
+
+// RUN: %clang -target armeb-linux-gnu -fsanitize=address,leak
-fno-sanitize=address %s -### 2>&1 | FileCheck %s
--check-prefix=CHECK-SANA-SANL-NO-SANA-ARMEB
+// CHECK-SANA-SANL-NO-SANA-ARMEB: "-fsanitize=leak"
+
+// RUN: %clang -target thumbeb-linux -fsanitize=leak %s -### 2>&1
| FileCheck %s --check-prefix=CHECK-SANL-THUMBEB
+// CHECK-SANL-THUMBEB: "-fsanitize=leak"
+
+// RUN: %clang -target thumbeb-linux -fsanitize=address,leak
-fno-sanitize=address %s -### 2>&1 | FileCheck %s
--check-prefix=CHECK-SANA-SANL-NO-SANA-THUMBEB
+// CHECK-SANA-SANL-NO-SANA-THUMBEB: "-fsanitize=leak"
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -###
2>&1 | FileCheck %s --check-prefix=CH

Re: r299921 - [lsan] Enable LSan on arm Linux, clang part

2017-06-05 Thread David Blaikie via cfe-commits
On Mon, Jun 5, 2017 at 10:28 AM Maxim Ostapenko  wrote:

> On 05/06/17 20:16, David Blaikie wrote:
> > This change seemed to be buggy (& I assume missing test coverage to
> > demonstrate that). Galina fixed it in
> > http://llvm.org/viewvc/llvm-project?rev=304663&view=rev based on a
> > compiler warning.
>
> Oh, right, I've missed that. Sorry!
>
> >
> > Can you add test coverage to this code to exercise these untested
> > codepaths?
>
> But doesn't https://reviews.llvm.org/rL299921 introduce testcases for
> arm, thumb, armeb and thumbeb targets to clang driver?


Right, but none of the checks were being done - it was just always true.

The test coverage that's missing is something that would cause the 'if' on
line 877 in that patch to return false. So something that isn't x86_64,
isn't mips64, isn't aarch64, and isn't arm (so, maybe PPC? for example).
That test would demonstrate that lsan is still enabled in that case when it
shouldn't be, because the 'IsArmArch' is always true.


> Or perhaps I'm
> missing something?
>
> -Maxim
>
> >
> > On Tue, Apr 11, 2017 at 12:34 AM Maxim Ostapenko via cfe-commits
> > mailto:cfe-commits@lists.llvm.org>> wrote:
> >
> > Author: chefmax
> > Date: Tue Apr 11 02:22:11 2017
> > New Revision: 299921
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=299921&view=rev
> > Log:
> > [lsan] Enable LSan on arm Linux, clang part
> >
> > This is a compiler part of https://reviews.llvm.org/D29586. Enable
> > LSan on arm Linux.
> >
> > Differential Revision: https://reviews.llvm.org/D31760
> >
> > Modified:
> > cfe/trunk/lib/Driver/ToolChains/Linux.cpp
> > cfe/trunk/test/Driver/fsanitize.c
> >
> > Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
> > URL:
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=299921&r1=299920&r2=299921&view=diff
> >
>  
> ==
> > --- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
> > +++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Tue Apr 11 02:22:11
> 2017
> > @@ -864,6 +864,9 @@ SanitizerMask Linux::getSupportedSanitiz
> > getTriple().getArch() ==
> > llvm::Triple::ppc64le;
> >const bool IsAArch64 = getTriple().getArch() ==
> > llvm::Triple::aarch64 ||
> >   getTriple().getArch() ==
> > llvm::Triple::aarch64_be;
> > +  const bool IsArmArch = getTriple().getArch() ==
> > llvm::Triple::arm ||
> > + llvm::Triple::thumb ||
> > llvm::Triple::armeb ||
> > + llvm::Triple::thumbeb;
> >SanitizerMask Res = ToolChain::getSupportedSanitizers();
> >Res |= SanitizerKind::Address;
> >Res |= SanitizerKind::KernelAddress;
> > @@ -871,7 +874,7 @@ SanitizerMask Linux::getSupportedSanitiz
> >Res |= SanitizerKind::SafeStack;
> >if (IsX86_64 || IsMIPS64 || IsAArch64)
> >  Res |= SanitizerKind::DataFlow;
> > -  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86)
> > +  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch)
> >  Res |= SanitizerKind::Leak;
> >if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
> >  Res |= SanitizerKind::Thread;
> >
> > Modified: cfe/trunk/test/Driver/fsanitize.c
> > URL:
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=299921&r1=299920&r2=299921&view=diff
> >
>  
> ==
> > --- cfe/trunk/test/Driver/fsanitize.c (original)
> > +++ cfe/trunk/test/Driver/fsanitize.c Tue Apr 11 02:22:11 2017
> > @@ -237,6 +237,30 @@
> >  // RUN: %clang -target i686-linux-gnu -fsanitize=address,leak
> > -fno-sanitize=address %s -### 2>&1 | FileCheck %s
> > --check-prefix=CHECK-SANA-SANL-NO-SANA-X86
> >  // CHECK-SANA-SANL-NO-SANA-X86: "-fsanitize=leak"
> >
> > +// RUN: %clang -target arm-linux-gnu -fsanitize=leak %s -### 2>&1
> > | FileCheck %s --check-prefix=CHECK-SANL-ARM
> > +// CHECK-SANL-ARM: "-fsanitize=leak"
> > +
> > +// RUN: %clang -target arm-linux-gnu -fsanitize=address,leak
> > -fno-sanitize=address %s -### 2>&1 | FileCheck %s
> > --check-prefix=CHECK-SANA-SANL-NO-SANA-ARM
> > +// CHECK-SANA-SANL-NO-SANA-ARM: "-fsanitize=leak"
> > +
> > +// RUN: %clang -target thumb-linux -fsanitize=leak %s -### 2>&1 |
> > FileCheck %s --check-prefix=CHECK-SANL-THUMB
> > +// CHECK-SANL-THUMB: "-fsanitize=leak"
> > +
> > +// RUN: %clang -target thumb-linux -fsanitize=address,leak
> > -fno-sanitize=address %s -### 2>&1 | FileCheck %s
> > --check-prefix=CHECK-SANA-SANL-NO-SANA-THUMB
> > +// CHECK-SANA-SANL-NO-SANA-THUMB: "-fsanitize=leak"
> > +
> > +// RUN: %clang -target armeb-linux-gnu -fsanitize=leak %s -###
> > 2>&1 | FileCheck %

Re: r299921 - [lsan] Enable LSan on arm Linux, clang part

2017-06-05 Thread Maxim Ostapenko via cfe-commits

On 05/06/17 21:06, David Blaikie wrote:



On Mon, Jun 5, 2017 at 10:28 AM Maxim Ostapenko > wrote:


On 05/06/17 20:16, David Blaikie wrote:
> This change seemed to be buggy (& I assume missing test coverage to
> demonstrate that). Galina fixed it in
> http://llvm.org/viewvc/llvm-project?rev=304663&view=rev based on a
> compiler warning.

Oh, right, I've missed that. Sorry!

>
> Can you add test coverage to this code to exercise these untested
> codepaths?

But doesn't https://reviews.llvm.org/rL299921 introduce testcases for
arm, thumb, armeb and thumbeb targets to clang driver?


Right, but none of the checks were being done - it was just always true.

The test coverage that's missing is something that would cause the 
'if' on line 877 in that patch to return false. So something that 
isn't x86_64, isn't mips64, isn't aarch64, and isn't arm (so, maybe 
PPC? for example). That test would demonstrate that lsan is still 
enabled in that case when it shouldn't be, because the 'IsArmArch' is 
always true.


Ah, OK, got it. I'll prepare the patch (perhaps with PPC or MIPS).

-Maxim


Or perhaps I'm
missing something?

-Maxim

>
> On Tue, Apr 11, 2017 at 12:34 AM Maxim Ostapenko via cfe-commits
> mailto:cfe-commits@lists.llvm.org>
>> wrote:
>
> Author: chefmax
> Date: Tue Apr 11 02:22:11 2017
> New Revision: 299921
>
> URL: http://llvm.org/viewvc/llvm-project?rev=299921&view=rev
> Log:
> [lsan] Enable LSan on arm Linux, clang part
>
> This is a compiler part of https://reviews.llvm.org/D29586.
Enable
> LSan on arm Linux.
>
> Differential Revision: https://reviews.llvm.org/D31760
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains/Linux.cpp
> cfe/trunk/test/Driver/fsanitize.c
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
> URL:
>

http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=299921&r1=299920&r2=299921&view=diff
>
 
==
> --- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Tue Apr 11
02:22:11 2017
> @@ -864,6 +864,9 @@ SanitizerMask Linux::getSupportedSanitiz
> getTriple().getArch() ==
> llvm::Triple::ppc64le;
>const bool IsAArch64 = getTriple().getArch() ==
> llvm::Triple::aarch64 ||
>   getTriple().getArch() ==
> llvm::Triple::aarch64_be;
> +  const bool IsArmArch = getTriple().getArch() ==
> llvm::Triple::arm ||
> + llvm::Triple::thumb ||
> llvm::Triple::armeb ||
> + llvm::Triple::thumbeb;
>SanitizerMask Res = ToolChain::getSupportedSanitizers();
>Res |= SanitizerKind::Address;
>Res |= SanitizerKind::KernelAddress;
> @@ -871,7 +874,7 @@ SanitizerMask Linux::getSupportedSanitiz
>Res |= SanitizerKind::SafeStack;
>if (IsX86_64 || IsMIPS64 || IsAArch64)
>  Res |= SanitizerKind::DataFlow;
> -  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86)
> +  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch)
>  Res |= SanitizerKind::Leak;
>if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
>  Res |= SanitizerKind::Thread;
>
> Modified: cfe/trunk/test/Driver/fsanitize.c
> URL:
>

http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=299921&r1=299920&r2=299921&view=diff
>
 
==
> --- cfe/trunk/test/Driver/fsanitize.c (original)
> +++ cfe/trunk/test/Driver/fsanitize.c Tue Apr 11 02:22:11 2017
> @@ -237,6 +237,30 @@
>  // RUN: %clang -target i686-linux-gnu -fsanitize=address,leak
> -fno-sanitize=address %s -### 2>&1 | FileCheck %s
> --check-prefix=CHECK-SANA-SANL-NO-SANA-X86
>  // CHECK-SANA-SANL-NO-SANA-X86: "-fsanitize=leak"
>
> +// RUN: %clang -target arm-linux-gnu -fsanitize=leak %s
-### 2>&1
> | FileCheck %s --check-prefix=CHECK-SANL-ARM
> +// CHECK-SANL-ARM: "-fsanitize=leak"
> +
> +// RUN: %clang -target arm-linux-gnu -fsanitize=address,leak
> -fno-sanitize=address %s -### 2>&1 | FileCheck %s
> --check-prefix=CHECK-SANA-SANL-NO-SANA-ARM
> +// CHECK-SANA-SANL-NO-SANA-ARM: "-fsanitize=leak"
> +
> +// RUN: %clang -target thumb-linux -fsanitize=leak %s -###
2>&1 |
> FileCheck %s --check-pr

r304726 - Rather than rejecting attempts to run preprocessor-only actions on AST files,

2017-06-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun  5 13:10:11 2017
New Revision: 304726

URL: http://llvm.org/viewvc/llvm-project?rev=304726&view=rev
Log:
Rather than rejecting attempts to run preprocessor-only actions on AST files,
replay the steps taken to create the AST file with the preprocessor-only action
installed to produce preprocessed output.

This can be used to produce the preprocessed text for an existing .pch or .pcm
file.

Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/include/clang/Frontend/FrontendAction.h
cfe/trunk/lib/Basic/SourceManager.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/preprocess-module.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=304726&r1=304725&r2=304726&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Mon Jun  5 13:10:11 2017
@@ -58,6 +58,7 @@ public:
 SOB_Trapping// -ftrapv
   };
 
+  // FIXME: Unify with TUKind.
   enum CompilingModuleKind {
 CMK_None,   ///< Not compiling a module interface at all.
 CMK_ModuleMap,  ///< Compiling a module from a module map.

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=304726&r1=304725&r2=304726&view=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Jun  5 13:10:11 2017
@@ -722,6 +722,10 @@ public:
 
   void clearIDTables();
 
+  /// Initialize this source manager suitably to replay the compilation
+  /// described by \p Old. Requires that \p Old outlive \p *this.
+  void initializeForReplay(const SourceManager &Old);
+
   DiagnosticsEngine &getDiagnostics() const { return Diag; }
 
   FileManager &getFileManager() const { return FileMgr; }

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=304726&r1=304725&r2=304726&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Mon Jun  5 13:10:11 2017
@@ -51,6 +51,7 @@ class DiagnosticsEngine;
 class FileEntry;
 class FileManager;
 class HeaderSearch;
+class InputKind;
 class MemoryBufferCache;
 class Preprocessor;
 class PCHContainerOperations;
@@ -305,9 +306,6 @@ private:
   /// (likely to change while trying to use them).
   bool UserFilesAreVolatile : 1;
  
-  /// \brief The language options used when we load an AST file.
-  LangOptions ASTFileLangOpts;
-
   static void ConfigureDiags(IntrusiveRefCntPtr Diags,
  ASTUnit &AST, bool CaptureDiagnostics);
 
@@ -702,6 +700,9 @@ public:
   /// \brief Determine what kind of translation unit this AST represents.
   TranslationUnitKind getTranslationUnitKind() const { return TUKind; }
 
+  /// \brief Determine the input kind this AST unit represents.
+  InputKind getInputKind() const;
+
   /// \brief A mapping from a file name to the memory buffer that stores the
   /// remapped contents of that file.
   typedef std::pair RemappedFile;

Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=304726&r1=304725&r2=304726&view=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendAction.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendAction.h Mon Jun  5 13:10:11 2017
@@ -176,10 +176,10 @@ public:
   virtual TranslationUnitKind getTranslationUnitKind() { return TU_Complete; }
 
   /// \brief Does this action support use with PCH?
-  virtual bool hasPCHSupport() const { return !usesPreprocessorOnly(); }
+  virtual bool hasPCHSupport() const { return true; }
 
   /// \brief Does this action support use with AST files?
-  virtual bool hasASTFileSupport() const { return !usesPreprocessorOnly(); }
+  virtual bool hasASTFileSupport() const { return true; }
 
   /// \brief Does this action support use with IR files?
   virtual bool hasIRSupport() const { return false; }

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=304726&r1=304725&r2=304726&view=diff
==
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib

Re: r299921 - [lsan] Enable LSan on arm Linux, clang part

2017-06-05 Thread Galina Kistanova via cfe-commits
The tests from https://reviews.llvm.org/rL299921 are not obviously enough.
Those tests test only positive cases, thus do not catch when some flag is
always true, like the bug we are discussing. There are missing tests that
cover negative cases, when some sanitizer is not specified for a target.

Thanks

Galina


On Mon, Jun 5, 2017 at 10:28 AM, Maxim Ostapenko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On 05/06/17 20:16, David Blaikie wrote:
>
>> This change seemed to be buggy (& I assume missing test coverage to
>> demonstrate that). Galina fixed it in http://llvm.org/viewvc/llvm-pr
>> oject?rev=304663&view=rev based on a compiler warning.
>>
>
> Oh, right, I've missed that. Sorry!
>
>
>> Can you add test coverage to this code to exercise these untested
>> codepaths?
>>
>
> But doesn't https://reviews.llvm.org/rL299921 introduce testcases for
> arm, thumb, armeb and thumbeb targets to clang driver? Or perhaps I'm
> missing something?
>
> -Maxim
>
>
>> On Tue, Apr 11, 2017 at 12:34 AM Maxim Ostapenko via cfe-commits <
>> cfe-commits@lists.llvm.org > wrote:
>>
>> Author: chefmax
>> Date: Tue Apr 11 02:22:11 2017
>> New Revision: 299921
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=299921&view=rev
>> Log:
>> [lsan] Enable LSan on arm Linux, clang part
>>
>> This is a compiler part of https://reviews.llvm.org/D29586. Enable
>> LSan on arm Linux.
>>
>> Differential Revision: https://reviews.llvm.org/D31760
>>
>> Modified:
>> cfe/trunk/lib/Driver/ToolChains/Linux.cpp
>> cfe/trunk/test/Driver/fsanitize.c
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
>> lChains/Linux.cpp?rev=299921&r1=299920&r2=299921&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Tue Apr 11 02:22:11
>> 2017
>> @@ -864,6 +864,9 @@ SanitizerMask Linux::getSupportedSanitiz
>> getTriple().getArch() ==
>> llvm::Triple::ppc64le;
>>const bool IsAArch64 = getTriple().getArch() ==
>> llvm::Triple::aarch64 ||
>>   getTriple().getArch() ==
>> llvm::Triple::aarch64_be;
>> +  const bool IsArmArch = getTriple().getArch() ==
>> llvm::Triple::arm ||
>> + llvm::Triple::thumb ||
>> llvm::Triple::armeb ||
>> + llvm::Triple::thumbeb;
>>SanitizerMask Res = ToolChain::getSupportedSanitizers();
>>Res |= SanitizerKind::Address;
>>Res |= SanitizerKind::KernelAddress;
>> @@ -871,7 +874,7 @@ SanitizerMask Linux::getSupportedSanitiz
>>Res |= SanitizerKind::SafeStack;
>>if (IsX86_64 || IsMIPS64 || IsAArch64)
>>  Res |= SanitizerKind::DataFlow;
>> -  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86)
>> +  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch)
>>  Res |= SanitizerKind::Leak;
>>if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
>>  Res |= SanitizerKind::Thread;
>>
>> Modified: cfe/trunk/test/Driver/fsanitize.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fs
>> anitize.c?rev=299921&r1=299920&r2=299921&view=diff
>> 
>> ==
>> --- cfe/trunk/test/Driver/fsanitize.c (original)
>> +++ cfe/trunk/test/Driver/fsanitize.c Tue Apr 11 02:22:11 2017
>> @@ -237,6 +237,30 @@
>>  // RUN: %clang -target i686-linux-gnu -fsanitize=address,leak
>> -fno-sanitize=address %s -### 2>&1 | FileCheck %s
>> --check-prefix=CHECK-SANA-SANL-NO-SANA-X86
>>  // CHECK-SANA-SANL-NO-SANA-X86: "-fsanitize=leak"
>>
>> +// RUN: %clang -target arm-linux-gnu -fsanitize=leak %s -### 2>&1
>> | FileCheck %s --check-prefix=CHECK-SANL-ARM
>> +// CHECK-SANL-ARM: "-fsanitize=leak"
>> +
>> +// RUN: %clang -target arm-linux-gnu -fsanitize=address,leak
>> -fno-sanitize=address %s -### 2>&1 | FileCheck %s
>> --check-prefix=CHECK-SANA-SANL-NO-SANA-ARM
>> +// CHECK-SANA-SANL-NO-SANA-ARM: "-fsanitize=leak"
>> +
>> +// RUN: %clang -target thumb-linux -fsanitize=leak %s -### 2>&1 |
>> FileCheck %s --check-prefix=CHECK-SANL-THUMB
>> +// CHECK-SANL-THUMB: "-fsanitize=leak"
>> +
>> +// RUN: %clang -target thumb-linux -fsanitize=address,leak
>> -fno-sanitize=address %s -### 2>&1 | FileCheck %s
>> --check-prefix=CHECK-SANA-SANL-NO-SANA-THUMB
>> +// CHECK-SANA-SANL-NO-SANA-THUMB: "-fsanitize=leak"
>> +
>> +// RUN: %clang -target armeb-linux-gnu -fsanitize=leak %s -###
>> 2>&1 | FileCheck %s --check-prefix=CHECK-SANL-ARMEB
>> +// CHECK-SANL-ARMEB: "-fsanitize=leak"
>> +
>> +// RUN: %cla

[PATCH] D33904: Add a __has_attribute_enhancement macro to clang

2017-06-05 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv created this revision.
Herald added a subscriber: javed.absar.

Attributes may gain features or added flexibility over time. This patch aims to 
add a simple and uniform way to directly add/query for arbitrary changes in 
attributes, instead of having to rely on other information (e.g. version 
numbers, the existence of other attributes added at around the same time as the 
feature you're interested in, ...).

The only user of this at the moment will be https://reviews.llvm.org/D32332, so 
I won't tag people for review here until that lands.

Better words than "enhancement" are welcome; I tried things like 
`__has_attribute_extension` and `__has_attribute_feature`, but we also have 
both `__has_extension` and `__has_feature`, so... :)


https://reviews.llvm.org/D33904

Files:
  docs/LanguageExtensions.rst
  include/clang/Basic/Attr.td
  include/clang/Basic/Attributes.h
  include/clang/Lex/Preprocessor.h
  lib/Basic/Attributes.cpp
  lib/Lex/PPMacroExpansion.cpp
  test/Preprocessor/has_attribute.c
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2664,6 +2664,7 @@
 static void GenerateHasAttrSpellingStringSwitch(
 const std::vector &Attrs, raw_ostream &OS,
 const std::string &Variety = "", const std::string &Scope = "") {
+  const StringRef CaseIndent = "";
   for (const auto *Attr : Attrs) {
 // C++11-style attributes have specific version information associated with
 // them. If the attribute has no scope, the version information must not
@@ -2700,15 +2701,35 @@
   // present in the caller.
   Test = "LangOpts.CPlusPlus11";
 
+// Any enhancements must be checked for, as well.
+if (!Test.empty())
+  Test += " && ";
+
+std::vector Enhancements =
+Attr->getValueAsListOfStrings("Enhancements");
+if (Enhancements.empty()) {
+  Test += "!Enhancement";
+} else {
+  Test += "(!Enhancement || llvm::StringSwitch(EnhancementName)";
+
+  std::string Preamble = ("\n" + CaseIndent + CaseIndent).str();
+  for (const auto &Enhancement : Enhancements) {
+assert(Enhancement.find('"') == std::string::npos &&
+   "Quotes aren't allowed in enhancements!");
+Test += (Preamble + ".Case(\"" + Enhancement + "\", true)").str();
+  }
+  Test += Preamble + ".Default(false))";
+}
+
 std::string TestStr =
 !Test.empty() ? Test + " ? " + llvm::itostr(Version) + " : 0" : "1";
 std::vector Spellings = GetFlattenedSpellings(*Attr);
 for (const auto &S : Spellings)
   if (Variety.empty() || (Variety == S.variety() &&
   (Scope.empty() || Scope == S.nameSpace(
-OS << ".Case(\"" << S.name() << "\", " << TestStr << ")\n";
+OS << CaseIndent << ".Case(\"" << S.name() << "\", " << TestStr << ")\n";
   }
-  OS << ".Default(0);\n";
+  OS << CaseIndent << ".Default(0);\n";
 }
 
 // Emits the list of spellings for attributes.
Index: test/Preprocessor/has_attribute.c
===
--- test/Preprocessor/has_attribute.c
+++ test/Preprocessor/has_attribute.c
@@ -56,3 +56,59 @@
 
 #if __has_cpp_attribute(selectany) // expected-error {{function-like macro '__has_cpp_attribute' is not defined}}
 #endif
+
+#if !defined(__has_attribute_enhancement)
+#error "No extended has_attribute support?"
+#endif
+
+#if __has_attribute_enhancement(attr_does_not_exist) // expected-error{{too few arguments}}
+#error "We have an enhancement on an attr that doesn't exist?"
+#endif
+
+#if __has_attribute_enhancement(attr_does_not_exist thing) // expected-error{{missing ',' after 'attr_does_not_exist'}}
+#error "We have an enhancement on an attr that doesn't exist?"
+#endif
+
+#if __has_attribute_enhancement(attr_does_not_exist, )
+#error "We have an enhancement on an attr that doesn't exist?"
+#endif
+
+#if __has_attribute_enhancement(always_inline, )
+#error "Empty enhancement exists on always_inline?"
+#endif
+
+#if __has_attribute_enhancement(always_inline, enhancement_does_not_exist)
+#error "Enhancement checks on enhancementless attributes seem broken"
+#endif
+
+#if !__has_attribute(overloadable)
+#error "The following tests depend on having overloadable"
+#endif
+
+#if __has_attribute_enhancement(overloadable,) // expected-error{{expected identifier}}
+#error "Should assume false"
+#endif
+
+#if __has_attribute_enhancement(overloadable, not a valid enhancement) // expected-error{{missing ')' after 'not'}} expected-note{{to match this}}
+#error "Should assume false"
+#endif
+
+#if __has_attribute_enhancement(overloadable, not_an_existing_enhancement)
+#error "Should assume false"
+#endif
+
+#if __has_attribute_enhancement(overloadable, __not_an_existing_enhancement__)
+#error "Should assume false"
+#endif
+
+#if !__has_

[PATCH] D32332: Add support for transparent overloadable functions in clang

2017-06-05 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

Ping :)

https://reviews.llvm.org/D33904 is what I imagine would be a good way to detect 
this change.


https://reviews.llvm.org/D32332



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


r304727 - Attempt to fix Windows buildbot failure due to mismatching directory separators in preprocessed output.

2017-06-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun  5 13:39:31 2017
New Revision: 304727

URL: http://llvm.org/viewvc/llvm-project?rev=304727&view=rev
Log:
Attempt to fix Windows buildbot failure due to mismatching directory separators 
in preprocessed output.

Modified:
cfe/trunk/test/Modules/preprocess-module.cpp

Modified: cfe/trunk/test/Modules/preprocess-module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess-module.cpp?rev=304727&r1=304726&r2=304727&view=diff
==
--- cfe/trunk/test/Modules/preprocess-module.cpp (original)
+++ cfe/trunk/test/Modules/preprocess-module.cpp Mon Jun  5 13:39:31 2017
@@ -37,11 +37,18 @@
 // Check that our module contains correct mapping information for the headers.
 // RUN: cp %S/Inputs/preprocess/fwd.h %S/Inputs/preprocess/file.h 
%S/Inputs/preprocess/file2.h %S/Inputs/preprocess/module.modulemap %t
 // RUN: %clang_cc1 -fmodules -fmodule-file=%t/copy.pcm %s -I%t -verify 
-fno-modules-error-recovery -DCOPY -DINCLUDE
+// RUN: rm %t/fwd.h %t/file.h %t/file2.h %t/module.modulemap
 
 // Check that we can preprocess from a .pcm file and that we get the same 
result as preprocessing from the original sources.
 // RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm 
-I%S/Inputs/preprocess -x c++-module-map %S/Inputs/preprocess/module.modulemap 
-emit-module -o %t/file.pcm
 // RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm 
-I%S/Inputs/preprocess %t/file.pcm -E -frewrite-includes -o %t/file.rewrite.ii
-// RUN: cmp %t/rewrite.ii %t/file.rewrite.ii
+// FIXME: This check fails on Windows targets, due to canonicalization of 
directory separators.
+// FIXME: cmp %t/rewrite.ii %t/file.rewrite.ii
+// FIXME: Instead, just check that the preprocessed output is functionally 
equivalent to the output when preprocessing from the original sources.
+// RUN: FileCheck %s --input-file %t/file.rewrite.ii--check-prefix=CHECK 
--check-prefix=REWRITE
+// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -x 
c++-module-map-cpp-output %t/file.rewrite.ii -emit-module -o %t/file.rewrite.pcm
+// RUN: %clang_cc1 -fmodules -fmodule-file=%t/file.rewrite.pcm %s -I%t -verify 
-fno-modules-error-recovery -DFILE_REWRITE
+// RUN: %clang_cc1 -fmodules -fmodule-file=%t/file.rewrite.pcm %s -I%t -verify 
-fno-modules-error-recovery -DFILE_REWRITE -DINCLUDE -I%S/Inputs/preprocess
 
 // == module map
 // CHECK: # 1 "{{.*}}module.modulemap"
@@ -110,7 +117,9 @@
 
 
 __FILE *a; // expected-error {{declaration of '__FILE' must be imported}}
-#ifdef REWRITE
+#if FILE_REWRITE
+// expected-n...@file.rewrite.ii:1 {{here}}
+#elif REWRITE
 // expected-n...@rewrite.ii:1 {{here}}
 #elif COPY
 // expected-n...@copy.ii:1 {{here}}


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


[PATCH] D30963: Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls replaced by visible decls.

2017-06-05 Thread Jorge Gorbe via Phabricator via cfe-commits
jgorbe updated this revision to Diff 101437.
jgorbe added a comment.
Herald added a subscriber: sanjoy.

Removed unneeded branch.


https://reviews.llvm.org/D30963

Files:
  lib/Sema/SemaLookup.cpp
  test/Modules/Inputs/crash-typo-correction-visibility/module.h
  test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
  test/Modules/crash-typo-correction-visibility.cpp


Index: test/Modules/crash-typo-correction-visibility.cpp
===
--- /dev/null
+++ test/Modules/crash-typo-correction-visibility.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=module -o 
%T/module.pcm -emit-module 
%S/Inputs/crash-typo-correction-visibility/module.modulemap
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%T/module.pcm %s 
-verify
+
+struct S {
+  int member; // expected-note {{declared here}}
+};
+
+int f(...);
+
+int b = sizeof(f(member)); // expected-error {{undeclared identifier 'member'}}
Index: test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
@@ -0,0 +1,3 @@
+module "module" {
+  header "module.h"
+}
Index: test/Modules/Inputs/crash-typo-correction-visibility/module.h
===
--- /dev/null
+++ test/Modules/Inputs/crash-typo-correction-visibility/module.h
@@ -0,0 +1 @@
+struct member;
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3746,20 +3746,19 @@
   bool FindHidden);
 
 /// \brief Check whether the declarations found for a typo correction are
-/// visible, and if none of them are, convert the correction to an 'import
-/// a module' correction.
+/// visible. Set the correction's RequiresImport flag to true if none of the
+/// declarations are visible, false otherwise.
 static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC) {
-  if (TC.begin() == TC.end())
-return;
-
   TypoCorrection::decl_iterator DI = TC.begin(), DE = TC.end();
 
   for (/**/; DI != DE; ++DI)
 if (!LookupResult::isVisible(SemaRef, *DI))
   break;
-  // Nothing to do if all decls are visible.
-  if (DI == DE)
+  // No filtering needed if all decls are visible.
+  if (DI == DE) {
+TC.setRequiresImport(false);
 return;
+  }
 
   llvm::SmallVector NewDecls(TC.begin(), DI);
   bool AnyVisibleDecls = !NewDecls.empty();


Index: test/Modules/crash-typo-correction-visibility.cpp
===
--- /dev/null
+++ test/Modules/crash-typo-correction-visibility.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=module -o %T/module.pcm -emit-module %S/Inputs/crash-typo-correction-visibility/module.modulemap
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%T/module.pcm %s -verify
+
+struct S {
+  int member; // expected-note {{declared here}}
+};
+
+int f(...);
+
+int b = sizeof(f(member)); // expected-error {{undeclared identifier 'member'}}
Index: test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
@@ -0,0 +1,3 @@
+module "module" {
+  header "module.h"
+}
Index: test/Modules/Inputs/crash-typo-correction-visibility/module.h
===
--- /dev/null
+++ test/Modules/Inputs/crash-typo-correction-visibility/module.h
@@ -0,0 +1 @@
+struct member;
Index: lib/Sema/SemaLookup.cpp
===
--- lib/Sema/SemaLookup.cpp
+++ lib/Sema/SemaLookup.cpp
@@ -3746,20 +3746,19 @@
   bool FindHidden);
 
 /// \brief Check whether the declarations found for a typo correction are
-/// visible, and if none of them are, convert the correction to an 'import
-/// a module' correction.
+/// visible. Set the correction's RequiresImport flag to true if none of the
+/// declarations are visible, false otherwise.
 static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC) {
-  if (TC.begin() == TC.end())
-return;
-
   TypoCorrection::decl_iterator DI = TC.begin(), DE = TC.end();
 
   for (/**/; DI != DE; ++DI)
 if (!LookupResult::isVisible(SemaRef, *DI))
   break;
-  // Nothing to do if all decls are visible.
-  if (DI == DE)
+  // No filtering needed if all decls are visible.
+  if (DI == DE) {
+TC.setRequiresImport(false);
 return;
+  }
 
   llvm::SmallVector NewDecls(TC.begin(), DI);
   bool AnyVisibleDecls = !NewDecls.empty();
___
cfe-commits mailing list
cfe

[PATCH] D30963: Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls replaced by visible decls.

2017-06-05 Thread Jorge Gorbe via Phabricator via cfe-commits
jgorbe added inline comments.



Comment at: lib/Sema/SemaLookup.cpp:3792-3793
 static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC) {
   if (TC.begin() == TC.end())
 return;
 

rsmith wrote:
> jgorbe wrote:
> > rsmith wrote:
> > > Do we need to clear the flag on this path too? (This might happen if the 
> > > old correction required an import and after clearing we set this up as a 
> > > keyword correction.)
> > If this might happen, then yes. I have updated the patch to clear the flag 
> > here as well but, on second thought, is this path necessary at all? It 
> > seems to me that 'no declarations' is a special case of 'all declarations 
> > are visible', which we check right after this.
> I agree, this check is redundant. Just go ahead and remove it :)
Done! :D

I don't have commit access yet, can you please commit it?


https://reviews.llvm.org/D30963



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


r304728 - Factor out and unify emission of "module is unavailable" diagnostics.

2017-06-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun  5 13:57:56 2017
New Revision: 304728

URL: http://llvm.org/viewvc/llvm-project?rev=304728&view=rev
Log:
Factor out and unify emission of "module is unavailable" diagnostics.

Inspired by post-commit review of r304190.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/test/Modules/requires-coroutines.mm
cfe/trunk/test/Modules/requires-gnuinlineasm.m
cfe/trunk/test/Modules/requires.m
cfe/trunk/test/Modules/requires.mm

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=304728&r1=304727&r2=304728&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Mon Jun  5 
13:57:56 2017
@@ -196,6 +196,7 @@ def err_no_submodule_suggest : Error<
   "no submodule named %0 in module '%1'; did you mean '%2'?">;
 def warn_missing_submodule : Warning<"missing submodule '%0'">,
   InGroup;
+def note_module_import_here : Note<"module imported here">;
 def err_module_cannot_create_includes : Error<
   "cannot create includes file for module %0: %1">;
 def warn_module_config_macro_undef : Warning<

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=304728&r1=304727&r2=304728&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Mon Jun  5 13:57:56 2017
@@ -1954,6 +1954,13 @@ private:
   void HandleMicrosoftImportDirective(Token &Tok);
 
 public:
+  /// Check that the given module is available, producing a diagnostic if not.
+  /// \return \c true if the check failed (because the module is not 
available).
+  /// \c false if the module appears to be usable.
+  static bool checkModuleIsAvailable(const LangOptions &LangOpts,
+ const TargetInfo &TargetInfo,
+ DiagnosticsEngine &Diags, Module *M);
+
   // Module inclusion testing.
   /// \brief Find the module that owns the source or header file that
   /// \p Loc points to. If the location is in a file that was included

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=304728&r1=304727&r2=304728&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Jun  5 13:57:56 2017
@@ -1824,20 +1824,10 @@ CompilerInstance::loadModule(SourceLocat
 }
 
 // Check whether this module is available.
-clang::Module::Requirement Requirement;
-clang::Module::UnresolvedHeaderDirective MissingHeader;
-if (!Module->isAvailable(getLangOpts(), getTarget(), Requirement,
- MissingHeader)) {
-  if (MissingHeader.FileNameLoc.isValid()) {
-getDiagnostics().Report(MissingHeader.FileNameLoc,
-diag::err_module_header_missing)
-  << MissingHeader.IsUmbrella << MissingHeader.FileName;
-  } else {
-getDiagnostics().Report(ImportLoc, diag::err_module_unavailable)
-  << Module->getFullModuleName()
-  << Requirement.second << Requirement.first
-  << SourceRange(Path.front().second, Path.back().second);
-  }
+if (Preprocessor::checkModuleIsAvailable(getLangOpts(), getTarget(),
+ getDiagnostics(), Module)) {
+  getDiagnostics().Report(ImportLoc, diag::note_module_import_here)
+<< SourceRange(Path.front().second, Path.back().second);
   LastModuleImportLoc = ImportLoc;
   LastModuleImportResult = ModuleLoadResult();
   return ModuleLoadResult();

Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=304728&r1=304727&r2=304728&view=diff
==
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Mon Jun  5 13:57:56 2017
@@ -443,21 +443,9 @@ static Module *prepareToBuildModule(Comp
   }
 
   // Check whether we can build this module at all.
-  clang::Module::Requirement Requirement;
-  clang::Module::UnresolvedHeaderDirective MissingHeader;
-  if (!M->isAvailable(CI.getLangOpts(), CI.getTarget(), Requirement,
-

Re: r304190 - Diagnose attempts to build a preprocessed module that defines an unavailable submodule.

2017-06-05 Thread Richard Smith via cfe-commits
On 5 June 2017 at 09:35, David Blaikie via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Mon, May 29, 2017 at 10:23 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Tue May 30 00:22:59 2017
>> New Revision: 304190
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=304190&view=rev
>> Log:
>> Diagnose attempts to build a preprocessed module that defines an
>> unavailable submodule.
>>
>> The errors we would otherwise get are incomprehensible, as we would enter
>> the
>> module but not make its contents visible to itself.
>>
>> Added:
>> cfe/trunk/test/Modules/preprocess-unavailable.cpp
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> cfe/trunk/lib/Lex/Pragma.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticLexKinds.td?rev=304190&r1=304189&r2=304190&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue May 30
>> 00:22:59 2017
>> @@ -525,6 +525,8 @@ def err_pp_module_begin_without_module_e
>>  def err_pp_module_end_without_module_begin : Error<
>>"no matching '#pragma clang module begin' for this "
>>"'#pragma clang module end'">;
>> +def note_pp_module_begin_here : Note<
>> +  "entering module '%0' due to this pragma">;
>>
>>  def err_defined_macro_name : Error<"'defined' cannot be used as a macro
>> name">;
>>  def err_paste_at_start : Error<
>>
>> Modified: cfe/trunk/lib/Lex/Pragma.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma
>> .cpp?rev=304190&r1=304189&r2=304190&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Lex/Pragma.cpp (original)
>> +++ cfe/trunk/lib/Lex/Pragma.cpp Tue May 30 00:22:59 2017
>> @@ -1407,6 +1407,24 @@ struct PragmaModuleBeginHandler : public
>>M = NewM;
>>  }
>>
>> +// If the module isn't available, it doesn't make sense to enter it.
>> +if (!M->isAvailable()) {
>> +  Module::Requirement Requirement;
>> +  Module::UnresolvedHeaderDirective MissingHeader;
>> +  (void)M->isAvailable(PP.getLangOpts(), PP.getTargetInfo(),
>> +   Requirement, MissingHeader);
>>
>
> This looks a tad weird ^ should this function have a different name (or a
> version of the function that only does the side-effecting work that I'm
> guessing is desired here)?
>

It's not exactly producing side-effects; rather, it's filling in output
parameters (and we happen to have already checked the primary return value
as an 'optimization' here). But it seems like this isn't worth the
confusion, plus we repeat this code in four (!) different places. Tidied up
and factored out the common code in r304728 (along with a minor improvement
to diagnostic quality in one of the four repetitions).


> +  if (MissingHeader.FileNameLoc.isValid()) {
>> +PP.Diag(MissingHeader.FileNameLoc,
>> diag::err_module_header_missing)
>> +  << MissingHeader.IsUmbrella << MissingHeader.FileName;
>> +  } else {
>> +PP.Diag(M->DefinitionLoc, diag::err_module_unavailable)
>> +  << M->getFullModuleName() << Requirement.second <<
>> Requirement.first;
>> +  }
>> +  PP.Diag(BeginLoc, diag::note_pp_module_begin_here)
>> +<< M->getTopLevelModuleName();
>> +  return;
>> +}
>> +
>>  // Enter the scope of the submodule.
>>  PP.EnterSubmodule(M, BeginLoc, /*ForPragma*/true);
>>  PP.EnterAnnotationToken(SourceRange(BeginLoc,
>> ModuleName.back().second),
>>
>> Added: cfe/trunk/test/Modules/preprocess-unavailable.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/
>> preprocess-unavailable.cpp?rev=304190&view=auto
>> 
>> ==
>> --- cfe/trunk/test/Modules/preprocess-unavailable.cpp (added)
>> +++ cfe/trunk/test/Modules/preprocess-unavailable.cpp Tue May 30
>> 00:22:59 2017
>> @@ -0,0 +1,12 @@
>> +// RUN: %clang_cc1 -x c++-module-map %s -fmodule-name=a -verify
>> +module a {
>> +  module b {
>> +requires cplusplus11
>> +  }
>> +}
>> +#pragma clang module contents
>> +// expected-error@3 {{module 'a.b' requires feature 'cplusplus11'}}
>> +#pragma clang module begin a.b // expected-note {{entering module 'a'
>> due to this pragma}}
>> +int f();
>> +int g() { f(); }
>> +#pragma clang module end // expected-error {{no matching '#pragma clang
>> module begin'}}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/

Re: [PATCH] D33708: [test] [libcxx] Disable MSVC++'s compare(a, b) implies !compare(b, a) assertion in predicate application count tests

2017-06-05 Thread Billy O'Neal via cfe-commits
But I actually want the predicate count assertions turned on -- if a user
turns off iterator debugging they need to get exactly what the standard
asks for, and that means both predicate assertions like this and the
Iterator Debug Array Overloads go away.

I need to figure out how to do this with our test harness though, since at
the moment we depend on that forceinclude.

Billy3

On Mon, Jun 5, 2017 at 9:51 AM, David Blaikie  wrote:

> Alternatively, you could disable the check (or change the count it checks)
> if this is defined. (& if you disable the check when this is defined, you
> could change an existing build/test config (or add a new one) to have this
> disabled)
>
> On Tue, May 30, 2017 at 8:19 PM Billy Robert O'Neal III via Phabricator
> via cfe-commits  wrote:
>
>> BillyONeal abandoned this revision.
>> BillyONeal added a comment.
>>
>> Stephan pointed out that the force include breaks this. Backing it out
>> for now :(
>>
>>
>> https://reviews.llvm.org/D33708
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-05 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

Adding an unsigned offset to a base pointer has undefined behavior if
the result of the expression would precede the base. An example from
@regehr:

  int foo(char *p, unsigned offset) {
return p + offset >= p; // This may be optimized to '1'.
  }
  
  foo(p, -1); // UB.

This patch extends the pointer overflow check in ubsan to detect invalid
unsigned pointer index expressions. It changes the instrumentation to
only permit non-negative offsets in pointer index expressions when all
of the GEP indices are unsigned.

Aside: If anyone has a better name for this type of bug, I'm all ears.
Using "unsigned pointer index expression" could be a problem, because it
sounds like an indexing expression with an _unsigned pointer_.


https://reviews.llvm.org/D33910

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ubsan-pointer-overflow.m

Index: test/CodeGen/ubsan-pointer-overflow.m
===
--- test/CodeGen/ubsan-pointer-overflow.m
+++ test/CodeGen/ubsan-pointer-overflow.m
@@ -5,9 +5,7 @@
   // CHECK:  [[BASE:%.*]] = ptrtoint i8* {{.*}} to i64, !nosanitize
   // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], 1, !nosanitize
   // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
-  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
-  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 true, i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
-  // CHECK-NEXT: [[VALID:%.*]] = and i1 true, [[DIFFVALID]], !nosanitize
+  // CHECK-NEXT: [[VALID:%.*]] = and i1 true, [[POSVALID]], !nosanitize
   // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize
   ++p;
@@ -34,11 +32,11 @@
   // CHECK-NEXT: [[SMULVAL:%.*]] = extractvalue { i64, i1 } [[SMUL]], 0, !nosanitize
   // CHECK-NEXT: [[BASE:%.*]] = ptrtoint i8* {{.*}} to i64, !nosanitize
   // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], [[SMULVAL]], !nosanitize
+  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
   // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
-  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
   // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize
-  // CHECK-DAG: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
-  // CHECK-DAG: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
+  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
   // CHECK: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize
   // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize
@@ -50,6 +48,27 @@
   p - i;
 }
 
+// CHECK-LABEL: define void @binary_arith_unsigned
+void binary_arith_unsigned(char *p, unsigned i) {
+  // CHECK: [[SMUL:%.*]] = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 1, i64 %{{.*}}), !nosanitize
+  // CHECK-NEXT: [[SMULOFLOW:%.*]] = extractvalue { i64, i1 } [[SMUL]], 1, !nosanitize
+  // CHECK-NEXT: [[OFFSETOFLOW:%.*]] = or i1 false, [[SMULOFLOW]], !nosanitize
+  // CHECK-NEXT: [[SMULVAL:%.*]] = extractvalue { i64, i1 } [[SMUL]], 0, !nosanitize
+  // CHECK-NEXT: [[BASE:%.*]] = ptrtoint i8* {{.*}} to i64, !nosanitize
+  // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], [[SMULVAL]], !nosanitize
+  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
+  // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[POSVALID]], !nosanitize
+  // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize
+  p + i;
+
+  // CHECK: [[OFFSET:%.*]] = sub i64 0, {{.*}}
+  // CHECK-NEXT: getelementptr inbounds {{.*}} [[OFFSET]]
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
+  p - i;
+}
+
 // CHECK-LABEL: define void @fixed_len_array
 void fixed_len_array(int k) {
   // CHECK: getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* [[ARR:%.*]], i64 0, i64 [[IDXPROM:%.*]]
@@ -59,11 +78,11 @@
   // CHECK-NEXT: [[SMULVAL:%.*]] = extractvalue { i64, i1 } [[SMUL]], 0, !nosanitize
   // CHECK-NEXT: [[BASE:%.*]] = ptrtoint [10 x [10 x i32]]* [[ARR]] to i64, !nosanitize
   // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], [[SMULVAL]], !nosanitize
+  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
   // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
-  // CHECK-NEXT: 

[libcxx] r304730 - [test] Remove workaround for C1XX empty parameter pack bug

2017-06-05 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Mon Jun  5 14:59:17 2017
New Revision: 304730

URL: http://llvm.org/viewvc/llvm-project?rev=304730&view=rev
Log:
[test] Remove workaround for C1XX empty parameter pack bug

Was VSO#109062. This bug was filed *4 years ago*. I submitted a workaround to 
enable the scoped_allocator_adaptor tests to pass. Bug fixed a week and a half 
later. This was either a waste of my time, or I've discovered that libc++ has 
magical bugfix-inducing powers. My money's on the latter.

Removed:

libcxx/trunk/test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
Modified:
libcxx/trunk/test/support/test_workarounds.h
libcxx/trunk/test/support/uses_alloc_types.hpp

Removed: 
libcxx/trunk/test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp?rev=304729&view=auto
==
--- 
libcxx/trunk/test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
 (original)
+++ 
libcxx/trunk/test/support/test.workarounds/c1xx_empty_parameter_pack_expansion.pass.cpp
 (removed)
@@ -1,49 +0,0 @@
-//===--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: c++98, c++03
-
-// Verify TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION.
-
-#include 
-
-#include "test_workarounds.h"
-
-template
-struct identity {
-using type = T;
-};
-
-template struct list {};
-
-// C1XX believes this function template is not viable when LArgs is an empty
-// parameter pack.
-template 
-int f2(typename identity::type..., int i) {
-return i;
-}
-
-#ifdef TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
-// C1XX believes this function template *is* viable when LArgs is an empty
-// parameter pack. Conforming compilers believe the two overloads are
-// ambiguous when LArgs is an empty pack.
-template 
-int f2(int i) {
-return i;
-}
-#endif
-
-template 
-int f1(list, Args&&... args) {
-return f2(args...);
-}
-
-int main() {
-f1(list<>{}, 42);
-}

Modified: libcxx/trunk/test/support/test_workarounds.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_workarounds.h?rev=304730&r1=304729&r2=304730&view=diff
==
--- libcxx/trunk/test/support/test_workarounds.h (original)
+++ libcxx/trunk/test/support/test_workarounds.h Mon Jun  5 14:59:17 2017
@@ -19,7 +19,6 @@
 
 #if defined(TEST_COMPILER_C1XX)
 # define TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE // VSO#117743
-# define TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION // VSO#109062
 # ifndef _MSC_EXTENSIONS
 #  define TEST_WORKAROUND_C1XX_BROKEN_ZA_CTOR_CHECK // VSO#119998
 # endif

Modified: libcxx/trunk/test/support/uses_alloc_types.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/uses_alloc_types.hpp?rev=304730&r1=304729&r2=304730&view=diff
==
--- libcxx/trunk/test/support/uses_alloc_types.hpp (original)
+++ libcxx/trunk/test/support/uses_alloc_types.hpp Mon Jun  5 14:59:17 2017
@@ -257,13 +257,6 @@ private:
 return alloc;
 }
 
-#ifdef TEST_WORKAROUND_C1XX_EMPTY_PARAMETER_PACK_EXPANSION
-template 
-static CtorAlloc getAllocatorFromPackImp(CtorAlloc const& alloc) {
-return alloc;
-}
-#endif
-
 bool has_alloc() const { return alloc_store.get_allocator() != nullptr; }
 const CtorAlloc *get_alloc() const { return alloc_store.get_allocator(); }
 public:


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


[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-05 Thread John Regehr via Phabricator via cfe-commits
regehr added a comment.

I'm afraid I don't have a better name for this.

Here's the obligatory gcc explorer link though: https://godbolt.org/g/s10h0O


https://reviews.llvm.org/D33910



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


Re: r304726 - Rather than rejecting attempts to run preprocessor-only actions on AST files,

2017-06-05 Thread Evgenii Stepanov via cfe-commits
This change leaks memory:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5453/steps/check-clang%20asan/logs/stdio

On Mon, Jun 5, 2017 at 11:10 AM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Mon Jun  5 13:10:11 2017
> New Revision: 304726
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304726&view=rev
> Log:
> Rather than rejecting attempts to run preprocessor-only actions on AST files,
> replay the steps taken to create the AST file with the preprocessor-only 
> action
> installed to produce preprocessed output.
>
> This can be used to produce the preprocessed text for an existing .pch or .pcm
> file.
>
> Modified:
> cfe/trunk/include/clang/Basic/LangOptions.h
> cfe/trunk/include/clang/Basic/SourceManager.h
> cfe/trunk/include/clang/Frontend/ASTUnit.h
> cfe/trunk/include/clang/Frontend/FrontendAction.h
> cfe/trunk/lib/Basic/SourceManager.cpp
> cfe/trunk/lib/Frontend/ASTUnit.cpp
> cfe/trunk/lib/Frontend/FrontendAction.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/test/Modules/preprocess-module.cpp
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=304726&r1=304725&r2=304726&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.h Mon Jun  5 13:10:11 2017
> @@ -58,6 +58,7 @@ public:
>  SOB_Trapping// -ftrapv
>};
>
> +  // FIXME: Unify with TUKind.
>enum CompilingModuleKind {
>  CMK_None,   ///< Not compiling a module interface at all.
>  CMK_ModuleMap,  ///< Compiling a module from a module map.
>
> Modified: cfe/trunk/include/clang/Basic/SourceManager.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=304726&r1=304725&r2=304726&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/SourceManager.h (original)
> +++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Jun  5 13:10:11 2017
> @@ -722,6 +722,10 @@ public:
>
>void clearIDTables();
>
> +  /// Initialize this source manager suitably to replay the compilation
> +  /// described by \p Old. Requires that \p Old outlive \p *this.
> +  void initializeForReplay(const SourceManager &Old);
> +
>DiagnosticsEngine &getDiagnostics() const { return Diag; }
>
>FileManager &getFileManager() const { return FileMgr; }
>
> Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=304726&r1=304725&r2=304726&view=diff
> ==
> --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
> +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Mon Jun  5 13:10:11 2017
> @@ -51,6 +51,7 @@ class DiagnosticsEngine;
>  class FileEntry;
>  class FileManager;
>  class HeaderSearch;
> +class InputKind;
>  class MemoryBufferCache;
>  class Preprocessor;
>  class PCHContainerOperations;
> @@ -305,9 +306,6 @@ private:
>/// (likely to change while trying to use them).
>bool UserFilesAreVolatile : 1;
>
> -  /// \brief The language options used when we load an AST file.
> -  LangOptions ASTFileLangOpts;
> -
>static void ConfigureDiags(IntrusiveRefCntPtr Diags,
>   ASTUnit &AST, bool CaptureDiagnostics);
>
> @@ -702,6 +700,9 @@ public:
>/// \brief Determine what kind of translation unit this AST represents.
>TranslationUnitKind getTranslationUnitKind() const { return TUKind; }
>
> +  /// \brief Determine the input kind this AST unit represents.
> +  InputKind getInputKind() const;
> +
>/// \brief A mapping from a file name to the memory buffer that stores the
>/// remapped contents of that file.
>typedef std::pair RemappedFile;
>
> Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=304726&r1=304725&r2=304726&view=diff
> ==
> --- cfe/trunk/include/clang/Frontend/FrontendAction.h (original)
> +++ cfe/trunk/include/clang/Frontend/FrontendAction.h Mon Jun  5 13:10:11 2017
> @@ -176,10 +176,10 @@ public:
>virtual TranslationUnitKind getTranslationUnitKind() { return TU_Complete; 
> }
>
>/// \brief Does this action support use with PCH?
> -  virtual bool hasPCHSupport() const { return !usesPreprocessorOnly(); }
> +  virtual bool hasPCHSupport() const { return true; }
>
>/// \brief Does this action support use with AST files?
> -  virtual bool hasASTFileSupport() const { return !usesPreprocessorOnly(); }
> +  virtual bool hasASTFileSupport() const { return true; }
>
>/// \brief Does this ac

[PATCH] D33913: [index] Index static_assert declarations

2017-06-05 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

static_assert declarations have to be indexed to gather the declaration 
references in their assert expression.


Repository:
  rL LLVM

https://reviews.llvm.org/D33913

Files:
  lib/Index/IndexDecl.cpp
  test/Index/Core/index-source.cpp


Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -433,3 +433,19 @@
 T varDecl = T();
 
 } // end namespace ensureDefaultTemplateParamsAreRecordedOnce
+
+struct StaticAssertRef {
+  static constexpr bool constVar = true;
+};
+
+static_assert(StaticAssertRef::constVar, "index static asserts");
+// CHECK: [[@LINE-1]]:32 | static-property/C++ | constVar | 
c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref | rel: 0
+// CHECK: [[@LINE-2]]:15 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef 
|  | Ref | rel: 0
+
+void staticAssertInFn() {
+  static_assert(StaticAssertRef::constVar, "index static asserts");
+// CHECK: [[@LINE-1]]:34 | static-property/C++ | constVar | 
c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref,RelCont | 
rel: 1
+// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn#
+// CHECK: [[@LINE-3]]:17 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef 
|  | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn#
+}
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -682,6 +682,13 @@
   bool VisitImportDecl(const ImportDecl *D) {
 return IndexCtx.importedModule(D);
   }
+
+  bool VisitStaticAssertDecl(const StaticAssertDecl *D) {
+IndexCtx.indexBody(D->getAssertExpr(),
+   dyn_cast(D->getDeclContext()),
+   D->getLexicalDeclContext());
+return true;
+  }
 };
 
 } // anonymous namespace


Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -433,3 +433,19 @@
 T varDecl = T();
 
 } // end namespace ensureDefaultTemplateParamsAreRecordedOnce
+
+struct StaticAssertRef {
+  static constexpr bool constVar = true;
+};
+
+static_assert(StaticAssertRef::constVar, "index static asserts");
+// CHECK: [[@LINE-1]]:32 | static-property/C++ | constVar | c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref | rel: 0
+// CHECK: [[@LINE-2]]:15 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef |  | Ref | rel: 0
+
+void staticAssertInFn() {
+  static_assert(StaticAssertRef::constVar, "index static asserts");
+// CHECK: [[@LINE-1]]:34 | static-property/C++ | constVar | c:@S@StaticAssertRef@constVar | __ZN15StaticAssertRef8constVarE | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn#
+// CHECK: [[@LINE-3]]:17 | struct/C++ | StaticAssertRef | c:@S@StaticAssertRef |  | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | staticAssertInFn | c:@F@staticAssertInFn#
+}
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -682,6 +682,13 @@
   bool VisitImportDecl(const ImportDecl *D) {
 return IndexCtx.importedModule(D);
   }
+
+  bool VisitStaticAssertDecl(const StaticAssertDecl *D) {
+IndexCtx.indexBody(D->getAssertExpr(),
+   dyn_cast(D->getDeclContext()),
+   D->getLexicalDeclContext());
+return true;
+  }
 };
 
 } // anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r304726 - Rather than rejecting attempts to run preprocessor-only actions on AST files,

2017-06-05 Thread Richard Smith via cfe-commits
Thanks, investigating.

On 5 June 2017 at 13:14, Evgenii Stepanov  wrote:

> This change leaks memory:
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-
> linux-fast/builds/5453/steps/check-clang%20asan/logs/stdio
>
> On Mon, Jun 5, 2017 at 11:10 AM, Richard Smith via cfe-commits
>  wrote:
> > Author: rsmith
> > Date: Mon Jun  5 13:10:11 2017
> > New Revision: 304726
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=304726&view=rev
> > Log:
> > Rather than rejecting attempts to run preprocessor-only actions on AST
> files,
> > replay the steps taken to create the AST file with the preprocessor-only
> action
> > installed to produce preprocessed output.
> >
> > This can be used to produce the preprocessed text for an existing .pch
> or .pcm
> > file.
> >
> > Modified:
> > cfe/trunk/include/clang/Basic/LangOptions.h
> > cfe/trunk/include/clang/Basic/SourceManager.h
> > cfe/trunk/include/clang/Frontend/ASTUnit.h
> > cfe/trunk/include/clang/Frontend/FrontendAction.h
> > cfe/trunk/lib/Basic/SourceManager.cpp
> > cfe/trunk/lib/Frontend/ASTUnit.cpp
> > cfe/trunk/lib/Frontend/FrontendAction.cpp
> > cfe/trunk/lib/Serialization/ASTReader.cpp
> > cfe/trunk/test/Modules/preprocess-module.cpp
> >
> > Modified: cfe/trunk/include/clang/Basic/LangOptions.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/LangOptions.h?rev=304726&r1=304725&r2=304726&view=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
> > +++ cfe/trunk/include/clang/Basic/LangOptions.h Mon Jun  5 13:10:11 2017
> > @@ -58,6 +58,7 @@ public:
> >  SOB_Trapping// -ftrapv
> >};
> >
> > +  // FIXME: Unify with TUKind.
> >enum CompilingModuleKind {
> >  CMK_None,   ///< Not compiling a module interface at all.
> >  CMK_ModuleMap,  ///< Compiling a module from a module map.
> >
> > Modified: cfe/trunk/include/clang/Basic/SourceManager.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/SourceManager.h?rev=304726&r1=304725&r2=304726&view=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Basic/SourceManager.h (original)
> > +++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Jun  5 13:10:11
> 2017
> > @@ -722,6 +722,10 @@ public:
> >
> >void clearIDTables();
> >
> > +  /// Initialize this source manager suitably to replay the compilation
> > +  /// described by \p Old. Requires that \p Old outlive \p *this.
> > +  void initializeForReplay(const SourceManager &Old);
> > +
> >DiagnosticsEngine &getDiagnostics() const { return Diag; }
> >
> >FileManager &getFileManager() const { return FileMgr; }
> >
> > Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Frontend/ASTUnit.h?rev=304726&r1=304725&r2=304726&view=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
> > +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Mon Jun  5 13:10:11 2017
> > @@ -51,6 +51,7 @@ class DiagnosticsEngine;
> >  class FileEntry;
> >  class FileManager;
> >  class HeaderSearch;
> > +class InputKind;
> >  class MemoryBufferCache;
> >  class Preprocessor;
> >  class PCHContainerOperations;
> > @@ -305,9 +306,6 @@ private:
> >/// (likely to change while trying to use them).
> >bool UserFilesAreVolatile : 1;
> >
> > -  /// \brief The language options used when we load an AST file.
> > -  LangOptions ASTFileLangOpts;
> > -
> >static void ConfigureDiags(IntrusiveRefCntPtr
> Diags,
> >   ASTUnit &AST, bool CaptureDiagnostics);
> >
> > @@ -702,6 +700,9 @@ public:
> >/// \brief Determine what kind of translation unit this AST
> represents.
> >TranslationUnitKind getTranslationUnitKind() const { return TUKind; }
> >
> > +  /// \brief Determine the input kind this AST unit represents.
> > +  InputKind getInputKind() const;
> > +
> >/// \brief A mapping from a file name to the memory buffer that
> stores the
> >/// remapped contents of that file.
> >typedef std::pair RemappedFile;
> >
> > Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Frontend/FrontendAction.h?rev=304726&r1=304725&r2=304726&view=diff
> > 
> ==
> > --- cfe/trunk/include/clang/Frontend/FrontendAction.h (original)
> > +++ cfe/trunk/include/clang/Frontend/FrontendAction.h Mon Jun  5
> 13:10:11 2017
> > @@ -176,10 +176,10 @@ public:
> >virtual TranslationUnitKind getTranslationUnitKind() { return
> TU_Complete; }
> >
> >/// \brief Does this action support use with PCH?
> > -  virtual bool hasPCHSupport() const { return !usesPrep

[PATCH] D33102: [clang] Implement -Wcast-qual for C++

2017-06-05 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

I still feel like that's more testing than would be ideal (does the context of 
the cast matter? Wether it's dereferenced, a struct member access, assigned, 
initialized, etc - it doesn't look like it from the code, etc).

But sure. Could you also (manually, I guess) confirm that this matches GCC's 
cast-qual behavior (insofar as the warning fires in the same situations). If 
there are any deviations, let's chat about them.


Repository:
  rL LLVM

https://reviews.llvm.org/D33102



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


r304740 - Fix memory leak exposed by r304726.

2017-06-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun  5 17:05:31 2017
New Revision: 304740

URL: http://llvm.org/viewvc/llvm-project?rev=304740&view=rev
Log:
Fix memory leak exposed by r304726.

When giving a ContentCache a null buffer, ignore the DoNotFree flag rather than
inheriting it onto whatever buffer we end up using for the file. Also ensure
that the main buffer is properly destroyed.

Modified:
cfe/trunk/lib/Basic/SourceManager.cpp

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=304740&r1=304739&r2=304740&view=diff
==
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Mon Jun  5 17:05:31 2017
@@ -73,11 +73,11 @@ void ContentCache::replaceBuffer(llvm::M
 Buffer.setInt(DoNotFree? DoNotFreeFlag : 0);
 return;
   }
-  
+
   if (shouldFreeBuffer())
 delete Buffer.getPointer();
   Buffer.setPointer(B);
-  Buffer.setInt(DoNotFree? DoNotFreeFlag : 0);
+  Buffer.setInt((B && DoNotFree) ? DoNotFreeFlag : 0);
 }
 
 llvm::MemoryBuffer *ContentCache::getBuffer(DiagnosticsEngine &Diag,
@@ -362,9 +362,11 @@ void SourceManager::initializeForReplay(
   // Set up our main file ID as a copy of the old source manager's main file.
   const SLocEntry &OldMainFile = Old.getSLocEntry(Old.getMainFileID());
   assert(OldMainFile.isFile() && "main file is macro expansion?");
-  setMainFileID(createFileID(
-  CloneContentCache(OldMainFile.getFile().getContentCache()),
-  SourceLocation(), OldMainFile.getFile().getFileCharacteristic(), 0, 0));
+  auto *MainCC = CloneContentCache(OldMainFile.getFile().getContentCache());
+  MemBufferInfos.push_back(MainCC);
+  setMainFileID(createFileID(MainCC, SourceLocation(),
+ OldMainFile.getFile().getFileCharacteristic(),
+ 0, 0));
 
   // Ensure all SLocEntries are loaded from the external source.
   for (unsigned I = 0, N = Old.LoadedSLocEntryTable.size(); I != N; ++I)


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


Re: r304726 - Rather than rejecting attempts to run preprocessor-only actions on AST files,

2017-06-05 Thread Richard Smith via cfe-commits
Should be fixed in r304740.

On 5 June 2017 at 14:09, Richard Smith  wrote:

> Thanks, investigating.
>
> On 5 June 2017 at 13:14, Evgenii Stepanov 
> wrote:
>
>> This change leaks memory:
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-
>> fast/builds/5453/steps/check-clang%20asan/logs/stdio
>>
>> On Mon, Jun 5, 2017 at 11:10 AM, Richard Smith via cfe-commits
>>  wrote:
>> > Author: rsmith
>> > Date: Mon Jun  5 13:10:11 2017
>> > New Revision: 304726
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=304726&view=rev
>> > Log:
>> > Rather than rejecting attempts to run preprocessor-only actions on AST
>> files,
>> > replay the steps taken to create the AST file with the
>> preprocessor-only action
>> > installed to produce preprocessed output.
>> >
>> > This can be used to produce the preprocessed text for an existing .pch
>> or .pcm
>> > file.
>> >
>> > Modified:
>> > cfe/trunk/include/clang/Basic/LangOptions.h
>> > cfe/trunk/include/clang/Basic/SourceManager.h
>> > cfe/trunk/include/clang/Frontend/ASTUnit.h
>> > cfe/trunk/include/clang/Frontend/FrontendAction.h
>> > cfe/trunk/lib/Basic/SourceManager.cpp
>> > cfe/trunk/lib/Frontend/ASTUnit.cpp
>> > cfe/trunk/lib/Frontend/FrontendAction.cpp
>> > cfe/trunk/lib/Serialization/ASTReader.cpp
>> > cfe/trunk/test/Modules/preprocess-module.cpp
>> >
>> > Modified: cfe/trunk/include/clang/Basic/LangOptions.h
>> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/LangOptions.h?rev=304726&r1=304725&r2=304726&view=diff
>> > 
>> ==
>> > --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
>> > +++ cfe/trunk/include/clang/Basic/LangOptions.h Mon Jun  5 13:10:11
>> 2017
>> > @@ -58,6 +58,7 @@ public:
>> >  SOB_Trapping// -ftrapv
>> >};
>> >
>> > +  // FIXME: Unify with TUKind.
>> >enum CompilingModuleKind {
>> >  CMK_None,   ///< Not compiling a module interface at all.
>> >  CMK_ModuleMap,  ///< Compiling a module from a module map.
>> >
>> > Modified: cfe/trunk/include/clang/Basic/SourceManager.h
>> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/SourceManager.h?rev=304726&r1=304725&r2=304726&view=diff
>> > 
>> ==
>> > --- cfe/trunk/include/clang/Basic/SourceManager.h (original)
>> > +++ cfe/trunk/include/clang/Basic/SourceManager.h Mon Jun  5 13:10:11
>> 2017
>> > @@ -722,6 +722,10 @@ public:
>> >
>> >void clearIDTables();
>> >
>> > +  /// Initialize this source manager suitably to replay the compilation
>> > +  /// described by \p Old. Requires that \p Old outlive \p *this.
>> > +  void initializeForReplay(const SourceManager &Old);
>> > +
>> >DiagnosticsEngine &getDiagnostics() const { return Diag; }
>> >
>> >FileManager &getFileManager() const { return FileMgr; }
>> >
>> > Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
>> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Frontend/ASTUnit.h?rev=304726&r1=304725&r2=304726&view=diff
>> > 
>> ==
>> > --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
>> > +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Mon Jun  5 13:10:11 2017
>> > @@ -51,6 +51,7 @@ class DiagnosticsEngine;
>> >  class FileEntry;
>> >  class FileManager;
>> >  class HeaderSearch;
>> > +class InputKind;
>> >  class MemoryBufferCache;
>> >  class Preprocessor;
>> >  class PCHContainerOperations;
>> > @@ -305,9 +306,6 @@ private:
>> >/// (likely to change while trying to use them).
>> >bool UserFilesAreVolatile : 1;
>> >
>> > -  /// \brief The language options used when we load an AST file.
>> > -  LangOptions ASTFileLangOpts;
>> > -
>> >static void ConfigureDiags(IntrusiveRefCntPtr
>> Diags,
>> >   ASTUnit &AST, bool CaptureDiagnostics);
>> >
>> > @@ -702,6 +700,9 @@ public:
>> >/// \brief Determine what kind of translation unit this AST
>> represents.
>> >TranslationUnitKind getTranslationUnitKind() const { return TUKind; }
>> >
>> > +  /// \brief Determine the input kind this AST unit represents.
>> > +  InputKind getInputKind() const;
>> > +
>> >/// \brief A mapping from a file name to the memory buffer that
>> stores the
>> >/// remapped contents of that file.
>> >typedef std::pair RemappedFile;
>> >
>> > Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h
>> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Frontend/FrontendAction.h?rev=304726&r1=304725&r2=304726&view=diff
>> > 
>> ==
>> > --- cfe/trunk/include/clang/Frontend/FrontendAction.h (original)
>> > +++ cfe/trunk/include/clang/Frontend/FrontendAction.h Mon Jun  5
>> 13:10:11 2017
>> > @@ -176,10 +176,10 @@ public:
>>

[PATCH] D33875: PR27037: Use correct CVR qualifier on an upcast on method pointer call

2017-06-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaExprCXX.cpp:5108
 QualType UseType = isIndirect ? Context.getPointerType(Class) : Class;
+UseType = 
UseType.withCVRQualifiers(LHS.get()->getType().getCVRQualifiers());
 ExprValueKind VK = isIndirect ? VK_RValue : LHS.get()->getValueKind();

In the "indirect" case, the cv-qualifiers should be taken from the pointee type 
of the LHS and applied to the pointee type of UseType. I believe this patch 
will not be enough to cause us to reject the indirect version of your testcase:

```
  ((&b)->*&B::f)();  // expected-error{{drops 'const' qualifier}}
```

Moreover, we should be preserving all qualifiers, not just cvr-qualifiers; for 
example, this should also preserve the address space.


https://reviews.llvm.org/D33875



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


r304745 - Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls

2017-06-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun  5 17:29:36 2017
New Revision: 304745

URL: http://llvm.org/viewvc/llvm-project?rev=304745&view=rev
Log:
Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls
replaced by visible decls.

Make sure that all paths through checkCorrectionVisibility set the
RequiresImport flag appropriately, so we don't end up using a stale value.
Patch by Jorge Gorbe!

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

Added:
cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/
cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h

cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=304745&r1=304744&r2=304745&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Jun  5 17:29:36 2017
@@ -3747,20 +3747,19 @@ static void LookupPotentialTypoResult(Se
   bool FindHidden);
 
 /// \brief Check whether the declarations found for a typo correction are
-/// visible, and if none of them are, convert the correction to an 'import
-/// a module' correction.
+/// visible. Set the correction's RequiresImport flag to true if none of the
+/// declarations are visible, false otherwise.
 static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC) {
-  if (TC.begin() == TC.end())
-return;
-
   TypoCorrection::decl_iterator DI = TC.begin(), DE = TC.end();
 
   for (/**/; DI != DE; ++DI)
 if (!LookupResult::isVisible(SemaRef, *DI))
   break;
-  // Nothing to do if all decls are visible.
-  if (DI == DE)
+  // No filtering needed if all decls are visible.
+  if (DI == DE) {
+TC.setRequiresImport(false);
 return;
+  }
 
   llvm::SmallVector NewDecls(TC.begin(), DI);
   bool AnyVisibleDecls = !NewDecls.empty();

Added: cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h?rev=304745&view=auto
==
--- cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h Mon 
Jun  5 17:29:36 2017
@@ -0,0 +1 @@
+struct member;

Added: 
cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap?rev=304745&view=auto
==
--- 
cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap 
(added)
+++ 
cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap 
Mon Jun  5 17:29:36 2017
@@ -0,0 +1,3 @@
+module "module" {
+  header "module.h"
+}

Added: cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp?rev=304745&view=auto
==
--- cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp (added)
+++ cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp Mon Jun  5 
17:29:36 2017
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=module -o 
%T/module.pcm -emit-module 
%S/Inputs/crash-typo-correction-visibility/module.modulemap
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%T/module.pcm %s 
-verify
+
+struct S {
+  int member; // expected-note {{declared here}}
+};
+
+int f(...);
+
+int b = sizeof(f(member)); // expected-error {{undeclared identifier 'member'}}


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


[PATCH] D30963: Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls replaced by visible decls.

2017-06-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304745: Fix crash when an 'import a module' TypoCorrection 
has its CorrectionDecls (authored by rsmith).

Changed prior to commit:
  https://reviews.llvm.org/D30963?vs=101437&id=101466#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30963

Files:
  cfe/trunk/lib/Sema/SemaLookup.cpp
  cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h
  
cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
  cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp


Index: cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
===
--- cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
+++ cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=module -o 
%T/module.pcm -emit-module 
%S/Inputs/crash-typo-correction-visibility/module.modulemap
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%T/module.pcm %s 
-verify
+
+struct S {
+  int member; // expected-note {{declared here}}
+};
+
+int f(...);
+
+int b = sizeof(f(member)); // expected-error {{undeclared identifier 'member'}}
Index: 
cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
===
--- 
cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
+++ 
cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
@@ -0,0 +1,3 @@
+module "module" {
+  header "module.h"
+}
Index: cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h
===
--- cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h
+++ cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h
@@ -0,0 +1 @@
+struct member;
Index: cfe/trunk/lib/Sema/SemaLookup.cpp
===
--- cfe/trunk/lib/Sema/SemaLookup.cpp
+++ cfe/trunk/lib/Sema/SemaLookup.cpp
@@ -3747,20 +3747,19 @@
   bool FindHidden);
 
 /// \brief Check whether the declarations found for a typo correction are
-/// visible, and if none of them are, convert the correction to an 'import
-/// a module' correction.
+/// visible. Set the correction's RequiresImport flag to true if none of the
+/// declarations are visible, false otherwise.
 static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC) {
-  if (TC.begin() == TC.end())
-return;
-
   TypoCorrection::decl_iterator DI = TC.begin(), DE = TC.end();
 
   for (/**/; DI != DE; ++DI)
 if (!LookupResult::isVisible(SemaRef, *DI))
   break;
-  // Nothing to do if all decls are visible.
-  if (DI == DE)
+  // No filtering needed if all decls are visible.
+  if (DI == DE) {
+TC.setRequiresImport(false);
 return;
+  }
 
   llvm::SmallVector NewDecls(TC.begin(), DI);
   bool AnyVisibleDecls = !NewDecls.empty();


Index: cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
===
--- cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
+++ cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=module -o %T/module.pcm -emit-module %S/Inputs/crash-typo-correction-visibility/module.modulemap
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%T/module.pcm %s -verify
+
+struct S {
+  int member; // expected-note {{declared here}}
+};
+
+int f(...);
+
+int b = sizeof(f(member)); // expected-error {{undeclared identifier 'member'}}
Index: cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
===
--- cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
+++ cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
@@ -0,0 +1,3 @@
+module "module" {
+  header "module.h"
+}
Index: cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h
===
--- cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h
+++ cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h
@@ -0,0 +1 @@
+struct member;
Index: cfe/trunk/lib/Sema/SemaLookup.cpp
===
--- cfe/trunk/lib/Sema/SemaLookup.cpp
+++ cfe/trunk/lib/Sema/SemaLookup.cpp
@@ -3747,20 +3747,19 @@
   bool FindHidden);
 
 /// \brief Check whether the declarations found for a typo correction are
-/// visible, and if none of them are, convert the correction to an 'import
-/// a module' correction.
+

[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Looks good, with a couple of tweaks (and corresponding test changes).




Comment at: lib/CodeGen/CGExprScalar.cpp:3910-3911
 (Opcode == BO_Add) ? SAddIntrinsic : SMulIntrinsic, {LHS, RHS});
 OffsetOverflows = Builder.CreateOr(
 OffsetOverflows, Builder.CreateExtractValue(ResultAndOverflow, 1));
 return Builder.CreateExtractValue(ResultAndOverflow, 0);

Reverse the order of operands here; Builder will simplify `or` instructions 
with a constant RHS.



Comment at: lib/CodeGen/CGExprScalar.cpp:3963-3965
+ValidGEP = Builder.CreateAnd(
+NoOffsetOverflow,
+Builder.CreateSelect(PosOrZeroOffset, PosOrZeroValid, NegValid));

Likewise reverse the operand order here



Comment at: lib/CodeGen/CGExprScalar.cpp:3967
+  } else {
+ValidGEP = Builder.CreateAnd(NoOffsetOverflow, PosOrZeroValid);
+  }

... and here.


https://reviews.llvm.org/D33910



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


[PATCH] D33820: [PowerPC] Pass CPU to assembler with -no-integrated-as

2017-06-05 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

One inline comment otherwise LGTM




Comment at: lib/Driver/ToolChains/Gnu.cpp:681
 CmdArgs.push_back("-mppc");
-CmdArgs.push_back("-many");
+std::string CPU = getCPUName(Args, getToolChain().getTriple());
+CmdArgs.push_back(ppc::getPPCAsmModeForCPU(CPU));

Probably don't need to store it to a temporary since the other function is just 
returning a const char *.


Repository:
  rL LLVM

https://reviews.llvm.org/D33820



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


[PATCH] D33721: [ARM] Add support for target("arm") and target("thumb").

2017-06-05 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Ah right. Thanks for looking.

LGTM.

-eric


https://reviews.llvm.org/D33721



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


[PATCH] D33920: [index] Record C++17 binding declarations

2017-06-05 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

Global binding declarations should be recorded as `variable` symbols.


Repository:
  rL LLVM

https://reviews.llvm.org/D33920

Files:
  lib/Index/IndexDecl.cpp
  lib/Index/IndexSymbol.cpp
  test/Index/Core/index-source.cpp


Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -1,4 +1,4 @@
-// RUN: c-index-test core -print-source-symbols -- %s -std=c++14 -target 
x86_64-apple-macosx10.7 | FileCheck %s
+// RUN: c-index-test core -print-source-symbols -- %s -std=c++1z -target 
x86_64-apple-macosx10.7 | FileCheck %s
 
 // CHECK: [[@LINE+1]]:7 | class/C++ | Cls | [[Cls_USR:.*]] |  | Def 
| rel: 0
 class Cls { public:
@@ -433,3 +433,29 @@
 T varDecl = T();
 
 } // end namespace ensureDefaultTemplateParamsAreRecordedOnce
+
+namespace cpp17structuredBinding {
+
+struct Cpp17StructuredBinding {
+  int x, y;
+
+  Cpp17StructuredBinding(int x, int y): x(x), y(y) { }
+};
+
+auto [structuredBinding1, structuredBinding2] = 
Cpp17StructuredBinding(Record::C, 0);
+// CHECK: [[@LINE-1]]:7 | variable/C++ | structuredBinding1 | 
c:@N@cpp17structuredBinding@structuredBinding1 |  | Decl,RelChild | 
rel: 1
+// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N@cpp17structuredBinding
+// CHECK: [[@LINE-3]]:27 | variable/C++ | structuredBinding2 | 
c:@N@cpp17structuredBinding@structuredBinding2 |  | Decl,RelChild | 
rel: 1
+// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N@cpp17structuredBinding
+
+void localStructuredBindingAndRef() {
+  int ref = structuredBinding1;
+// CHECK: [[@LINE-1]]:13 | variable/C++ | structuredBinding1 | 
c:@N@cpp17structuredBinding@structuredBinding1 |  | Ref,Read,RelCont 
| rel: 1
+// CHECK-NEXT: RelCont | localStructuredBindingAndRef | 
c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef#
+  auto [localBinding1, localBinding2] = Cpp17StructuredBinding(ref, 
structuredBinding2);
+// CHECK: [[@LINE-1]]:69 | variable/C++ | structuredBinding2 | 
c:@N@cpp17structuredBinding@structuredBinding2 |  | Ref,Read,RelCont 
| rel: 1
+// CHECK-NEXT: RelCont | localStructuredBindingAndRef | 
c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef#
+// CHECK-NOT: localBinding
+}
+
+}
Index: lib/Index/IndexSymbol.cpp
===
--- lib/Index/IndexSymbol.cpp
+++ lib/Index/IndexSymbol.cpp
@@ -301,6 +301,10 @@
   Info.Kind = SymbolKind::TypeAlias;
   Info.Lang = SymbolLanguage::CXX;
   break;
+case Decl::Binding:
+  Info.Kind = SymbolKind::Variable;
+  Info.Lang = SymbolLanguage::CXX;
+  break;
 default:
   break;
 }
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -293,6 +293,12 @@
 return true;
   }
 
+  bool VisitDecompositionDecl(const DecompositionDecl *D) {
+for (const auto *Binding : D->bindings())
+  TRY_DECL(Binding, IndexCtx.handleDecl(Binding));
+return Base::VisitDecompositionDecl(D);
+  }
+
   bool VisitFieldDecl(const FieldDecl *D) {
 SmallVector Relations;
 gatherTemplatePseudoOverrides(D, Relations);


Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -1,4 +1,4 @@
-// RUN: c-index-test core -print-source-symbols -- %s -std=c++14 -target x86_64-apple-macosx10.7 | FileCheck %s
+// RUN: c-index-test core -print-source-symbols -- %s -std=c++1z -target x86_64-apple-macosx10.7 | FileCheck %s
 
 // CHECK: [[@LINE+1]]:7 | class/C++ | Cls | [[Cls_USR:.*]] |  | Def | rel: 0
 class Cls { public:
@@ -433,3 +433,29 @@
 T varDecl = T();
 
 } // end namespace ensureDefaultTemplateParamsAreRecordedOnce
+
+namespace cpp17structuredBinding {
+
+struct Cpp17StructuredBinding {
+  int x, y;
+
+  Cpp17StructuredBinding(int x, int y): x(x), y(y) { }
+};
+
+auto [structuredBinding1, structuredBinding2] = Cpp17StructuredBinding(Record::C, 0);
+// CHECK: [[@LINE-1]]:7 | variable/C++ | structuredBinding1 | c:@N@cpp17structuredBinding@structuredBinding1 |  | Decl,RelChild | rel: 1
+// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N@cpp17structuredBinding
+// CHECK: [[@LINE-3]]:27 | variable/C++ | structuredBinding2 | c:@N@cpp17structuredBinding@structuredBinding2 |  | Decl,RelChild | rel: 1
+// CHECK-NEXT: RelChild | cpp17structuredBinding | c:@N@cpp17structuredBinding
+
+void localStructuredBindingAndRef() {
+  int ref = structuredBinding1;
+// CHECK: [[@LINE-1]]:13 | variable/C++ | structuredBinding1 | c:@N@cpp17structuredBinding@structuredBinding1 |  | Ref,Read,RelCont | rel: 1
+// CHECK-NEXT: RelCont | localStructuredBindingAndRef | c:@N@cpp17structuredBinding@F@localStructuredBindingAndRef#
+  auto [localBinding1, localBinding2] = Cpp17StructuredBinding(ref, structuredBinding2);
+//

[PATCH] D17215: [Sema] Fix PR14211 Crash for explicit instantiation of overloaded template function within class template

2017-06-05 Thread don hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 101482.
hintonda added a comment.

Fixes PR14211.

Since getMostSpecialized only handles FunctionTemplateDecl matches,
keep track of non-FunctionTemplateDecl matches and only call
getMostSpecialized if no non-FunctionTemplateDecl matches are found.

Added tests.


https://reviews.llvm.org/D17215

Files:
  lib/Sema/SemaTemplate.cpp
  test/CXX/temp/temp.decls/temp.mem/p5.cpp


Index: test/CXX/temp/temp.decls/temp.mem/p5.cpp
===
--- test/CXX/temp/temp.decls/temp.mem/p5.cpp
+++ test/CXX/temp/temp.decls/temp.mem/p5.cpp
@@ -77,3 +77,16 @@
   x0.operator float *();
   x0c.operator const char*();
 }
+
+namespace PR14211 {
+template  struct X {
+  void foo(U){}
+  template  void foo(T){}
+
+  template  void bar(T){}
+  void bar(U){}
+};
+
+template void X::foo(int);
+template void X::bar(int);
+}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -8956,6 +8956,7 @@
   //  instantiated from the member definition associated with its class
   //  template.
   UnresolvedSet<8> Matches;
+  FunctionDecl *NonTemplateMatch = nullptr;
   AttributeList *Attr = D.getDeclSpec().getAttributes().getList();
   TemplateSpecCandidateSet FailedCandidates(D.getIdentifierLoc());
   for (LookupResult::iterator P = Previous.begin(), PEnd = Previous.end();
@@ -8966,12 +8967,22 @@
 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
 /*AdjustExceptionSpec*/true);
 if (Context.hasSameUnqualifiedType(Method->getType(), Adjusted)) {
-  Matches.clear();
-
+  if (!Method->getPrimaryTemplate()) {
+// FIXME: Can this assert ever happen?  Needs a test.
+assert(!NonTemplateMatch && "Multiple NonTemplateMatches");
+NonTemplateMatch = Method;
+continue;
+  }
   Matches.addDecl(Method, P.getAccess());
+
+  // FIXME: Can this ever be true?  Even so, should it really be a
+  // break?  Needs a test.
   if (Method->getTemplateSpecializationKind() == TSK_Undeclared)
 break;
+  continue;
 }
+// FIXME:  Would this be considered an almost match as well?
+continue;
   }
 }
 
@@ -9012,19 +9023,22 @@
 Matches.addDecl(Specialization, P.getAccess());
   }
 
-  // Find the most specialized function template specialization.
-  UnresolvedSetIterator Result = getMostSpecialized(
-  Matches.begin(), Matches.end(), FailedCandidates,
-  D.getIdentifierLoc(),
-  PDiag(diag::err_explicit_instantiation_not_known) << Name,
-  PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
-  PDiag(diag::note_explicit_instantiation_candidate));
-
-  if (Result == Matches.end())
-return true;
+  FunctionDecl *Specialization = NonTemplateMatch;
+  if (!Specialization) {
+// Find the most specialized function template specialization.
+UnresolvedSetIterator Result = getMostSpecialized(
+Matches.begin(), Matches.end(), FailedCandidates,
+D.getIdentifierLoc(),
+PDiag(diag::err_explicit_instantiation_not_known) << Name,
+PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
+PDiag(diag::note_explicit_instantiation_candidate));
+
+if (Result == Matches.end())
+  return true;
 
-  // Ignore access control bits, we don't need them for redeclaration checking.
-  FunctionDecl *Specialization = cast(*Result);
+// Ignore access control bits, we don't need them for redeclaration 
checking.
+Specialization = cast(*Result);
+  }
 
   // C++11 [except.spec]p4
   // In an explicit instantiation an exception-specification may be specified,


Index: test/CXX/temp/temp.decls/temp.mem/p5.cpp
===
--- test/CXX/temp/temp.decls/temp.mem/p5.cpp
+++ test/CXX/temp/temp.decls/temp.mem/p5.cpp
@@ -77,3 +77,16 @@
   x0.operator float *();
   x0c.operator const char*();
 }
+
+namespace PR14211 {
+template  struct X {
+  void foo(U){}
+  template  void foo(T){}
+
+  template  void bar(T){}
+  void bar(U){}
+};
+
+template void X::foo(int);
+template void X::bar(int);
+}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -8956,6 +8956,7 @@
   //  instantiated from the member definition associated with its class
   //  template.
   UnresolvedSet<8> Matches;
+  FunctionDecl *NonTemplateMatch = nullptr;
   AttributeList *Attr = D.getDeclSpec().getAttributes().getList();
   TemplateSpecCandidateSet FailedCandidates(D.getIdentifierLoc());
   for (LookupResult::iterator P = Previous.begin(), PEnd = Previous.end();
@@ -8966,12 +8967,22 @@
 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
   

[PATCH] D33735: [DebugInfo] Add ThisOrSelf attribute for emission of FlagObjectPointer.

2017-06-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/Decl.h:1387
+IPK_CapturedContext, /// Parameter for captured context
+IPK_GeneralParam,/// General implicit parameter
+  };

I would just call this "Other" and document it as being for kinds of implicit 
parameters that we haven't seen a purpose in categorizing yet.  (Or you could 
just classify them all, I suppose.)

We can use C++11 features in Clang now, so I would recommend hoisting this type 
out of ImplicitParamDecl and making it an enum class.  You can then drop the 
"IPK_" prefixes.



Comment at: include/clang/AST/Decl.h:1394
+  /// Whether this parameter represents implicit 'this'|'self' argument in
+  /// member functions.
+  ImplicitParamKind ParamKind;

Comment is out-of-date.

Also, please compress this into VarDecl's bit-field storage.



Comment at: include/clang/AST/Decl.h:1405
+  static ImplicitParamDecl *Create(ASTContext &C, QualType T,
+   DeclContext *DC = nullptr);
 

I see the point in having a convenience constructor like this, but it should 
probably still take an IPK.



Comment at: include/clang/AST/Decl.h:1426
 setImplicit();
   }
 

Same idea.  This should probably still take an IPK.



Comment at: include/clang/AST/Decl.h:1429
+  /// Returns true if the parameter represents implicit 'this' or 'self'
+  /// argument in member functions.
+  ImplicitParamKind getParameterKind() const { return ParamKind; }

This comment is out-of-date.



Comment at: lib/CodeGen/CGDebugInfo.cpp:3475
+Flags |= llvm::DINode::FlagObjectPointer;
+}
 

Looks like this whole block is still unnecessarily indented.



Comment at: lib/CodeGen/CGException.cpp:1654
+  IPD->setLocation(StartLoc);
+  IPD->setDeclName(&getContext().Idents.get("exception_pointers"));
+  Args.push_back(IPD);

These do not feel like good uses of your shorthand constructors.


https://reviews.llvm.org/D33735



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


r304756 - Retain header search and preprocessing options from AST file when emitting

2017-06-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun  5 19:32:01 2017
New Revision: 304756

URL: http://llvm.org/viewvc/llvm-project?rev=304756&view=rev
Log:
Retain header search and preprocessing options from AST file when emitting
preprocessed text for an AST file.

Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Modules/preprocess-module.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=304756&r1=304755&r2=304756&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Mon Jun  5 19:32:01 2017
@@ -54,6 +54,7 @@ class HeaderSearch;
 class InputKind;
 class MemoryBufferCache;
 class Preprocessor;
+class PreprocessorOptions;
 class PCHContainerOperations;
 class PCHContainerReader;
 class TargetInfo;
@@ -97,6 +98,7 @@ private:
   IntrusiveRefCntPtr  Ctx;
   std::shared_ptr  TargetOpts;
   std::shared_ptrHSOpts;
+  std::shared_ptrPPOpts;
   IntrusiveRefCntPtr Reader;
   bool HadModuleLoaderFatalFailure;
 
@@ -516,9 +518,19 @@ public:
   }
 
   const LangOptions &getLangOpts() const {
-assert(LangOpts && " ASTUnit does not have language options");
+assert(LangOpts && "ASTUnit does not have language options");
 return *LangOpts;
   }
+
+  const HeaderSearchOptions &getHeaderSearchOpts() const {
+assert(HSOpts && "ASTUnit does not have header search options");
+return *HSOpts;
+  }
+  
+  const PreprocessorOptions &getPreprocessorOpts() const {
+assert(PPOpts && "ASTUnit does not have preprocessor options");
+return *PPOpts;
+  }
   
   const FileManager &getFileManager() const { return *FileMgr; }
 FileManager &getFileManager()   { return *FileMgr; }

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=304756&r1=304755&r2=304756&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Jun  5 19:32:01 2017
@@ -486,6 +486,8 @@ namespace {
 class ASTInfoCollector : public ASTReaderListener {
   Preprocessor &PP;
   ASTContext &Context;
+  HeaderSearchOptions &HSOpts;
+  PreprocessorOptions &PPOpts;
   LangOptions &LangOpt;
   std::shared_ptr &TargetOpts;
   IntrusiveRefCntPtr &Target;
@@ -493,11 +495,14 @@ class ASTInfoCollector : public ASTReade
 
   bool InitializedLanguage;
 public:
-  ASTInfoCollector(Preprocessor &PP, ASTContext &Context, LangOptions &LangOpt,
+  ASTInfoCollector(Preprocessor &PP, ASTContext &Context,
+   HeaderSearchOptions &HSOpts, PreprocessorOptions &PPOpts,
+   LangOptions &LangOpt,
std::shared_ptr &TargetOpts,
IntrusiveRefCntPtr &Target, unsigned &Counter)
-  : PP(PP), Context(Context), LangOpt(LangOpt), TargetOpts(TargetOpts),
-Target(Target), Counter(Counter), InitializedLanguage(false) {}
+  : PP(PP), Context(Context), HSOpts(HSOpts), PPOpts(PPOpts),
+LangOpt(LangOpt), TargetOpts(TargetOpts), Target(Target),
+Counter(Counter), InitializedLanguage(false) {}
 
   bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
bool AllowCompatibleDifferences) override {
@@ -511,6 +516,20 @@ public:
 return false;
   }
 
+  virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+   StringRef SpecificModuleCachePath,
+   bool Complain) override {
+this->HSOpts = HSOpts;
+return false;
+  }
+
+  virtual bool
+  ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain,
+  std::string &SuggestedPredefines) override {
+this->PPOpts = PPOpts;
+return false;
+  }
+
   bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
  bool AllowCompatibleDifferences) override {
 // If we've already initialized the target, don't do it again.
@@ -685,11 +704,10 @@ std::unique_ptr ASTUnit::LoadFr
  AST->getDiagnostics(),
  AST->getLangOpts(),
  /*Target=*/nullptr));
-
-  auto PPOpts = std::make_shared();
+  AST->PPOpts = std::make_shared();
 
   for (const auto &RemappedFile : RemappedFiles)
-PPOpts->addRemappedFile(RemappedFile.first, RemappedFile.second);
+AST->PPOpts->addRemappedFile(RemappedFile.first, RemappedFile.second);
 
   // Gather Info for preprocessor construction later on.
 
@@ 

[PATCH] D17215: [Sema] Fix PR14211 Crash for explicit instantiation of overloaded template function within class template

2017-06-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaTemplate.cpp:8985
+// FIXME:  Would this be considered an almost match as well?
+continue;
   }

These continues that you're adding are already at the end of the loop body, so 
this code is really confusing.

I think the template-specialization check here is trying to do the same thing 
you're doing: treat non-template matches specially.  But your way of handling 
it is better, so I would just remove the check and all the breaks and continues 
so that we add the match to either NonTemplateMatch or TemplateMatches.  
(Please do rename Matches to TemplateMatches, though.)


https://reviews.llvm.org/D17215



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


[PATCH] D32109: [Driver] Limit .exe extension addition to Windows hosts

2017-06-05 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai abandoned this revision.
smeenai added a comment.

Will just drop the .exe entirely, since that works


https://reviews.llvm.org/D32109



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


[PATCH] D33923: [Driver] Don't force .exe suffix for lld

2017-06-05 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.

When cross-compiling to Windows using lld, we want the driver to invoke
it as lld-link rather than lld-link.exe. On Windows, the LLVM fs
functions take care of adding the .exe suffix where necessary, so we can
just drop the addition in the toolchain entirely.


https://reviews.llvm.org/D33923

Files:
  lib/Driver/ToolChains/MSVC.cpp
  test/Driver/cl-link.c


Index: test/Driver/cl-link.c
===
--- test/Driver/cl-link.c
+++ test/Driver/cl-link.c
@@ -56,4 +56,4 @@
 // NONEXISTENT: nonexistent
 
 // RUN: %clang_cl /Tc%s -fuse-ld=lld -### 2>&1 | FileCheck 
--check-prefix=USE_LLD %s
-// USE_LLD: lld-link.exe
+// USE_LLD: lld-link
Index: lib/Driver/ToolChains/MSVC.cpp
===
--- lib/Driver/ToolChains/MSVC.cpp
+++ lib/Driver/ToolChains/MSVC.cpp
@@ -529,9 +529,7 @@
   SkipSettingEnvironment:;
 #endif
   } else {
-linkPath = Linker;
-llvm::sys::path::replace_extension(linkPath, "exe");
-linkPath = TC.GetProgramPath(linkPath.c_str());
+linkPath = TC.GetProgramPath(Linker.str().c_str());
   }
 
   auto LinkCmd = llvm::make_unique(


Index: test/Driver/cl-link.c
===
--- test/Driver/cl-link.c
+++ test/Driver/cl-link.c
@@ -56,4 +56,4 @@
 // NONEXISTENT: nonexistent
 
 // RUN: %clang_cl /Tc%s -fuse-ld=lld -### 2>&1 | FileCheck --check-prefix=USE_LLD %s
-// USE_LLD: lld-link.exe
+// USE_LLD: lld-link
Index: lib/Driver/ToolChains/MSVC.cpp
===
--- lib/Driver/ToolChains/MSVC.cpp
+++ lib/Driver/ToolChains/MSVC.cpp
@@ -529,9 +529,7 @@
   SkipSettingEnvironment:;
 #endif
   } else {
-linkPath = Linker;
-llvm::sys::path::replace_extension(linkPath, "exe");
-linkPath = TC.GetProgramPath(linkPath.c_str());
+linkPath = TC.GetProgramPath(Linker.str().c_str());
   }
 
   auto LinkCmd = llvm::make_unique(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-05 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 101479.
vsk marked 3 inline comments as done.
vsk added a comment.

Thanks for the review comments. I've changed the calls which use Builder as 
suggested, and fixed up the tests.

It sounds like this patch is in good shape, so I'll commit this after two days 
provided that there's no blocking feedback.


https://reviews.llvm.org/D33910

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ubsan-pointer-overflow.m

Index: test/CodeGen/ubsan-pointer-overflow.m
===
--- test/CodeGen/ubsan-pointer-overflow.m
+++ test/CodeGen/ubsan-pointer-overflow.m
@@ -5,17 +5,13 @@
   // CHECK:  [[BASE:%.*]] = ptrtoint i8* {{.*}} to i64, !nosanitize
   // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], 1, !nosanitize
   // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
-  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
-  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 true, i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
-  // CHECK-NEXT: [[VALID:%.*]] = and i1 true, [[DIFFVALID]], !nosanitize
-  // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
+  // CHECK-NEXT: br i1 [[POSVALID]]{{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize
   ++p;
 
   // CHECK: ptrtoint i8* {{.*}} to i64, !nosanitize
   // CHECK-NEXT: add i64 {{.*}}, -1, !nosanitize
   // CHECK: select i1 false{{.*}}, !nosanitize
-  // CHECK-NEXT: and i1 true{{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
   --p;
 
@@ -30,16 +26,35 @@
 void binary_arith(char *p, int i) {
   // CHECK: [[SMUL:%.*]] = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 1, i64 %{{.*}}), !nosanitize
   // CHECK-NEXT: [[SMULOFLOW:%.*]] = extractvalue { i64, i1 } [[SMUL]], 1, !nosanitize
-  // CHECK-NEXT: [[OFFSETOFLOW:%.*]] = or i1 false, [[SMULOFLOW]], !nosanitize
   // CHECK-NEXT: [[SMULVAL:%.*]] = extractvalue { i64, i1 } [[SMUL]], 0, !nosanitize
   // CHECK-NEXT: [[BASE:%.*]] = ptrtoint i8* {{.*}} to i64, !nosanitize
   // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], [[SMULVAL]], !nosanitize
+  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[SMULOFLOW]], true, !nosanitize
   // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
-  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
   // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize
-  // CHECK-DAG: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize
-  // CHECK-DAG: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
-  // CHECK: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize
+  // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize
+  // CHECK: [[VALID:%.*]] = and i1 [[DIFFVALID]], [[OFFSETVALID]], !nosanitize
+  // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize
+  p + i;
+
+  // CHECK: [[OFFSET:%.*]] = sub i64 0, {{.*}}
+  // CHECK-NEXT: getelementptr inbounds {{.*}} [[OFFSET]]
+  // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
+  p - i;
+}
+
+// CHECK-LABEL: define void @binary_arith_unsigned
+void binary_arith_unsigned(char *p, unsigned i) {
+  // CHECK: [[SMUL:%.*]] = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 1, i64 %{{.*}}), !nosanitize
+  // CHECK-NEXT: [[SMULOFLOW:%.*]] = extractvalue { i64, i1 } [[SMUL]], 1, !nosanitize
+  // CHECK-NEXT: [[SMULVAL:%.*]] = extractvalue { i64, i1 } [[SMUL]], 0, !nosanitize
+  // CHECK-NEXT: [[BASE:%.*]] = ptrtoint i8* {{.*}} to i64, !nosanitize
+  // CHECK-NEXT: [[COMPGEP:%.*]] = add i64 [[BASE]], [[SMULVAL]], !nosanitize
+  // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[SMULOFLOW]], true, !nosanitize
+  // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize
+  // CHECK: [[VALID:%.*]] = and i1 [[POSVALID]], [[OFFSETVALID]], !nosanitize
   // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize
   // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize
   p + i;
@@ -55,16 +70,15 @@
   // CHECK: getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* [[ARR:%.*]], i64 0, i64 [[IDXPROM:%.*]]
   // CHECK-NEXT: [[SMUL:%.*]] = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 40, i64 [[IDXPROM]]), !nosanitize
   // CHECK-NEXT: [[SMULOFLOW:%.*]] = extractvalue { i64, i1 } [[SMUL]], 1, !nosanitize
-  // CHECK-NEXT: [[OFFSETOFLOW:%.*]] = or i1 false, [[SMULOFLOW]], !nosanitize
   // CHECK-NEXT: [[SMULVAL:%.*]] = extractvalue { i64, i1 } [[SMUL]], 0, !nosanitize
   // CHECK-NEXT: [[BAS

[PATCH] D33923: [Driver] Don't force .exe suffix for lld

2017-06-05 Thread Zachary Turner via Phabricator via cfe-commits
zturner accepted this revision.
zturner added a comment.
This revision is now accepted and ready to land.

Seems fine to me.


https://reviews.llvm.org/D33923



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


[PATCH] D32671: [libcxx] [test] variant: test coverage for LWG2904 and P0602

2017-06-05 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 101497.
CaseyCarter retitled this revision from "[libcxx] [test] variant: test coverage 
for P0602 extension" to "[libcxx] [test] variant: test coverage for LWG2904 and 
P0602".
CaseyCarter edited the summary of this revision.
CaseyCarter added a comment.

Massive update: Move the libcxx tree tests into std, merge my LWG2904 
differential.


https://reviews.llvm.org/D32671

Files:
  test/libcxx/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/libcxx/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/libcxx/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/libcxx/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
  test/support/variant_test_helpers.hpp

Index: test/support/variant_test_helpers.hpp
===
--- test/support/variant_test_helpers.hpp
+++ test/support/variant_test_helpers.hpp
@@ -69,9 +69,9 @@
 void makeEmpty(Variant& v) {
 Variant v2(std::in_place_type);
 try {
-v = v2;
+v = std::move(v2);
 assert(false);
-}  catch (...) {
+} catch (...) {
 assert(v.valueless_by_exception());
 }
 }
Index: test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -53,6 +53,34 @@
   MoveOnlyNT(MoveOnlyNT &&other) : value(other.value) { other.value = -1; }
 };
 
+struct NTMove {
+  constexpr NTMove(int v) : value(v) {}
+  NTMove(const NTMove &) = delete;
+  NTMove(NTMove &&that) : value(that.value) { that.value = -1; }
+  int value;
+};
+
+static_assert(!std::is_trivially_move_constructible::value, "");
+static_assert(std::is_move_constructible::value, "");
+
+struct TMove {
+  constexpr TMove(int v) : value(v) {}
+  TMove(const TMove &) = delete;
+  TMove(TMove &&) = default;
+  int value;
+};
+
+static_assert(std::is_trivially_move_constructible::value, "");
+
+struct TMoveNTCopy {
+  constexpr TMoveNTCopy(int v) : value(v) {}
+  TMoveNTCopy(const TMoveNTCopy& that) : value(that.value) {}
+  TMoveNTCopy(TMoveNTCopy&&) = default;
+  int value;
+};
+
+static_assert(std::is_trivially_move_constructible::value, "");
+
 #ifndef TEST_HAS_NO_EXCEPTIONS
 struct MakeEmptyT {
   static int alive;
@@ -73,7 +101,7 @@
 template  void makeEmpty(Variant &v) {
   Variant v2(std::in_place_type);
   try {
-v = v2;
+v = std::move(v2);
 assert(false);
   } catch (...) {
 assert(v.valueless_by_exception());
@@ -117,8 +145,30 @@
 using V = std::variant;
 static_assert(!std::is_move_constructible::value, "");
   }
+
+  // The following tests are for not-yet-standardized behavior (P0602):
+  {
+using V = std::variant;
+static_assert(std::is_trivially_move_constructible::value, "");
+  }
+  {
+using V = std::variant;
+static_assert(!std::is_trivially_move_constructible::value, "");
+static_assert(std::is_move_constructible::value, "");
+  }
+  {
+using V = std::variant;
+static_assert(std::is_trivially_move_constructible::value, "");
+  }
+  {
+using V = std::variant;
+static_assert(std::is_trivially_move_constructible::value, "");
+  }
 }
 
+template 
+struct Result { size_t index; T value; };
+
 void test_move_ctor_basic() {
   {
 std::variant v(std::in_place_index<0>, 42);
@@ -162,6 +212,80 @@
 assert(std::get<1>(v).value == -1);
 assert(std::get<1>(v2).value == 42);
   }
+
+  // The following tests are for not-yet-standardized behavior (P0602):
+  {
+struct {
+  constexpr Result operator()() const {
+std::variant v(std::in_place_index<0>, 42);
+std::variant v2 = std::move(v);
+return {v2.index(), std::get<0>(std::move(v2))};
+  }
+} test;
+constexpr auto result = test();
+static_assert(result.index == 0, "");
+static_assert(result.value == 42, "");
+  }
+  {
+struct {
+  constexpr Result operator()() const {
+std::variant v(std::in_place_index<1>, 42);
+std::variant v2 = std::move(v);
+return {v2.index(), std::get<1>(std::move(v2))};
+  }
+} test;
+constexpr auto result = test();
+static_assert(result.index == 1, "");
+static_assert(result.value == 42, "");
+  }
+  {
+struct {
+  constexpr Result operator()() const {
+std::variant v(std::in_place_index<0>, 42);
+std::variant v2(std::move(v));
+return {v2.index(), std::get<0>(std

[PATCH] D32515: [libcxx] [test] Changes to accommodate LWG 2904 "Make variant move-assignment more exception safe"

2017-06-05 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter abandoned this revision.
CaseyCarter added a comment.

Abandoning: these changes have been merged into https://reviews.llvm.org/D32671.


https://reviews.llvm.org/D32515



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


r304760 - PR33318: Add missing full-expression checking to static_assert expression.

2017-06-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun  5 20:34:24 2017
New Revision: 304760

URL: http://llvm.org/viewvc/llvm-project?rev=304760&view=rev
Log:
PR33318: Add missing full-expression checking to static_assert expression.

This fixes missing lambda-captures for variables referenced only inside a
static_assert (!), among other things.

Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=304760&r1=304759&r2=304760&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Jun  5 20:34:24 2017
@@ -1461,7 +1461,8 @@ public:
   };
 
   ExprResult ParseExpression(TypeCastState isTypeCast = NotTypeCast);
-  ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState 
isTypeCast);
+  ExprResult ParseConstantExpressionInExprEvalContext(
+  TypeCastState isTypeCast = NotTypeCast);
   ExprResult ParseConstantExpression(TypeCastState isTypeCast = NotTypeCast);
   ExprResult ParseConstraintExpression();
   // Expr that doesn't include commas.

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=304760&r1=304759&r2=304760&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Jun  5 20:34:24 2017
@@ -840,7 +840,9 @@ Decl *Parser::ParseStaticAssertDeclarati
 return nullptr;
   }
 
-  ExprResult AssertExpr(ParseConstantExpression());
+  EnterExpressionEvaluationContext ConstantEvaluated(
+  Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated);
+  ExprResult AssertExpr(ParseConstantExpressionInExprEvalContext());
   if (AssertExpr.isInvalid()) {
 SkipMalformedDecl();
 return nullptr;

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=304760&r1=304759&r2=304760&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Jun  5 20:34:24 2017
@@ -13232,6 +13232,14 @@ Decl *Sema::BuildStaticAssertDeclaration
 }
   }
 
+  ExprResult FullAssertExpr = ActOnFinishFullExpr(AssertExpr, StaticAssertLoc,
+  /*DiscardedValue*/false,
+  /*IsConstexpr*/true);
+  if (FullAssertExpr.isInvalid())
+Failed = true;
+  else
+AssertExpr = FullAssertExpr.get();
+
   Decl *Decl = StaticAssertDecl::Create(Context, CurContext, StaticAssertLoc,
 AssertExpr, AssertMessage, RParenLoc,
 Failed);

Modified: cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp?rev=304760&r1=304759&r2=304760&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp Mon Jun  5 
20:34:24 2017
@@ -1376,3 +1376,7 @@ XT xt{};
 
 
 }
+
+void PR33318(int i) {
+  [&](auto) { static_assert(&i != nullptr, ""); }(0); // expected-warning 
2{{always true}} expected-note {{instantiation}}
+}

Modified: cfe/trunk/test/SemaTemplate/deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/deduction.cpp?rev=304760&r1=304759&r2=304760&view=diff
==
--- cfe/trunk/test/SemaTemplate/deduction.cpp (original)
+++ cfe/trunk/test/SemaTemplate/deduction.cpp Mon Jun  5 20:34:24 2017
@@ -305,11 +305,11 @@ namespace nullptr_deduction {
 
   template struct X {};
   template void f(X) {
-static_assert(!v, "");
+static_assert(!v, ""); // expected-warning 2{{implicit conversion of 
nullptr constant to 'bool'}}
   }
   void g() {
-f(X());
-f(X());
+f(X()); // expected-note {{instantiation of}}
+f(X()); // expected-note {{instantiation of}}
   }
 
   template class X, typename T, typename U, int *P>


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


r304761 - [Driver] Don't force .exe suffix for lld

2017-06-05 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Jun  5 21:06:28 2017
New Revision: 304761

URL: http://llvm.org/viewvc/llvm-project?rev=304761&view=rev
Log:
[Driver] Don't force .exe suffix for lld

When cross-compiling to Windows using lld, we want the driver to invoke
it as lld-link rather than lld-link.exe. On Windows, the LLVM fs
functions take care of adding the .exe suffix where necessary, so we can
just drop the addition in the toolchain entirely.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
cfe/trunk/test/Driver/cl-link.c

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=304761&r1=304760&r2=304761&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Mon Jun  5 21:06:28 2017
@@ -529,9 +529,7 @@ void visualstudio::Linker::ConstructJob(
   SkipSettingEnvironment:;
 #endif
   } else {
-linkPath = Linker;
-llvm::sys::path::replace_extension(linkPath, "exe");
-linkPath = TC.GetProgramPath(linkPath.c_str());
+linkPath = TC.GetProgramPath(Linker.str().c_str());
   }
 
   auto LinkCmd = llvm::make_unique(

Modified: cfe/trunk/test/Driver/cl-link.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-link.c?rev=304761&r1=304760&r2=304761&view=diff
==
--- cfe/trunk/test/Driver/cl-link.c (original)
+++ cfe/trunk/test/Driver/cl-link.c Mon Jun  5 21:06:28 2017
@@ -56,4 +56,4 @@
 // NONEXISTENT: nonexistent
 
 // RUN: %clang_cl /Tc%s -fuse-ld=lld -### 2>&1 | FileCheck 
--check-prefix=USE_LLD %s
-// USE_LLD: lld-link.exe
+// USE_LLD: lld-link


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


[PATCH] D33923: [Driver] Don't force .exe suffix for lld

2017-06-05 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304761: [Driver] Don't force .exe suffix for lld (authored 
by smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D33923?vs=101495&id=101502#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33923

Files:
  cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
  cfe/trunk/test/Driver/cl-link.c


Index: cfe/trunk/test/Driver/cl-link.c
===
--- cfe/trunk/test/Driver/cl-link.c
+++ cfe/trunk/test/Driver/cl-link.c
@@ -56,4 +56,4 @@
 // NONEXISTENT: nonexistent
 
 // RUN: %clang_cl /Tc%s -fuse-ld=lld -### 2>&1 | FileCheck 
--check-prefix=USE_LLD %s
-// USE_LLD: lld-link.exe
+// USE_LLD: lld-link
Index: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
@@ -529,9 +529,7 @@
   SkipSettingEnvironment:;
 #endif
   } else {
-linkPath = Linker;
-llvm::sys::path::replace_extension(linkPath, "exe");
-linkPath = TC.GetProgramPath(linkPath.c_str());
+linkPath = TC.GetProgramPath(Linker.str().c_str());
   }
 
   auto LinkCmd = llvm::make_unique(


Index: cfe/trunk/test/Driver/cl-link.c
===
--- cfe/trunk/test/Driver/cl-link.c
+++ cfe/trunk/test/Driver/cl-link.c
@@ -56,4 +56,4 @@
 // NONEXISTENT: nonexistent
 
 // RUN: %clang_cl /Tc%s -fuse-ld=lld -### 2>&1 | FileCheck --check-prefix=USE_LLD %s
-// USE_LLD: lld-link.exe
+// USE_LLD: lld-link
Index: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
@@ -529,9 +529,7 @@
   SkipSettingEnvironment:;
 #endif
   } else {
-linkPath = Linker;
-llvm::sys::path::replace_extension(linkPath, "exe");
-linkPath = TC.GetProgramPath(linkPath.c_str());
+linkPath = TC.GetProgramPath(Linker.str().c_str());
   }
 
   auto LinkCmd = llvm::make_unique(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17215: [Sema] Fix PR14211 Crash for explicit instantiation of overloaded template function within class template

2017-06-05 Thread don hinton via Phabricator via cfe-commits
hintonda updated this revision to Diff 101503.
hintonda added a comment.

- Addressed comments.


https://reviews.llvm.org/D17215

Files:
  lib/Sema/SemaTemplate.cpp
  test/CXX/temp/temp.decls/temp.mem/p5.cpp


Index: test/CXX/temp/temp.decls/temp.mem/p5.cpp
===
--- test/CXX/temp/temp.decls/temp.mem/p5.cpp
+++ test/CXX/temp/temp.decls/temp.mem/p5.cpp
@@ -77,3 +77,16 @@
   x0.operator float *();
   x0c.operator const char*();
 }
+
+namespace PR14211 {
+template  struct X {
+  void foo(U){}
+  template  void foo(T){}
+
+  template  void bar(T){}
+  void bar(U){}
+};
+
+template void X::foo(int);
+template void X::bar(int);
+}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -8955,7 +8955,8 @@
   //   A member function [...] of a class template can be explicitly
   //  instantiated from the member definition associated with its class
   //  template.
-  UnresolvedSet<8> Matches;
+  UnresolvedSet<8> TemplateMatches;
+  FunctionDecl *NonTemplateMatch = nullptr;
   AttributeList *Attr = D.getDeclSpec().getAttributes().getList();
   TemplateSpecCandidateSet FailedCandidates(D.getIdentifierLoc());
   for (LookupResult::iterator P = Previous.begin(), PEnd = Previous.end();
@@ -8966,11 +8967,13 @@
 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
 /*AdjustExceptionSpec*/true);
 if (Context.hasSameUnqualifiedType(Method->getType(), Adjusted)) {
-  Matches.clear();
-
-  Matches.addDecl(Method, P.getAccess());
-  if (Method->getTemplateSpecializationKind() == TSK_Undeclared)
-break;
+  if (Method->getPrimaryTemplate()) {
+TemplateMatches.addDecl(Method, P.getAccess());
+  } else {
+// FIXME: Can this assert ever happen?  Needs a test.
+assert(!NonTemplateMatch && "Multiple NonTemplateMatches");
+NonTemplateMatch = Method;
+  }
 }
   }
 }
@@ -9009,22 +9012,25 @@
   continue;
 }
 
-Matches.addDecl(Specialization, P.getAccess());
+TemplateMatches.addDecl(Specialization, P.getAccess());
   }
 
-  // Find the most specialized function template specialization.
-  UnresolvedSetIterator Result = getMostSpecialized(
-  Matches.begin(), Matches.end(), FailedCandidates,
-  D.getIdentifierLoc(),
-  PDiag(diag::err_explicit_instantiation_not_known) << Name,
-  PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
-  PDiag(diag::note_explicit_instantiation_candidate));
-
-  if (Result == Matches.end())
-return true;
+  FunctionDecl *Specialization = NonTemplateMatch;
+  if (!Specialization) {
+// Find the most specialized function template specialization.
+UnresolvedSetIterator Result = getMostSpecialized(
+TemplateMatches.begin(), TemplateMatches.end(), FailedCandidates,
+D.getIdentifierLoc(),
+PDiag(diag::err_explicit_instantiation_not_known) << Name,
+PDiag(diag::err_explicit_instantiation_ambiguous) << Name,
+PDiag(diag::note_explicit_instantiation_candidate));
+
+if (Result == TemplateMatches.end())
+  return true;
 
-  // Ignore access control bits, we don't need them for redeclaration checking.
-  FunctionDecl *Specialization = cast(*Result);
+// Ignore access control bits, we don't need them for redeclaration 
checking.
+Specialization = cast(*Result);
+  }
 
   // C++11 [except.spec]p4
   // In an explicit instantiation an exception-specification may be specified,


Index: test/CXX/temp/temp.decls/temp.mem/p5.cpp
===
--- test/CXX/temp/temp.decls/temp.mem/p5.cpp
+++ test/CXX/temp/temp.decls/temp.mem/p5.cpp
@@ -77,3 +77,16 @@
   x0.operator float *();
   x0c.operator const char*();
 }
+
+namespace PR14211 {
+template  struct X {
+  void foo(U){}
+  template  void foo(T){}
+
+  template  void bar(T){}
+  void bar(U){}
+};
+
+template void X::foo(int);
+template void X::bar(int);
+}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -8955,7 +8955,8 @@
   //   A member function [...] of a class template can be explicitly
   //  instantiated from the member definition associated with its class
   //  template.
-  UnresolvedSet<8> Matches;
+  UnresolvedSet<8> TemplateMatches;
+  FunctionDecl *NonTemplateMatch = nullptr;
   AttributeList *Attr = D.getDeclSpec().getAttributes().getList();
   TemplateSpecCandidateSet FailedCandidates(D.getIdentifierLoc());
   for (LookupResult::iterator P = Previous.begin(), PEnd = Previous.end();
@@ -8966,11 +8967,13 @@
 QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
 /*Adjust

[PATCH] D17215: [Sema] Fix PR14211 Crash for explicit instantiation of overloaded template function within class template

2017-06-05 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, looks great.  Do you still not have commit access?


https://reviews.llvm.org/D17215



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


[PATCH] D17215: [Sema] Fix PR14211 Crash for explicit instantiation of overloaded template function within class template

2017-06-05 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

Great, thanks John.

Yes, that's correct -- I do not have commit access.


https://reviews.llvm.org/D17215



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


[libcxx] r304765 - [libcxx] [test] Add _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to msvc_stdlib_force_include.hpp.

2017-06-05 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Mon Jun  5 21:46:12 2017
New Revision: 304765

URL: http://llvm.org/viewvc/llvm-project?rev=304765&view=rev
Log:
[libcxx] [test] Add _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to 
msvc_stdlib_force_include.hpp.

This macro will instruct MSVC's STL to not warn about features that are 
deprecated in C++17,
as libcxx tests those features and uses them elsewhere.

Modified:
libcxx/trunk/test/support/msvc_stdlib_force_include.hpp

Modified: libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/msvc_stdlib_force_include.hpp?rev=304765&r1=304764&r2=304765&view=diff
==
--- libcxx/trunk/test/support/msvc_stdlib_force_include.hpp (original)
+++ libcxx/trunk/test/support/msvc_stdlib_force_include.hpp Mon Jun  5 21:46:12 
2017
@@ -81,6 +81,9 @@ const AssertionDialogAvoider assertion_d
 
 // Silence warnings about raw pointers and other unchecked iterators.
 #define _SCL_SECURE_NO_WARNINGS
+
+// Silence warnings about features that are deprecated in C++17.
+#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
 #endif // _LIBCXX_IN_DEVCRT
 
 #include 


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


[PATCH] D33926: [clang] Remove double semicolons. NFC.

2017-06-05 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang created this revision.
mgrang added a project: clang-c.

https://reviews.llvm.org/D33926

Files:
  lib/AST/Type.cpp
  lib/Sema/SemaType.cpp


Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -3367,7 +3367,7 @@
 if (auto objcClass = type->getAs()) {
   if (objcClass->getInterface()->getIdentifier() == S.getNSErrorIdent()) {
 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2)
-  return PointerDeclaratorKind::NSErrorPointerPointer;;
+  return PointerDeclaratorKind::NSErrorPointerPointer;
   }
 
   break;
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -1344,7 +1344,7 @@
   } else if (getAs()) {
 ASTContext &ctx = dc->getParentASTContext();
 objectType = ctx.getObjCObjectType(ctx.ObjCBuiltinIdTy, { }, { })
-   ->castAs();;
+   ->castAs();
   } else {
 objectType = getAs();
   }


Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -3367,7 +3367,7 @@
 if (auto objcClass = type->getAs()) {
   if (objcClass->getInterface()->getIdentifier() == S.getNSErrorIdent()) {
 if (numNormalPointers == 2 && numTypeSpecifierPointers < 2)
-  return PointerDeclaratorKind::NSErrorPointerPointer;;
+  return PointerDeclaratorKind::NSErrorPointerPointer;
   }
 
   break;
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -1344,7 +1344,7 @@
   } else if (getAs()) {
 ASTContext &ctx = dc->getParentASTContext();
 objectType = ctx.getObjCObjectType(ctx.ObjCBuiltinIdTy, { }, { })
-   ->castAs();;
+   ->castAs();
   } else {
 objectType = getAs();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33820: [PowerPC] Pass CPU to assembler with -no-integrated-as

2017-06-05 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai updated this revision to Diff 101508.
nemanjai added a comment.

Remove the temporary string variable for the CPU.


Repository:
  rL LLVM

https://reviews.llvm.org/D33820

Files:
  lib/Driver/ToolChains/Arch/PPC.cpp
  lib/Driver/ToolChains/Arch/PPC.h
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/linux-as.c
  test/Driver/ppc-features.cpp

Index: test/Driver/ppc-features.cpp
===
--- test/Driver/ppc-features.cpp
+++ test/Driver/ppc-features.cpp
@@ -171,8 +171,8 @@
 
 // RUN: %clang -target powerpc64le-unknown-linux-gnu %s -### -o %t.o -no-integrated-as 2>&1 | FileCheck -check-prefix=CHECK_LE_AS_ARGS %s
 // CHECK_LE_AS_ARGS: "-mppc64"
-// CHECK_LE_AS_ARGS: "-many"
 // CHECK_LE_AS_ARGS: "-mlittle-endian"
+// CHECK_LE_AS_ARGS: "-mpower8"
 
 // linker features
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK_BE_LD_ARGS %s
Index: test/Driver/linux-as.c
===
--- test/Driver/linux-as.c
+++ test/Driver/linux-as.c
@@ -174,3 +174,18 @@
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-Z-ARCH-Z196 %s
 // CHECK-Z-ARCH-Z196: as{{.*}} "-march=z196"
+//
+// RUN: %clang -target powerpc64le-linux -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PPC64LE %s
+// CHECK-PPC64LE: as{{.*}} "-mpower8"
+//
+// RUN: %clang -target powerpc64-linux -mcpu=pwr7 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PPC64 %s
+// CHECK-PPC64: as{{.*}} "-mpower7"
+//
+// RUN: %clang -target powerpc-linux -mcpu=pwr9 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PPC32 %s
+// CHECK-PPC32: as{{.*}} "-mpower9"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -11,6 +11,7 @@
 #include "Linux.h"
 #include "Arch/ARM.h"
 #include "Arch/Mips.h"
+#include "Arch/PPC.h"
 #include "Arch/Sparc.h"
 #include "Arch/SystemZ.h"
 #include "CommonArgs.h"
@@ -674,22 +675,28 @@
 else
   CmdArgs.push_back("--64");
 break;
-  case llvm::Triple::ppc:
+  case llvm::Triple::ppc: {
 CmdArgs.push_back("-a32");
 CmdArgs.push_back("-mppc");
-CmdArgs.push_back("-many");
+CmdArgs.push_back(
+  ppc::getPPCAsmModeForCPU(getCPUName(Args, getToolChain().getTriple(;
 break;
-  case llvm::Triple::ppc64:
+  }
+  case llvm::Triple::ppc64: {
 CmdArgs.push_back("-a64");
 CmdArgs.push_back("-mppc64");
-CmdArgs.push_back("-many");
+CmdArgs.push_back(
+  ppc::getPPCAsmModeForCPU(getCPUName(Args, getToolChain().getTriple(;
 break;
-  case llvm::Triple::ppc64le:
+  }
+  case llvm::Triple::ppc64le: {
 CmdArgs.push_back("-a64");
 CmdArgs.push_back("-mppc64");
-CmdArgs.push_back("-many");
 CmdArgs.push_back("-mlittle-endian");
+CmdArgs.push_back(
+  ppc::getPPCAsmModeForCPU(getCPUName(Args, getToolChain().getTriple(;
 break;
+  }
   case llvm::Triple::sparc:
   case llvm::Triple::sparcel: {
 CmdArgs.push_back("-32");
Index: lib/Driver/ToolChains/Arch/PPC.h
===
--- lib/Driver/ToolChains/Arch/PPC.h
+++ lib/Driver/ToolChains/Arch/PPC.h
@@ -32,6 +32,7 @@
 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 
 std::string getPPCTargetCPU(const llvm::opt::ArgList &Args);
+const char *getPPCAsmModeForCPU(StringRef Name);
 
 void getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
Index: lib/Driver/ToolChains/Arch/PPC.cpp
===
--- lib/Driver/ToolChains/Arch/PPC.cpp
+++ lib/Driver/ToolChains/Arch/PPC.cpp
@@ -86,6 +86,18 @@
   return "";
 }
 
+const char *ppc::getPPCAsmModeForCPU(StringRef Name) {
+  return llvm::StringSwitch(Name)
+.Case("pwr7", "-mpower7")
+.Case("power7", "-mpower7")
+.Case("pwr8", "-mpower8")
+.Case("power8", "-mpower8")
+.Case("ppc64le", "-mpower8")
+.Case("pwr9", "-mpower9")
+.Case("power9", "-mpower9")
+.Default("-many");
+}
+
 void ppc::getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args,
std::vector &Features) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30393: Do not inherit default arguments for friend function in class template.

2017-06-05 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 101512.
sepavloff added a comment.

Rebased patch


https://reviews.llvm.org/D30393

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp


Index: test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
===
--- test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
+++ test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
@@ -73,3 +73,36 @@
 }
 
 } // namespace
+
+namespace pr12724 {
+
+void func_01(bool param = true);
+class C01 {
+public:
+  friend void func_01(bool param);
+};
+
+void func_02(bool param = true);
+template
+class C02 {
+public:
+  friend void func_02(bool param);
+};
+C02 c02;
+
+void func_03(bool param);
+template
+class C03 {
+public:
+  friend void func_03(bool param);
+};
+void func_03(bool param = true);
+C03 c03;
+
+void main() {
+  func_01();
+  func_02();
+  func_03();
+}
+
+} // namespace pr12724
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -547,17 +547,23 @@
   Diag(OldParam->getLocation(), diag::note_previous_definition)
 << OldParam->getDefaultArgRange();
 } else if (OldParamHasDfl) {
-  // Merge the old default argument into the new parameter.
-  // It's important to use getInit() here;  getDefaultArg()
-  // strips off any top-level ExprWithCleanups.
-  NewParam->setHasInheritedDefaultArg();
-  if (OldParam->hasUnparsedDefaultArg())
-NewParam->setUnparsedDefaultArg();
-  else if (OldParam->hasUninstantiatedDefaultArg())
-NewParam->setUninstantiatedDefaultArg(
-  OldParam->getUninstantiatedDefaultArg());
-  else
-NewParam->setDefaultArg(OldParam->getInit());
+  // Merge the old default argument into the new parameter unless the new
+  // function is a friend declaration in a template class. In the latter
+  // case the default arguments will be inherited when the friend
+  // declaration will be instantiated.
+  if (New->getFriendObjectKind() == Decl::FOK_None ||
+  !New->getLexicalDeclContext()->isDependentContext()) {
+// It's important to use getInit() here;  getDefaultArg()
+// strips off any top-level ExprWithCleanups.
+NewParam->setHasInheritedDefaultArg();
+if (OldParam->hasUnparsedDefaultArg())
+  NewParam->setUnparsedDefaultArg();
+else if (OldParam->hasUninstantiatedDefaultArg())
+  NewParam->setUninstantiatedDefaultArg(
+   
OldParam->getUninstantiatedDefaultArg());
+else
+  NewParam->setDefaultArg(OldParam->getInit());
+  }
 } else if (NewParamHasDfl) {
   if (New->getDescribedFunctionTemplate()) {
 // Paragraph 4, quoted above, only applies to non-template functions.


Index: test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
===
--- test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
+++ test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp
@@ -73,3 +73,36 @@
 }
 
 } // namespace
+
+namespace pr12724 {
+
+void func_01(bool param = true);
+class C01 {
+public:
+  friend void func_01(bool param);
+};
+
+void func_02(bool param = true);
+template
+class C02 {
+public:
+  friend void func_02(bool param);
+};
+C02 c02;
+
+void func_03(bool param);
+template
+class C03 {
+public:
+  friend void func_03(bool param);
+};
+void func_03(bool param = true);
+C03 c03;
+
+void main() {
+  func_01();
+  func_02();
+  func_03();
+}
+
+} // namespace pr12724
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -547,17 +547,23 @@
   Diag(OldParam->getLocation(), diag::note_previous_definition)
 << OldParam->getDefaultArgRange();
 } else if (OldParamHasDfl) {
-  // Merge the old default argument into the new parameter.
-  // It's important to use getInit() here;  getDefaultArg()
-  // strips off any top-level ExprWithCleanups.
-  NewParam->setHasInheritedDefaultArg();
-  if (OldParam->hasUnparsedDefaultArg())
-NewParam->setUnparsedDefaultArg();
-  else if (OldParam->hasUninstantiatedDefaultArg())
-NewParam->setUninstantiatedDefaultArg(
-  OldParam->getUninstantiatedDefaultArg());
-  else
-NewParam->setDefaultArg(OldParam->getInit());
+  // Merge the old default argument into the new parameter unless the new
+  // function is a friend declaration in a template class. In the latter
+  // case the default arguments will be inherited when the friend
+  // declaration will be instantiated.
+  if (New->getFriendObjectKind() == Decl::FOK_None ||
+  !New->getLexicalDeclContext()->isDepe