Re: [PATCH] D13014: [X86] Add XSAVE intrinsics (Clang part)

2015-10-12 Thread Elena Demikhovsky via cfe-commits
delena added a comment.

Do you need to add some tests for clang?


Repository:
  rL LLVM

http://reviews.llvm.org/D13014



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


Re: [PATCH] D13546: [ATTR] Automatic line feed after pragma-like attribute.

2015-10-12 Thread Alexey Bataev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250017: [ATTR] Automatic line feed after pragma-like 
attribute. (authored by ABataev).

Changed prior to commit:
  http://reviews.llvm.org/D13546?vs=36924=37080#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13546

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/lib/AST/DeclPrinter.cpp
  cfe/trunk/test/Misc/ast-print-pragmas.cpp
  cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -2048,17 +2048,15 @@
 unsigned SpellingIndex = getSpellingListIndex();
 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
 // "nounroll" is already emitted as the pragma name.
-if (SpellingIndex == Pragma_nounroll) {
-  OS << "\n";
+if (SpellingIndex == Pragma_nounroll)
   return;
-}
 else if (SpellingIndex == Pragma_unroll) {
-  OS << getValueString(Policy) << "\n";
+  OS << getValueString(Policy);
   return;
 }
 
 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
-OS << getOptionName(option) << getValueString(Policy) << "\n";
+OS << getOptionName(option) << getValueString(Policy);
   }
 
   // Return a string containing the loop hint argument including the
Index: cfe/trunk/test/Misc/ast-print-pragmas.cpp
===
--- cfe/trunk/test/Misc/ast-print-pragmas.cpp
+++ cfe/trunk/test/Misc/ast-print-pragmas.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -ast-print %s -o - | FileCheck %s
+// RUN: %clang_cc1 -DMS_EXT -fsyntax-only -fms-extensions %s -triple x86_64-pc-win32 -ast-print | FileCheck %s --check-prefix=MS-EXT
 
 // FIXME: A bug in ParsedAttributes causes the order of the attributes to be
 // reversed. The checks are consequently in the reverse order below.
@@ -53,3 +54,11 @@
 void test_templates(int *List, int Length) {
   test_nontype_template_param<2, 4>(List, Length);
 }
+
+#ifdef MS_EXT
+#pragma init_seg(compiler)
+// MS-EXT: #pragma init_seg (.CRT$XCC)
+// MS-EXT-NEXT: int x = 3 __declspec(thread);
+int __declspec(thread) x = 3;
+#endif //MS_EXT
+
Index: cfe/trunk/lib/AST/DeclPrinter.cpp
===
--- cfe/trunk/lib/AST/DeclPrinter.cpp
+++ cfe/trunk/lib/AST/DeclPrinter.cpp
@@ -96,6 +96,7 @@
 void PrintTemplateParameters(const TemplateParameterList *Params,
  const TemplateArgumentList *Args = nullptr);
 void prettyPrintAttributes(Decl *D);
+void prettyPrintPragmas(Decl *D);
 void printDeclType(QualType T, StringRef DeclName, bool Pack = false);
   };
 }
@@ -197,12 +198,40 @@
 void DeclPrinter::prettyPrintAttributes(Decl *D) {
   if (Policy.PolishForDeclaration)
 return;
-  
+
   if (D->hasAttrs()) {
 AttrVec  = D->getAttrs();
-for (AttrVec::const_iterator i=Attrs.begin(), e=Attrs.end(); i!=e; ++i) {
-  Attr *A = *i;
-  A->printPretty(Out, Policy);
+for (auto *A : Attrs) {
+  switch (A->getKind()) {
+#define ATTR(X)
+#define PRAGMA_SPELLING_ATTR(X) case attr::X:
+#include "clang/Basic/AttrList.inc"
+break;
+  default:
+A->printPretty(Out, Policy);
+break;
+  }
+}
+  }
+}
+
+void DeclPrinter::prettyPrintPragmas(Decl *D) {
+  if (Policy.PolishForDeclaration)
+return;
+
+  if (D->hasAttrs()) {
+AttrVec  = D->getAttrs();
+for (auto *A : Attrs) {
+  switch (A->getKind()) {
+#define ATTR(X)
+#define PRAGMA_SPELLING_ATTR(X) case attr::X:
+#include "clang/Basic/AttrList.inc"
+A->printPretty(Out, Policy);
+Indent();
+break;
+  default:
+break;
+  }
 }
   }
 }
@@ -408,6 +437,10 @@
 }
 
 void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
+  if (!D->getDescribedFunctionTemplate() &&
+  !D->isFunctionTemplateSpecialization())
+prettyPrintPragmas(D);
+
   CXXConstructorDecl *CDecl = dyn_cast(D);
   CXXConversionDecl *ConversionDecl = dyn_cast(D);
   if (!Policy.SuppressSpecifiers) {
@@ -643,6 +676,7 @@
 }
 
 void DeclPrinter::VisitFieldDecl(FieldDecl *D) {
+  // FIXME: add printing of pragma attributes if required.
   if (!Policy.SuppressSpecifiers && D->isMutable())
 Out << "mutable ";
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
@@ -672,6 +706,7 @@
 }
 
 void DeclPrinter::VisitVarDecl(VarDecl *D) {
+  prettyPrintPragmas(D);
   if (!Policy.SuppressSpecifiers) {
 StorageClass SC = D->getStorageClass();
 if (SC != SC_None)
@@ -779,6 +814,7 @@
 }
 
 void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
+  // FIXME: add printing of pragma attributes if required.
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
 Out << "__module_private__ ";
   Out << D->getKindName();
@@ -914,11 +950,13 @@
   if 

r250017 - [ATTR] Automatic line feed after pragma-like attribute.

2015-10-12 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Oct 12 01:59:48 2015
New Revision: 250017

URL: http://llvm.org/viewvc/llvm-project?rev=250017=rev
Log:
[ATTR] Automatic line feed after pragma-like attribute.
Automatically insert line feed after pretty printing of all pragma-like 
attributes + fix printing of pragma-like pragmas on declarations.
Differential Revision: http://reviews.llvm.org/D13546

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Misc/ast-print-pragmas.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=250017=250016=250017=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Oct 12 01:59:48 2015
@@ -2048,17 +2048,15 @@ def LoopHint : Attr {
 unsigned SpellingIndex = getSpellingListIndex();
 // For "#pragma unroll" and "#pragma nounroll" the string "unroll" or
 // "nounroll" is already emitted as the pragma name.
-if (SpellingIndex == Pragma_nounroll) {
-  OS << "\n";
+if (SpellingIndex == Pragma_nounroll)
   return;
-}
 else if (SpellingIndex == Pragma_unroll) {
-  OS << getValueString(Policy) << "\n";
+  OS << getValueString(Policy);
   return;
 }
 
 assert(SpellingIndex == Pragma_clang_loop && "Unexpected spelling");
-OS << getOptionName(option) << getValueString(Policy) << "\n";
+OS << getOptionName(option) << getValueString(Policy);
   }
 
   // Return a string containing the loop hint argument including the

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=250017=250016=250017=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Mon Oct 12 01:59:48 2015
@@ -96,6 +96,7 @@ namespace {
 void PrintTemplateParameters(const TemplateParameterList *Params,
  const TemplateArgumentList *Args = nullptr);
 void prettyPrintAttributes(Decl *D);
+void prettyPrintPragmas(Decl *D);
 void printDeclType(QualType T, StringRef DeclName, bool Pack = false);
   };
 }
@@ -197,12 +198,40 @@ raw_ostream& DeclPrinter::Indent(unsigne
 void DeclPrinter::prettyPrintAttributes(Decl *D) {
   if (Policy.PolishForDeclaration)
 return;
-  
+
   if (D->hasAttrs()) {
 AttrVec  = D->getAttrs();
-for (AttrVec::const_iterator i=Attrs.begin(), e=Attrs.end(); i!=e; ++i) {
-  Attr *A = *i;
-  A->printPretty(Out, Policy);
+for (auto *A : Attrs) {
+  switch (A->getKind()) {
+#define ATTR(X)
+#define PRAGMA_SPELLING_ATTR(X) case attr::X:
+#include "clang/Basic/AttrList.inc"
+break;
+  default:
+A->printPretty(Out, Policy);
+break;
+  }
+}
+  }
+}
+
+void DeclPrinter::prettyPrintPragmas(Decl *D) {
+  if (Policy.PolishForDeclaration)
+return;
+
+  if (D->hasAttrs()) {
+AttrVec  = D->getAttrs();
+for (auto *A : Attrs) {
+  switch (A->getKind()) {
+#define ATTR(X)
+#define PRAGMA_SPELLING_ATTR(X) case attr::X:
+#include "clang/Basic/AttrList.inc"
+A->printPretty(Out, Policy);
+Indent();
+break;
+  default:
+break;
+  }
 }
   }
 }
@@ -408,6 +437,10 @@ void DeclPrinter::VisitEnumConstantDecl(
 }
 
 void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
+  if (!D->getDescribedFunctionTemplate() &&
+  !D->isFunctionTemplateSpecialization())
+prettyPrintPragmas(D);
+
   CXXConstructorDecl *CDecl = dyn_cast(D);
   CXXConversionDecl *ConversionDecl = dyn_cast(D);
   if (!Policy.SuppressSpecifiers) {
@@ -643,6 +676,7 @@ void DeclPrinter::VisitFriendDecl(Friend
 }
 
 void DeclPrinter::VisitFieldDecl(FieldDecl *D) {
+  // FIXME: add printing of pragma attributes if required.
   if (!Policy.SuppressSpecifiers && D->isMutable())
 Out << "mutable ";
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
@@ -672,6 +706,7 @@ void DeclPrinter::VisitLabelDecl(LabelDe
 }
 
 void DeclPrinter::VisitVarDecl(VarDecl *D) {
+  prettyPrintPragmas(D);
   if (!Policy.SuppressSpecifiers) {
 StorageClass SC = D->getStorageClass();
 if (SC != SC_None)
@@ -779,6 +814,7 @@ void DeclPrinter::VisitEmptyDecl(EmptyDe
 }
 
 void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
+  // FIXME: add printing of pragma attributes if required.
   if (!Policy.SuppressSpecifiers && D->isModulePrivate())
 Out << "__module_private__ ";
   Out << D->getKindName();
@@ -914,11 +950,13 @@ void DeclPrinter::VisitFunctionTemplateD
   if (PrintInstantiation) {
 TemplateParameterList *Params = D->getTemplateParameters();
 for (auto *I : D->specializations()) {
+  prettyPrintPragmas(I);
   PrintTemplateParameters(Params, 

[PATCH] D13643: [Sema] Warn on ternary comparison

2015-10-12 Thread Matěj Grabovský via cfe-commits
mgrabovsky created this revision.
mgrabovsky added a subscriber: cfe-commits.

This change adds a Sema diagnostic for comparisons like `a < b < c`,
which usually do not behave as intended by the author.

Fixes bug 20082.

http://reviews.llvm.org/D13643

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/bool-compare.c

Index: test/Sema/bool-compare.c
===
--- test/Sema/bool-compare.c
+++ test/Sema/bool-compare.c
@@ -85,7 +85,9 @@
   if ((ayy z)  {} // no warning
   if((a(z (a(a (a(agetLHS()->getSourceRange() << E->getRHS()->getSourceRange());
 }
 
+/// Diagnose attempts at ternary comparison, e.g., 1 < x < 2
+static void DiagnoseTernaryComparison(Sema , BinaryOperator *E) {
+  BinaryOperator *LHS = dyn_cast(E->getLHS());
+  if (!LHS || !LHS->isComparisonOp())
+return;
+
+  SourceLocation Loc = E->getSourceRange().getBegin();
+
+  S.DiagRuntimeBehavior(Loc, E,
+S.PDiag(diag::warn_ternary_comparison) << E->getSourceRange());
+  S.DiagRuntimeBehavior(Loc, E,
+S.PDiag(diag::note_ternary_comparison_to_conjunction));
+  S.DiagRuntimeBehavior(Loc, E,
+S.PDiag(diag::note_ternary_comparison_silence));
+}
+
 /// Analyze the operands of the given comparison.  Implements the
 /// fallback case from AnalyzeComparison.
 static void AnalyzeImpConvsInComparison(Sema , BinaryOperator *E) {
@@ -6720,7 +6736,9 @@
   Expr *RHS = E->getRHS()->IgnoreParenImpCasts();
   
   bool IsComparisonConstant = false;
-  
+
+  DiagnoseTernaryComparison(S, E);
+
   // Check whether an integer constant comparison results in a value
   // of 'true' or 'false'.
   if (T->isIntegralType(S.Context)) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5862,6 +5862,14 @@
 def note_condition_assign_silence : Note<
   "place parentheses around the assignment to silence this warning">;
 
+def warn_ternary_comparison : Warning<"ternary comparisons do not work "
+  "as expected">,
+  InGroup;
+def note_ternary_comparison_to_conjunction : Note<"to achieve the expected 
behavior, "
+  "turn this expression into a conjunction of two comparisons">;
+def note_ternary_comparison_silence : Note<"place parentheses around either "
+  "of the comparisons to silence this warning">;
+
 def warn_equality_with_extra_parens : Warning<"equality comparison with "
   "extraneous parentheses">, InGroup;
 def note_equality_comparison_to_assign : Note<


Index: test/Sema/bool-compare.c
===
--- test/Sema/bool-compare.c
+++ test/Sema/bool-compare.c
@@ -85,7 +85,9 @@
   if ((ayy

Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-10-12 Thread Nicholas Allegra via cfe-commits
comex added a comment.

Ping again.


http://reviews.llvm.org/D12686



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


Re: [PATCH] D13582: [DEBUG INFO] Emit debug info for type used in explicit cast only.

2015-10-12 Thread Bataev, Alexey via cfe-commits
Yes, revision 246985 
 
broke th debug info for types in explicit casts.


Best regards,
Alexey Bataev
=
Software Engineer
Intel Compiler Team

09.10.2015 18:26, David Blaikie пишет:



On Fri, Oct 9, 2015 at 2:26 AM, Alexey Bataev via cfe-commits 
> wrote:


ABataev created this revision.
ABataev added a reviewer: echristo.
ABataev added a subscriber: cfe-commits.

Currently debug info for types used in explicit cast only is not
emitted. It happened after a patch for better alignment handling.


You mean a patch related to alignment regressed this functionality? Do 
you have the specific revision number of that change (since it sounds 
like you tracked it down)?


This patch fixes this bug.

http://reviews.llvm.org/D13582

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenCXX/debug-info-explicit-cast.cpp

Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -799,6 +799,10 @@
 if (E->getType()->isVariablyModifiedType())
   EmitVariablyModifiedType(E->getType());

+if (isa(CE))
+  if (CGDebugInfo *DI = getDebugInfo())
+DI->EmitExplicitCastType(E->getType());
+
 switch (CE->getCastKind()) {
 // Non-converting casts (but not C's implicit conversion from
void*).
 case CK_BitCast:
Index: test/CodeGenCXX/debug-info-explicit-cast.cpp
===
--- test/CodeGenCXX/debug-info-explicit-cast.cpp
+++ test/CodeGenCXX/debug-info-explicit-cast.cpp
@@ -0,0 +1,18 @@
+// RUN: %clangxx -c -target x86_64-unknown-unknown -g %s
-emit-llvm -S -o - | FileCheck %s
+struct Foo {
+  int a;
+  Foo() : a(1){};
+};
+
+struct Bar {
+  int b;
+  Bar() : b(2){};
+};
+
+int main() {
+  Bar *pb = new Bar;
+
+  return reinterpret_cast(pb)->a;
+}
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Foo",



___
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] D13639: Add decayedType and hasDecayedType AST matchers

2015-10-12 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D13639



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


Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Marek Kurdej via cfe-commits
curdeius updated this revision to Diff 37081.
curdeius added a comment.

Fix description formatting.


http://reviews.llvm.org/D13549

Files:
  lib/Driver/Tools.cpp
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
  tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
  tools/clang-format/ClangFormat.cpp

Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -201,15 +201,30 @@
 static void outputReplacementXML(StringRef Text) {
   size_t From = 0;
   size_t Index;
-  while ((Index = Text.find_first_of("\n\r", From)) != StringRef::npos) {
+  while ((Index = Text.find_first_of("\n\r<>&\"'", From)) != StringRef::npos) {
 llvm::outs() << Text.substr(From, Index - From);
 switch (Text[Index]) {
 case '\n':
   llvm::outs() << "";
   break;
 case '\r':
   llvm::outs() << "";
   break;
+case '<':
+  llvm::outs() << "";
+  break;
+case '>':
+  llvm::outs() << "";
+  break;
+case '&':
+  llvm::outs() << "";
+  break;
+case '\'':
+  llvm::outs() << "";
+  break;
+case '"':
+  llvm::outs() << "";
+  break;
 default:
   llvm_unreachable("Unexpected character encountered!");
 }
Index: tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
===
--- tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
+++ tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@
 // You can specify all the values or you can default the Revision and Build Numbers 
 // by using the '*' as shown below:
 
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]
Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -32,13 +32,16 @@
 [CLSCompliant(false), ComVisible(true)]
 public class OptionPageGrid : DialogPage
 {
-private string style = "File";
+private string assumeFilename = "";
+private string fallbackStyle = "LLVM";
+private bool sortIncludes = false;
+private string style = "file";
 
 [Category("LLVM/Clang")]
 [DisplayName("Style")]
 [Description("Coding style, currently supports:\n" +
- "  - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla').\n" +
- "  - 'File' to search for a YAML .clang-format or _clang-format\n" +
+ "  - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla', 'WebKit').\n" +
+ "  - 'file' to search for a YAML .clang-format or _clang-format\n" +
  "configuration file.\n" +
  "  - A YAML configuration snippet.\n\n" +
  "'File':\n" +
@@ -53,6 +56,38 @@
 get { return style; }
 set { style = value; }
 }
+
+[Category("LLVM/Clang")]
+[DisplayName("Assume Filename")]
+[Description("When reading from stdin, clang-format assumes this " +
+ "filename to look for a style config file (with 'file' style) " +
+ "and to determine the language.")]
+public string AssumeFilename
+{
+get { return assumeFilename; }
+set { assumeFilename = value; }
+}
+
+[Category("LLVM/Clang")]
+[DisplayName("Fallback Style")]
+[Description("The name of the predefined style used as a fallback in case clang-format " +
+ "is invoked with 'file' style, but can not find the configuration file.\n" +
+ "Use 'none' fallback style to skip formatting.")]
+public string FallbackStyle
+{
+get { return fallbackStyle; }
+set { fallbackStyle = value; }
+}
+
+[Category("LLVM/Clang")]
+[DisplayName("Sort includes")]
+[Description("Sort touched include lines.\n\n" +
+ "See also: http://clang.llvm.org/docs/ClangFormat.html.;)]
+public bool SortIncludes
+{
+get { return sortIncludes; }
+set { sortIncludes = value; }
+}
 }
 
 [PackageRegistration(UseManagedResourcesOnly = true)]
@@ -138,10 +173,17 @@
 // Poor man's escaping - this will not work when quotes are already escaped
 // in the input (but we don't need more).
 string style = GetStyle().Replace("\"", "\\\"");
+string fallbackStyle = GetFallbackStyle().Replace("\"", "\\\"");
 process.StartInfo.Arguments = " -offset " + 

Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Marek Kurdej via cfe-commits
curdeius added inline comments.


Comment at: lib/Driver/Tools.cpp:2356
@@ -2355,3 +2355,3 @@
 CmdArgs.push_back(
-Args.MakeArgString("-dwarf-version=" + llvm::itostr(DwarfVersion)));
+Args.MakeArgString("-dwarf-version=" + Twine(DwarfVersion)));
 }

klimek wrote:
> Seems unrelated?
Oups, I've made a mistake when updating the revision and pulled in the changes 
from master.
I'll correct this.


Comment at: tools/clang-format/ClangFormat.cpp:227
@@ -213,1 +226,3 @@
+  llvm::outs() << "";
+  break;
 default:

klimek wrote:
> For XML, we should only need "<" and "&". Everything else is just important 
> in a context introduced by "<" or "&".
> The problem with include-sorting is that we'll now need to fully support utf8 
> input (well, any encoding, to be precise).
> The best way is probably to escape all code points that are outside the ascii 
> range. The problem I see is that we have no idea what encoding the file is 
> in, so I have no clue how we can really resolve this.
> 
Ok. I'll cut it  down to the necessary minimum ('<', '&').
Anyway, I thing it's more urgent to fix the include sorting containing open 
brackets and later work on UTF-8 support.


http://reviews.llvm.org/D13549



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


Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Marek Kurdej via cfe-commits
curdeius updated this revision to Diff 37086.
curdeius added a comment.

Escape only '<' and '&'.
Remove unrelated changes from the revision.


http://reviews.llvm.org/D13549

Files:
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
  tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
  tools/clang-format/ClangFormat.cpp

Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -201,15 +201,21 @@
 static void outputReplacementXML(StringRef Text) {
   size_t From = 0;
   size_t Index;
-  while ((Index = Text.find_first_of("\n\r", From)) != StringRef::npos) {
+  while ((Index = Text.find_first_of("\n\r<&", From)) != StringRef::npos) {
 llvm::outs() << Text.substr(From, Index - From);
 switch (Text[Index]) {
 case '\n':
   llvm::outs() << "";
   break;
 case '\r':
   llvm::outs() << "";
   break;
+case '<':
+  llvm::outs() << "";
+  break;
+case '&':
+  llvm::outs() << "";
+  break;
 default:
   llvm_unreachable("Unexpected character encountered!");
 }
Index: tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
===
--- tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
+++ tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@
 // You can specify all the values or you can default the Revision and Build Numbers 
 // by using the '*' as shown below:
 
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]
Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -32,13 +32,16 @@
 [CLSCompliant(false), ComVisible(true)]
 public class OptionPageGrid : DialogPage
 {
-private string style = "File";
+private string assumeFilename = "";
+private string fallbackStyle = "LLVM";
+private bool sortIncludes = false;
+private string style = "file";
 
 [Category("LLVM/Clang")]
 [DisplayName("Style")]
 [Description("Coding style, currently supports:\n" +
- "  - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla').\n" +
- "  - 'File' to search for a YAML .clang-format or _clang-format\n" +
+ "  - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla', 'WebKit').\n" +
+ "  - 'file' to search for a YAML .clang-format or _clang-format\n" +
  "configuration file.\n" +
  "  - A YAML configuration snippet.\n\n" +
  "'File':\n" +
@@ -53,6 +56,38 @@
 get { return style; }
 set { style = value; }
 }
+
+[Category("LLVM/Clang")]
+[DisplayName("Assume Filename")]
+[Description("When reading from stdin, clang-format assumes this " +
+ "filename to look for a style config file (with 'file' style) " +
+ "and to determine the language.")]
+public string AssumeFilename
+{
+get { return assumeFilename; }
+set { assumeFilename = value; }
+}
+
+[Category("LLVM/Clang")]
+[DisplayName("Fallback Style")]
+[Description("The name of the predefined style used as a fallback in case clang-format " +
+ "is invoked with 'file' style, but can not find the configuration file.\n" +
+ "Use 'none' fallback style to skip formatting.")]
+public string FallbackStyle
+{
+get { return fallbackStyle; }
+set { fallbackStyle = value; }
+}
+
+[Category("LLVM/Clang")]
+[DisplayName("Sort includes")]
+[Description("Sort touched include lines.\n\n" +
+ "See also: http://clang.llvm.org/docs/ClangFormat.html.;)]
+public bool SortIncludes
+{
+get { return sortIncludes; }
+set { sortIncludes = value; }
+}
 }
 
 [PackageRegistration(UseManagedResourcesOnly = true)]
@@ -138,10 +173,17 @@
 // Poor man's escaping - this will not work when quotes are already escaped
 // in the input (but we don't need more).
 string style = GetStyle().Replace("\"", "\\\"");
+string fallbackStyle = GetFallbackStyle().Replace("\"", "\\\"");
 process.StartInfo.Arguments = " -offset " + offset +
   " -length " + length +
   " -output-replacements-xml " +
-  

Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:186
@@ -145,1 +185,3 @@
+if (!string.IsNullOrEmpty(assumeFilename))
+  process.StartInfo.Arguments += " -assume-filename \"" + 
assumeFilename + "\"";
 process.StartInfo.CreateNoWindow = true;

curdeius wrote:
> klimek wrote:
> > curdeius wrote:
> > > klimek wrote:
> > > > Don't we need " escaping for assumeFilename? (or do we consider that an 
> > > > error? in which case, would we want to make that an error?)
> > > Well, quotes (") are not allowed as a part of a file name on Windows.
> > > What we could do is to strip surrounding quotes if the user added them in 
> > > order not to add them twice.
> > Oh, I didn't know that.
> > My main concern is what happens when the user (accidentally) adds quotes 
> > (for example, unbalanced) and messes up the command line in a way that 
> > leads to a super hard to diagnose problem
> Hmm, you're right, we should do something with that.
> Either:
> 
>   - escape all quotes (but then the errors will be silent and user will not 
> know that something bad happens)
>   - or to give an error message somehow, e.g. by using a custom TypeConverter 
> for AssumeFilename option that will check for the existence of quotes.
I'd vote for the latter, if possible.


http://reviews.llvm.org/D13549



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


Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: lib/Driver/Tools.cpp:2356
@@ -2355,3 +2355,3 @@
 CmdArgs.push_back(
-Args.MakeArgString("-dwarf-version=" + llvm::itostr(DwarfVersion)));
+Args.MakeArgString("-dwarf-version=" + Twine(DwarfVersion)));
 }

Seems unrelated?


Comment at: tools/clang-format/ClangFormat.cpp:227
@@ -213,1 +226,3 @@
+  llvm::outs() << "";
+  break;
 default:

For XML, we should only need "<" and "&". Everything else is just important in 
a context introduced by "<" or "&".
The problem with include-sorting is that we'll now need to fully support utf8 
input (well, any encoding, to be precise).
The best way is probably to escape all code points that are outside the ascii 
range. The problem I see is that we have no idea what encoding the file is in, 
so I have no clue how we can really resolve this.



http://reviews.llvm.org/D13549



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


Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:186
@@ -145,1 +185,3 @@
+if (!string.IsNullOrEmpty(assumeFilename))
+  process.StartInfo.Arguments += " -assume-filename \"" + 
assumeFilename + "\"";
 process.StartInfo.CreateNoWindow = true;

Don't we need " escaping for assumeFilename? (or do we consider that an error? 
in which case, would we want to make that an error?)


http://reviews.llvm.org/D13549



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


Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Marek Kurdej via cfe-commits
curdeius updated this revision to Diff 37087.
curdeius marked 2 inline comments as done.
curdeius added a comment.

Add FIXME comment.


http://reviews.llvm.org/D13549

Files:
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
  tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
  tools/clang-format/ClangFormat.cpp

Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -199,17 +199,25 @@
 }
 
 static void outputReplacementXML(StringRef Text) {
+  // FIXME: When we sort includes, we need to make sure the stream is correct
+  // utf-8.
   size_t From = 0;
   size_t Index;
-  while ((Index = Text.find_first_of("\n\r", From)) != StringRef::npos) {
+  while ((Index = Text.find_first_of("\n\r<&", From)) != StringRef::npos) {
 llvm::outs() << Text.substr(From, Index - From);
 switch (Text[Index]) {
 case '\n':
   llvm::outs() << "";
   break;
 case '\r':
   llvm::outs() << "";
   break;
+case '<':
+  llvm::outs() << "";
+  break;
+case '&':
+  llvm::outs() << "";
+  break;
 default:
   llvm_unreachable("Unexpected character encountered!");
 }
Index: tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
===
--- tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
+++ tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@
 // You can specify all the values or you can default the Revision and Build Numbers 
 // by using the '*' as shown below:
 
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]
Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -32,13 +32,16 @@
 [CLSCompliant(false), ComVisible(true)]
 public class OptionPageGrid : DialogPage
 {
-private string style = "File";
+private string assumeFilename = "";
+private string fallbackStyle = "LLVM";
+private bool sortIncludes = false;
+private string style = "file";
 
 [Category("LLVM/Clang")]
 [DisplayName("Style")]
 [Description("Coding style, currently supports:\n" +
- "  - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla').\n" +
- "  - 'File' to search for a YAML .clang-format or _clang-format\n" +
+ "  - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla', 'WebKit').\n" +
+ "  - 'file' to search for a YAML .clang-format or _clang-format\n" +
  "configuration file.\n" +
  "  - A YAML configuration snippet.\n\n" +
  "'File':\n" +
@@ -53,6 +56,38 @@
 get { return style; }
 set { style = value; }
 }
+
+[Category("LLVM/Clang")]
+[DisplayName("Assume Filename")]
+[Description("When reading from stdin, clang-format assumes this " +
+ "filename to look for a style config file (with 'file' style) " +
+ "and to determine the language.")]
+public string AssumeFilename
+{
+get { return assumeFilename; }
+set { assumeFilename = value; }
+}
+
+[Category("LLVM/Clang")]
+[DisplayName("Fallback Style")]
+[Description("The name of the predefined style used as a fallback in case clang-format " +
+ "is invoked with 'file' style, but can not find the configuration file.\n" +
+ "Use 'none' fallback style to skip formatting.")]
+public string FallbackStyle
+{
+get { return fallbackStyle; }
+set { fallbackStyle = value; }
+}
+
+[Category("LLVM/Clang")]
+[DisplayName("Sort includes")]
+[Description("Sort touched include lines.\n\n" +
+ "See also: http://clang.llvm.org/docs/ClangFormat.html.;)]
+public bool SortIncludes
+{
+get { return sortIncludes; }
+set { sortIncludes = value; }
+}
 }
 
 [PackageRegistration(UseManagedResourcesOnly = true)]
@@ -138,10 +173,17 @@
 // Poor man's escaping - this will not work when quotes are already escaped
 // in the input (but we don't need more).
 string style = GetStyle().Replace("\"", "\\\"");
+string fallbackStyle = GetFallbackStyle().Replace("\"", "\\\"");
 process.StartInfo.Arguments = " -offset " + offset +
   " -length " + 

Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Marek Kurdej via cfe-commits
curdeius added inline comments.


Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:186
@@ -145,1 +185,3 @@
+if (!string.IsNullOrEmpty(assumeFilename))
+  process.StartInfo.Arguments += " -assume-filename \"" + 
assumeFilename + "\"";
 process.StartInfo.CreateNoWindow = true;

klimek wrote:
> Don't we need " escaping for assumeFilename? (or do we consider that an 
> error? in which case, would we want to make that an error?)
Well, quotes (") are not allowed as a part of a file name on Windows.
What we could do is to strip surrounding quotes if the user added them in order 
not to add them twice.


http://reviews.llvm.org/D13549



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


Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: tools/clang-format/ClangFormat.cpp:227
@@ -213,1 +226,3 @@
+  llvm::outs() << "";
+  break;
 default:

curdeius wrote:
> klimek wrote:
> > For XML, we should only need "<" and "&". Everything else is just important 
> > in a context introduced by "<" or "&".
> > The problem with include-sorting is that we'll now need to fully support 
> > utf8 input (well, any encoding, to be precise).
> > The best way is probably to escape all code points that are outside the 
> > ascii range. The problem I see is that we have no idea what encoding the 
> > file is in, so I have no clue how we can really resolve this.
> > 
> Ok. I'll cut it  down to the necessary minimum ('<', '&').
> Anyway, I thing it's more urgent to fix the include sorting containing open 
> brackets and later work on UTF-8 support.
Agreed. Can you please add a FIXME though:
// FIXME: When we sort includes, we need to make sure the stream is correct
// utf-8.


http://reviews.llvm.org/D13549



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


Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Marek Kurdej via cfe-commits
curdeius marked 3 inline comments as done.
curdeius added a comment.

Applied suggestions from comments.


http://reviews.llvm.org/D13549



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


Re: [PATCH] D13099: [Analyzer] Don’t invalidate CXXThis when conservatively evaluating const methods (PR 21606)

2015-10-12 Thread Sean Eveson via cfe-commits
seaneveson updated this revision to Diff 37084.
seaneveson added a comment.

Updated to latest trunk
Replaced some code with an existing method: ignoreParenBaseCasts()

Could someone commit this for me as I don't have SVN access?
Thank you.


http://reviews.llvm.org/D13099

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/const-method-call.cpp

Index: test/Analysis/const-method-call.cpp
===
--- test/Analysis/const-method-call.cpp
+++ test/Analysis/const-method-call.cpp
@@ -0,0 +1,230 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(bool);
+
+struct A {
+  int x;
+  void foo() const;
+  void bar();
+};
+
+struct B {
+  mutable int mut;
+  void foo() const;
+};
+
+struct C {
+  int *p;
+  void foo() const;
+};
+
+struct MutBase {
+  mutable int b_mut;
+};
+
+struct MutDerived : MutBase {
+  void foo() const;
+};
+
+struct PBase {
+  int *p;
+};
+
+struct PDerived : PBase {
+  void foo() const;
+};
+
+struct Inner {
+  int x;
+  int *p;
+  void bar() const;
+};
+
+struct Outer {
+  int x;
+  Inner in;
+  void foo() const;
+};
+
+void checkThatConstMethodWithoutDefinitionDoesNotInvalidateObject() {
+  A t;
+  t.x = 3;
+  t.foo();
+  clang_analyzer_eval(t.x == 3); // expected-warning{{TRUE}}
+  // Test non-const does invalidate
+  t.bar();
+  clang_analyzer_eval(t.x); // expected-warning{{UNKNOWN}}
+}
+
+void checkThatConstMethodDoesInvalidateMutableFields() {
+  B t;
+  t.mut = 4;
+  t.foo();
+  clang_analyzer_eval(t.mut); // expected-warning{{UNKNOWN}}
+}
+
+void checkThatConstMethodDoesInvalidatePointedAtMemory() {
+  int x = 1;
+  C t;
+  t.p = 
+  t.foo();
+  clang_analyzer_eval(x); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(t.p == ); // expected-warning{{TRUE}}
+}
+
+void checkThatConstMethodDoesInvalidateInheritedMutableFields() {
+  MutDerived t;
+  t.b_mut = 4;
+  t.foo();
+  clang_analyzer_eval(t.b_mut); // expected-warning{{UNKNOWN}}
+}
+
+void checkThatConstMethodDoesInvalidateInheritedPointedAtMemory() {
+  int x = 1;
+  PDerived t;
+  t.p = 
+  t.foo();
+  clang_analyzer_eval(x); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(t.p == ); // expected-warning{{TRUE}}
+}
+
+void checkThatConstMethodDoesInvalidateContainedPointedAtMemory() {
+  int x = 1;
+  Outer t;
+  t.x = 2;
+  t.in.p = 
+  t.foo();
+  clang_analyzer_eval(x); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(t.x == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(t.in.p == ); // expected-warning{{TRUE}}
+}
+
+void checkThatContainedConstMethodDoesNotInvalidateObjects() {
+  Outer t;
+  t.x = 1;
+  t.in.x = 2;
+  t.in.bar();
+  clang_analyzer_eval(t.x == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(t.in.x == 2); // expected-warning{{TRUE}}
+}
+
+// --- Versions of the above tests where the const method is inherited --- //
+
+struct B1 {
+  void foo() const;
+};
+
+struct D1 : public B1 {
+  int x;
+};
+
+struct D2 : public B1 {
+  mutable int mut;
+};
+
+struct D3 : public B1 {
+  int *p;
+};
+
+struct DInner : public B1 {
+  int x;
+  int *p;
+};
+
+struct DOuter : public B1 {
+  int x;
+  DInner in;
+};
+
+void checkThatInheritedConstMethodDoesNotInvalidateObject() {
+  D1 t;
+  t.x = 1;
+  t.foo();
+  clang_analyzer_eval(t.x == 1); // expected-warning{{TRUE}}
+}
+
+void checkThatInheritedConstMethodDoesInvalidateMutableFields() {
+  D2 t;
+  t.mut = 1;
+  t.foo();
+  clang_analyzer_eval(t.mut); // expected-warning{{UNKNOWN}}
+}
+
+void checkThatInheritedConstMethodDoesInvalidatePointedAtMemory() {
+  int x = 1;
+  D3 t;
+  t.p = 
+  t.foo();
+  clang_analyzer_eval(x); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(t.p == ); // expected-warning{{TRUE}}
+}
+
+void checkThatInheritedConstMethodDoesInvalidateContainedPointedAtMemory() {
+  int x = 1;
+  DOuter t;
+  t.x = 2;
+  t.in.x = 3;
+  t.in.p = 
+  t.foo();
+  clang_analyzer_eval(x); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(t.x == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(t.in.x == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(t.in.p == ); // expected-warning{{TRUE}}
+}
+
+void checkThatInheritedContainedConstMethodDoesNotInvalidateObjects() {
+  DOuter t;
+  t.x = 1;
+  t.in.x = 2;
+  t.in.foo();
+  clang_analyzer_eval(t.x == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(t.in.x == 2); // expected-warning{{TRUE}}
+}
+
+// --- PR21606 --- //
+
+struct s1 {
+void g(const int *i) const;
+};
+
+struct s2 {
+void f(int *i) {
+m_i = i;
+m_s.g(m_i);
+if (m_i)
+*i = 42; // no-warning
+}
+
+int *m_i;
+s1 m_s;
+};
+
+void PR21606()
+{
+s2().f(0);
+}
+
+// FIXME
+// When there is a circular reference to an object and a const method is called
+// the object is not invalidated because TK_PreserveContents has already been
+// set.
+struct 

Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Marek Kurdej via cfe-commits
curdeius added inline comments.


Comment at: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs:186
@@ -145,1 +185,3 @@
+if (!string.IsNullOrEmpty(assumeFilename))
+  process.StartInfo.Arguments += " -assume-filename \"" + 
assumeFilename + "\"";
 process.StartInfo.CreateNoWindow = true;

klimek wrote:
> curdeius wrote:
> > klimek wrote:
> > > Don't we need " escaping for assumeFilename? (or do we consider that an 
> > > error? in which case, would we want to make that an error?)
> > Well, quotes (") are not allowed as a part of a file name on Windows.
> > What we could do is to strip surrounding quotes if the user added them in 
> > order not to add them twice.
> Oh, I didn't know that.
> My main concern is what happens when the user (accidentally) adds quotes (for 
> example, unbalanced) and messes up the command line in a way that leads to a 
> super hard to diagnose problem
Hmm, you're right, we should do something with that.
Either:

  - escape all quotes (but then the errors will be silent and user will not 
know that something bad happens)
  - or to give an error message somehow, e.g. by using a custom TypeConverter 
for AssumeFilename option that will check for the existence of quotes.


http://reviews.llvm.org/D13549



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


Re: [PATCH] D13658: [VFS] Let the user decide if they want path normalization.

2015-10-12 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg



Comment at: include/clang/Basic/VirtualFileSystem.h:282
@@ -280,2 +281,3 @@
   /// Add a buffer to the VFS with a path. The VFS owns the buffer.
-  void addFile(const Twine , time_t ModificationTime,
+  /// \return true if the file was successfully added.
+  bool addFile(const Twine , time_t ModificationTime,

Here, too!


http://reviews.llvm.org/D13658



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


[PATCH] D13658: [VFS] Let the user decide if they want path normalization.

2015-10-12 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added a reviewer: klimek.
bkramer added a subscriber: cfe-commits.

This is a more principled version of what I did earlier. Path
normalization is generally a good thing, but may break users in strange
environments, e. g. using lots of symlinks. Let the user choose and
default it to on.

This also changes adding a duplicated file into returning an error if
the file contents are different instead of an assertion failure.

http://reviews.llvm.org/D13658

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp

Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -525,6 +525,11 @@
 class InMemoryFileSystemTest : public ::testing::Test {
 protected:
   clang::vfs::InMemoryFileSystem FS;
+  clang::vfs::InMemoryFileSystem NormalizedFS;
+
+  InMemoryFileSystemTest()
+  : FS(/*UseNormalizedPaths=*/false),
+NormalizedFS(/*UseNormalizedPaths=*/true) {}
 };
 
 TEST_F(InMemoryFileSystemTest, IsEmpty) {
@@ -549,8 +554,13 @@
 
 TEST_F(InMemoryFileSystemTest, OverlayFile) {
   FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
+  NormalizedFS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
   auto Stat = FS.status("/");
   ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
+  Stat = FS.status("/.");
+  ASSERT_FALSE(Stat);
+  Stat = NormalizedFS.status("/.");
+  ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
   Stat = FS.status("/a");
   ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString();
   ASSERT_EQ("/a", Stat->getName());
@@ -566,17 +576,36 @@
 
 TEST_F(InMemoryFileSystemTest, OpenFileForRead) {
   FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
-  FS.addFile("./c", 0, MemoryBuffer::getMemBuffer("c"));
+  FS.addFile("././c", 0, MemoryBuffer::getMemBuffer("c"));
+  FS.addFile("./d/../d", 0, MemoryBuffer::getMemBuffer("d"));
+  NormalizedFS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
+  NormalizedFS.addFile("././c", 0, MemoryBuffer::getMemBuffer("c"));
+  NormalizedFS.addFile("./d/../d", 0, MemoryBuffer::getMemBuffer("d"));
   auto File = FS.openFileForRead("/a");
   ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
   File = FS.openFileForRead("/a"); // Open again.
   ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
+  File = NormalizedFS.openFileForRead("/././a"); // Open again.
+  ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
   File = FS.openFileForRead("/");
   ASSERT_EQ(File.getError(), errc::invalid_argument) << FS.toString();
   File = FS.openFileForRead("/b");
   ASSERT_EQ(File.getError(), errc::no_such_file_or_directory) << FS.toString();
-  File = FS.openFileForRead("c");
+  File = FS.openFileForRead("./c");
+  ASSERT_FALSE(File);
+  File = FS.openFileForRead("e/../d");
+  ASSERT_FALSE(File);
+  File = NormalizedFS.openFileForRead("./c");
   ASSERT_EQ("c", (*(*File)->getBuffer("ignored"))->getBuffer());
+  File = NormalizedFS.openFileForRead("e/../d");
+  ASSERT_EQ("d", (*(*File)->getBuffer("ignored"))->getBuffer());
+}
+
+TEST_F(InMemoryFileSystemTest, DuplicatedFile) {
+  ASSERT_TRUE(FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a")));
+  ASSERT_FALSE(FS.addFile("/a/b", 0, MemoryBuffer::getMemBuffer("a")));
+  ASSERT_TRUE(FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a")));
+  ASSERT_FALSE(FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("b")));
 }
 
 TEST_F(InMemoryFileSystemTest, DirectoryIteration) {
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -10,6 +10,7 @@
 //===--===//
 
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Basic/FileManager.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
@@ -474,19 +475,20 @@
 };
 }
 
-InMemoryFileSystem::InMemoryFileSystem()
+InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths)
 : Root(new detail::InMemoryDirectory(
   Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(),
  0, 0, 0, llvm::sys::fs::file_type::directory_file,
- llvm::sys::fs::perms::all_all))) {}
+ llvm::sys::fs::perms::all_all))),
+  UseNormalizedPaths(UseNormalizedPaths) {}
 
 InMemoryFileSystem::~InMemoryFileSystem() {}
 
 std::string InMemoryFileSystem::toString() const {
   return Root->toString(/*Indent=*/0);
 }
 
-void InMemoryFileSystem::addFile(const Twine , time_t ModificationTime,
+bool InMemoryFileSystem::addFile(const Twine , time_t ModificationTime,
  std::unique_ptr Buffer) {
   SmallString<128> Path;
   

Re: [PATCH] D13658: [VFS] Let the user decide if they want path normalization.

2015-10-12 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250060: [VFS] Let the user decide if they want path 
normalization. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D13658?vs=37124=37125#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13658

Files:
  cfe/trunk/include/clang/Basic/VirtualFileSystem.h
  cfe/trunk/lib/Basic/VirtualFileSystem.cpp
  cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Index: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
===
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h
@@ -273,17 +273,24 @@
 class InMemoryFileSystem : public FileSystem {
   std::unique_ptr Root;
   std::string WorkingDirectory;
+  bool UseNormalizedPaths = true;
 
 public:
-  InMemoryFileSystem();
+  explicit InMemoryFileSystem(bool UseNormalizedPaths = true);
   ~InMemoryFileSystem() override;
   /// Add a buffer to the VFS with a path. The VFS owns the buffer.
-  void addFile(const Twine , time_t ModificationTime,
+  /// \return true if the file was successfully added, false if the file already
+  /// exists in the file system with different contents.
+  bool addFile(const Twine , time_t ModificationTime,
std::unique_ptr Buffer);
   /// Add a buffer to the VFS with a path. The VFS does not own the buffer.
-  void addFileNoOwn(const Twine , time_t ModificationTime,
+  /// \return true if the file was successfully added, false if the file already
+  /// exists in the file system with different contents.
+  bool addFileNoOwn(const Twine , time_t ModificationTime,
 llvm::MemoryBuffer *Buffer);
   std::string toString() const;
+  /// Return true if this file system normalizes . and .. in paths.
+  bool useNormalizedPaths() const { return UseNormalizedPaths; }
 
   llvm::ErrorOr status(const Twine ) override;
   llvm::ErrorOr
Index: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
===
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp
@@ -10,6 +10,7 @@
 //===--===//
 
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Basic/FileManager.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
@@ -474,19 +475,20 @@
 };
 }
 
-InMemoryFileSystem::InMemoryFileSystem()
+InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths)
 : Root(new detail::InMemoryDirectory(
   Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(),
  0, 0, 0, llvm::sys::fs::file_type::directory_file,
- llvm::sys::fs::perms::all_all))) {}
+ llvm::sys::fs::perms::all_all))),
+  UseNormalizedPaths(UseNormalizedPaths) {}
 
 InMemoryFileSystem::~InMemoryFileSystem() {}
 
 std::string InMemoryFileSystem::toString() const {
   return Root->toString(/*Indent=*/0);
 }
 
-void InMemoryFileSystem::addFile(const Twine , time_t ModificationTime,
+bool InMemoryFileSystem::addFile(const Twine , time_t ModificationTime,
  std::unique_ptr Buffer) {
   SmallString<128> Path;
   P.toVector(Path);
@@ -496,14 +498,14 @@
   assert(!EC);
   (void)EC;
 
-  detail::InMemoryDirectory *Dir = Root.get();
-  auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
-  if (*I == ".")
-++I;
+  if (useNormalizedPaths())
+FileManager::removeDotPaths(Path, /*RemoveDotDot=*/true);
 
-  if (I == E)
-return;
+  if (Path.empty())
+return false;
 
+  detail::InMemoryDirectory *Dir = Root.get();
+  auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
   while (true) {
 StringRef Name = *I;
 detail::InMemoryNode *Node = Dir->getChild(Name);
@@ -519,7 +521,7 @@
 llvm::sys::fs::all_all);
 Dir->addChild(Name, llvm::make_unique(
 std::move(Stat), std::move(Buffer)));
-return;
+return true;
   }
 
   // Create a new directory. Use the path up to here.
@@ -534,12 +536,24 @@
   continue;
 }
 
-if (auto *NewDir = dyn_cast(Node))
+if (auto *NewDir = dyn_cast(Node)) {
   Dir = NewDir;
+} else {
+  assert(isa(Node) &&
+ "Must be either file or directory!");
+
+  // Trying to insert a directory in place of a file.
+  if (I != E)
+return false;
+
+  // Return false only if the new file is different from the existing one.
+  return cast(Node)->getBuffer()->getBuffer() ==
+ Buffer->getBuffer();
+}
   }
 }
 
-void InMemoryFileSystem::addFileNoOwn(const Twine , time_t ModificationTime,
+bool InMemoryFileSystem::addFileNoOwn(const Twine , time_t ModificationTime,
   

r250060 - [VFS] Let the user decide if they want path normalization.

2015-10-12 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct 12 11:16:39 2015
New Revision: 250060

URL: http://llvm.org/viewvc/llvm-project?rev=250060=rev
Log:
[VFS] Let the user decide if they want path normalization.

This is a more principled version of what I did earlier. Path
normalization is generally a good thing, but may break users in strange
environments, e. g. using lots of symlinks. Let the user choose and
default it to on.

This also changes adding a duplicated file into returning an error if
the file contents are different instead of an assertion failure.

Differential Revision: http://reviews.llvm.org/D13658

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=250060=250059=250060=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Mon Oct 12 11:16:39 2015
@@ -273,17 +273,24 @@ class InMemoryDirectory;
 class InMemoryFileSystem : public FileSystem {
   std::unique_ptr Root;
   std::string WorkingDirectory;
+  bool UseNormalizedPaths = true;
 
 public:
-  InMemoryFileSystem();
+  explicit InMemoryFileSystem(bool UseNormalizedPaths = true);
   ~InMemoryFileSystem() override;
   /// Add a buffer to the VFS with a path. The VFS owns the buffer.
-  void addFile(const Twine , time_t ModificationTime,
+  /// \return true if the file was successfully added, false if the file 
already
+  /// exists in the file system with different contents.
+  bool addFile(const Twine , time_t ModificationTime,
std::unique_ptr Buffer);
   /// Add a buffer to the VFS with a path. The VFS does not own the buffer.
-  void addFileNoOwn(const Twine , time_t ModificationTime,
+  /// \return true if the file was successfully added, false if the file 
already
+  /// exists in the file system with different contents.
+  bool addFileNoOwn(const Twine , time_t ModificationTime,
 llvm::MemoryBuffer *Buffer);
   std::string toString() const;
+  /// Return true if this file system normalizes . and .. in paths.
+  bool useNormalizedPaths() const { return UseNormalizedPaths; }
 
   llvm::ErrorOr status(const Twine ) override;
   llvm::ErrorOr

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=250060=250059=250060=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct 12 11:16:39 2015
@@ -10,6 +10,7 @@
 
//===--===//
 
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Basic/FileManager.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
@@ -474,11 +475,12 @@ public:
 };
 }
 
-InMemoryFileSystem::InMemoryFileSystem()
+InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths)
 : Root(new detail::InMemoryDirectory(
   Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(),
  0, 0, 0, llvm::sys::fs::file_type::directory_file,
- llvm::sys::fs::perms::all_all))) {}
+ llvm::sys::fs::perms::all_all))),
+  UseNormalizedPaths(UseNormalizedPaths) {}
 
 InMemoryFileSystem::~InMemoryFileSystem() {}
 
@@ -486,7 +488,7 @@ std::string InMemoryFileSystem::toString
   return Root->toString(/*Indent=*/0);
 }
 
-void InMemoryFileSystem::addFile(const Twine , time_t ModificationTime,
+bool InMemoryFileSystem::addFile(const Twine , time_t ModificationTime,
  std::unique_ptr Buffer) {
   SmallString<128> Path;
   P.toVector(Path);
@@ -496,14 +498,14 @@ void InMemoryFileSystem::addFile(const T
   assert(!EC);
   (void)EC;
 
-  detail::InMemoryDirectory *Dir = Root.get();
-  auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
-  if (*I == ".")
-++I;
+  if (useNormalizedPaths())
+FileManager::removeDotPaths(Path, /*RemoveDotDot=*/true);
 
-  if (I == E)
-return;
+  if (Path.empty())
+return false;
 
+  detail::InMemoryDirectory *Dir = Root.get();
+  auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
   while (true) {
 StringRef Name = *I;
 detail::InMemoryNode *Node = Dir->getChild(Name);
@@ -519,7 +521,7 @@ void InMemoryFileSystem::addFile(const T
 llvm::sys::fs::all_all);
 Dir->addChild(Name, llvm::make_unique(
 std::move(Stat), std::move(Buffer)));
-return;
+return true;
   }
 
   // Create a new directory. 

Re: [PATCH] D13304: Avoid inlining in throw statement

2015-10-12 Thread Jun Bum Lim via cfe-commits
junbuml added a comment.

Just want to hear if there is any opinion about moving this implementation back 
to PrunceEH.cpp like http://reviews.llvm.org/D12979 and adding the minimum 
callee size check to avoid marking noinlines on trivial constrictor calls. 
Please let me know any objection or suggestion.


http://reviews.llvm.org/D13304



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


Re: r248949 - Don't inherit availability information when implementing a protocol requirement.

2015-10-12 Thread Hans Wennborg via cfe-commits
On Fri, Oct 9, 2015 at 9:10 PM, Douglas Gregor  wrote:
>
>
> Sent from my iPhone
>
>> On Oct 9, 2015, at 2:17 PM, Hans Wennborg  wrote:
>>
>>> On Fri, Oct 9, 2015 at 1:46 PM, Douglas Gregor  wrote:
>>>
 On Oct 7, 2015, at 11:55 AM, Hans Wennborg  wrote:

 Hi Doug,

 On Wed, Sep 30, 2015 at 2:27 PM, Douglas Gregor via cfe-commits
  wrote:
> Author: dgregor
> Date: Wed Sep 30 16:27:42 2015
> New Revision: 248949
>
> URL: http://llvm.org/viewvc/llvm-project?rev=248949=rev
> Log:
> Don't inherit availability information when implementing a protocol 
> requirement.
>
> When an Objective-C method implements a protocol requirement, do not
> inherit any availability information from the protocol
> requirement. Rather, check that the implementation is not less
> available than the protocol requirement, as we do when overriding a
> method that has availability. Fixes rdar://problem/22734745.

 This is causing new warnings to fire in Chromium, and I'm not sure
 they're correct.

 For example:

 $ cat | build/bin/clang -c -x objective-c++ -
 #import 
 @protocol Foo
 @end
 @interface Bar : NSTextView {
 }
 @end
 @implementation Bar
 - (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange {
   [super setMarkedText:aString selectedRange:selRange];
 }
 @end
 :9:10: warning: 'setMarkedText:selectedRange:' is deprecated:
 first deprecated in OS X 10.6 [-Wdeprecated-declarations]
   [super setMarkedText:aString selectedRange:selRange];
  ^
 /System/Library/Frameworks/AppKit.framework/Headers/NSInputManager.h:21:1:
 note: 'setMarkedText:selectedRange:' has been explicitly marked
 deprecated here
 - (void) setMarkedText:(id)aString selectedRange:(NSRange)selRange
 NS_DEPRECATED_MAC(10_0, 10_6);
 ^

 I don't really know Objective-C, but from what I understand,
 NSTextView implements both NSTextInput and NSTextInputClient.
 setMarkedText is deprecated in the former, but not the latter. So
 warning here is probably wrong?
>>>
>>> The warning is correct. We no longer infer that -[Bar 
>>> setMarkedText:selectedRange:] is deprecated simply because it matches up 
>>> with a deprecated requirement in the NSTextView protocol. You can mark this 
>>> method with
>>>
>>>NS_DEPRECATED_MAC(10_0, 10_6)
>>>
>>> (i.e., copy the availability information from the protocol requirement) to 
>>> get the old behavior.
>>
>>
>> Again, apologies for my Objective-C ignorance here, but don't you mean
>> the other way around?
>
> No, I have it correct.
>
>> Before this patch we did not warn that setMarkedText was deprecated,
>> but now we do. It seems we've gone from not inferring that it's
>> deprecated to doing so?
>
> NSTextView's setMarkedText is deprecated. Whether we diagnose a call to a 
> deprecated method depends on the context: inside another deprecated method we 
> suppress the diagnostic.
>
> That's where the inference comes in. We used to (incorrectly) infer that 
> Bar's setMarkedText was deprecated. That's wrong, and it suppressed the 
> deprecated warning for the call to the NSTextView version.

Oh, I see what you're saying. That makes sense. Thanks for explaining!

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


Re: [libcxx] r249798 - Split out of .

2015-10-12 Thread Steven Wu via cfe-commits
Hi Richard

Your splitting seems causing problem when using extern "C". Here is a test case:

$ cat test.cpp 
#ifdef __cplusplus
extern "C" {
#endif
#include 
#ifdef __cplusplus
}
#endif

Error:
clang -fsyntax-only test.cpp 
In file included from test.cpp:4:
In file included from /usr/bin/../include/c++/v1/stdio.h:102:
/usr/bin/../include/c++/v1/__config:593:1: error: 
  templates must have C++ linkage
template  struct __static_assert_test;
^~~
/usr/bin/../include/c++/v1/__config:594:20: error: 
  explicit specialization of non-template struct '__static_assert_test'
template <> struct __static_assert_test {};
   ^   ~~
/usr/bin/../include/c++/v1/__config:595:1: error: 
  templates must have C++ linkage
template  struct __static_assert_check {};
^~~
3 errors generated.

Because the code is actually compiled in C++, the guard in the header failed to 
exclude the templates. In the meantime, I don't know if there are ways to 
detect the header is in extern "C".

Steven


> On Oct 8, 2015, at 6:29 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> Author: rsmith
> Date: Thu Oct  8 20:29:09 2015
> New Revision: 249798
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=249798=rev
> Log:
> Split  out of .
> 
> As with , skip our custom header if __need_FILE or __need___FILE is 
> defined.
> 
> Added:
>libcxx/trunk/include/stdio.h
>  - copied, changed from r249736, libcxx/trunk/include/cstdio
> Modified:
>libcxx/trunk/include/cstdio
>libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp
> 
> Modified: libcxx/trunk/include/cstdio
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdio?rev=249798=249797=249798=diff
> ==
> --- libcxx/trunk/include/cstdio (original)
> +++ libcxx/trunk/include/cstdio Thu Oct  8 20:29:09 2015
> @@ -103,16 +103,6 @@ void perror(const char* s);
> #pragma GCC system_header
> #endif
> 
> -// snprintf
> -#if defined(_LIBCPP_MSVCRT)
> -#include "support/win32/support.h"
> -#endif
> -
> -#undef getc
> -#undef putc
> -#undef clearerr
> -#undef feof
> -#undef ferror
> _LIBCPP_BEGIN_NAMESPACE_STD
> 
> using ::FILE;
> 
> Copied: libcxx/trunk/include/stdio.h (from r249736, 
> libcxx/trunk/include/cstdio)
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stdio.h?p2=libcxx/trunk/include/stdio.h=libcxx/trunk/include/cstdio=249736=249798=249798=diff
> ==
> --- libcxx/trunk/include/cstdio (original)
> +++ libcxx/trunk/include/stdio.h Thu Oct  8 20:29:09 2015
> @@ -1,5 +1,5 @@
> // -*- C++ -*-
> -//=== cstdio 
> --===//
> +//=== stdio.h 
> -===//
> //
> // The LLVM Compiler Infrastructure
> //
> @@ -8,11 +8,19 @@
> //
> //===--===//
> 
> -#ifndef _LIBCPP_CSTDIO
> -#define _LIBCPP_CSTDIO
> +#if defined(__need_FILE) || defined(__need___FILE)
> +
> +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
> +#pragma GCC system_header
> +#endif
> +
> +#include_next 
> +
> +#elif !defined(_LIBCPP_STDIO_H)
> +#define _LIBCPP_STDIO_H
> 
> /*
> -cstdio synopsis
> +stdio.h synopsis
> 
> Macros:
> 
> @@ -33,9 +41,6 @@ Macros:
> stdin
> stdout
> 
> -namespace std
> -{
> -
> Types:
> 
> FILE
> @@ -92,20 +97,23 @@ void clearerr(FILE* stream);
> int feof(FILE* stream);
> int ferror(FILE* stream);
> void perror(const char* s);
> -
> -}  // std
> */
> 
> #include <__config>
> -#include 
> 
> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
> #pragma GCC system_header
> #endif
> 
> +#include_next 
> +
> +#ifdef __cplusplus
> +
> // snprintf
> #if defined(_LIBCPP_MSVCRT)
> +extern "C++" {
> #include "support/win32/support.h"
> +}
> #endif
> 
> #undef getc
> @@ -113,72 +121,7 @@ void perror(const char* s);
> #undef clearerr
> #undef feof
> #undef ferror
> -_LIBCPP_BEGIN_NAMESPACE_STD
> -
> -using ::FILE;
> -using ::fpos_t;
> -using ::size_t;
> -
> -using ::fclose;
> -using ::fflush;
> -using ::setbuf;
> -using ::setvbuf;
> -using ::fprintf;
> -using ::fscanf;
> -using ::snprintf;
> -using ::sprintf;
> -using ::sscanf;
> -#ifndef _LIBCPP_MSVCRT
> -using ::vfprintf;
> -using ::vfscanf;
> -using ::vsscanf;
> -#endif // _LIBCPP_MSVCRT
> -using ::vsnprintf;
> -using ::vsprintf;
> -using ::fgetc;
> -using ::fgets;
> -using ::fputc;
> -using ::fputs;
> -using ::getc;
> -using ::putc;
> -using ::ungetc;
> -using ::fread;
> -using ::fwrite;
> -using ::fgetpos;
> -using ::fseek;
> -using ::fsetpos;
> -using ::ftell;
> -using ::rewind;
> -using ::clearerr;
> -using ::feof;
> -using ::ferror;
> -using ::perror;
> -
> -#ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE
> -using ::fopen;
> -using ::freopen;
> -using 

Re: [PATCH] D13399: [CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang

2015-10-12 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250064: [CMake] Bug 14109 - CMake build for compiler-rt 
should use just-built clang (authored by cbieneman).

Changed prior to commit:
  http://reviews.llvm.org/D13399?vs=36897=37127#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13399

Files:
  cfe/trunk/runtime/CMakeLists.txt

Index: cfe/trunk/runtime/CMakeLists.txt
===
--- cfe/trunk/runtime/CMakeLists.txt
+++ cfe/trunk/runtime/CMakeLists.txt
@@ -24,85 +24,101 @@
 
 set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC_DIR}/projects/compiler-rt)
 if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
-  if(CMAKE_GENERATOR MATCHES "Ninja")
-message(FATAL_ERROR
-"Ninja generator can't build compiler-rt as ExternalProject."
-"Unset LLVM_BUILD_EXTERNAL_COMPILER_RT, or don't use Ninja."
-"See http://www.cmake.org/Bug/view.php?id=14771;)
+  if(CMAKE_VERSION VERSION_GREATER 3.3.20150708)
+set(cmake_3_4_USES_TERMINAL_OPTIONS
+  USES_TERMINAL_CONFIGURE 1
+  USES_TERMINAL_BUILD 1
+  USES_TERMINAL_INSTALL 1
+  )
   endif()
 
   # Add compiler-rt as an external project.
   set(COMPILER_RT_PREFIX ${CMAKE_BINARY_DIR}/projects/compiler-rt)
-  
+
+  set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-stamps/)
+  set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-bins/)
+
+  add_custom_target(compiler-rt-clear
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
+COMMENT "Clobberring compiler-rt build and stamp directories"
+)
+
   ExternalProject_Add(compiler-rt
 PREFIX ${COMPILER_RT_PREFIX}
 SOURCE_DIR ${COMPILER_RT_SRC_ROOT}
-CMAKE_ARGS -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
+STAMP_DIR ${STAMP_DIR}
+BINARY_DIR ${BINARY_DIR}
+CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS}
+   -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
-   -DCMAKE_BUILD_TYPE=Release
+   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config
-DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}
-DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
-   -DCOMPILER_RT_INSTALL_PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
+   -DCOMPILER_RT_INSTALL_PATH=${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-   -DCOMPILER_RT_ENABLE_WERROR=ON
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build
+${cmake_3_4_USES_TERMINAL_OPTIONS}
 )
-  # Due to a bug, DEPENDS in ExternalProject_Add doesn't work
-  # in CMake 2.8.9 and 2.8.10.
-  add_dependencies(compiler-rt llvm-config clang)
-
-  # Add a custom step to always re-configure compiler-rt (in case some of its
-  # sources have changed).
-  ExternalProject_Add_Step(compiler-rt force-reconfigure
-DEPENDERS configure
-ALWAYS 1
+
+  get_ext_project_build_command(run_clean_compiler_rt clean)
+  ExternalProject_Add_Step(compiler-rt clean
+COMMAND ${run_clean_compiler_rt}
+COMMENT "Cleaning compiler-rt..."
+DEPENDEES configure
+DEPENDERS build
+DEPENDS clang
+WORKING_DIRECTORY ${BINARY_DIR}
 )
 
-  ExternalProject_Add_Step(compiler-rt clobber
-COMMAND ${CMAKE_COMMAND} -E remove_directory 
-COMMAND ${CMAKE_COMMAND} -E make_directory 
-COMMENT "Clobberring compiler-rt build directory..."
-DEPENDERS configure
-DEPENDS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-  )
+  add_dependencies(compiler-rt-configure clang llvm-config)
+
+  install(CODE "execute_process\(COMMAND ${CMAKE_COMMAND} -P ${BINARY_DIR}/cmake_install.cmake \)"
+COMPONENT compiler-rt)
 
-  ExternalProject_Get_Property(compiler-rt BINARY_DIR)
-  set(COMPILER_RT_BINARY_DIR ${BINARY_DIR})
+  add_custom_target(install-compiler-rt
+DEPENDS compiler-rt
+COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=compiler-rt
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
 
   # Add top-level targets that build specific compiler-rt runtimes.
   set(COMPILER_RT_RUNTIMES asan builtins dfsan lsan msan profile tsan ubsan)
   foreach(runtime ${COMPILER_RT_RUNTIMES})
 get_ext_project_build_command(build_runtime_cmd ${runtime})
 add_custom_target(${runtime}
   COMMAND ${build_runtime_cmd}
   DEPENDS compiler-rt-configure
-  WORKING_DIRECTORY ${COMPILER_RT_BINARY_DIR}
+  WORKING_DIRECTORY ${BINARY_DIR}
   VERBATIM)
   endforeach()
 
-  # Add binaries that compiler-rt 

Re: [PATCH] D13658: [VFS] Let the user decide if they want path normalization.

2015-10-12 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Basic/VirtualFileSystem.h:276
@@ -275,2 +275,3 @@
   std::string WorkingDirectory;
+  bool UseNormalizedPaths;
 

I'd use an in class initializer.


Comment at: include/clang/Basic/VirtualFileSystem.h:282
@@ -280,2 +281,3 @@
   /// Add a buffer to the VFS with a path. The VFS owns the buffer.
-  void addFile(const Twine , time_t ModificationTime,
+  /// \return true if the file was successfully added.
+  bool addFile(const Twine , time_t ModificationTime,

Document in which cases false can happen (or return a status).


http://reviews.llvm.org/D13658



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


Re: [PATCH] D13658: [VFS] Let the user decide if they want path normalization.

2015-10-12 Thread Benjamin Kramer via cfe-commits
bkramer updated this revision to Diff 37124.
bkramer added a comment.

Addressed review comments.


http://reviews.llvm.org/D13658

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp

Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -525,6 +525,11 @@
 class InMemoryFileSystemTest : public ::testing::Test {
 protected:
   clang::vfs::InMemoryFileSystem FS;
+  clang::vfs::InMemoryFileSystem NormalizedFS;
+
+  InMemoryFileSystemTest()
+  : FS(/*UseNormalizedPaths=*/false),
+NormalizedFS(/*UseNormalizedPaths=*/true) {}
 };
 
 TEST_F(InMemoryFileSystemTest, IsEmpty) {
@@ -549,8 +554,13 @@
 
 TEST_F(InMemoryFileSystemTest, OverlayFile) {
   FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
+  NormalizedFS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
   auto Stat = FS.status("/");
   ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
+  Stat = FS.status("/.");
+  ASSERT_FALSE(Stat);
+  Stat = NormalizedFS.status("/.");
+  ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
   Stat = FS.status("/a");
   ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString();
   ASSERT_EQ("/a", Stat->getName());
@@ -566,17 +576,36 @@
 
 TEST_F(InMemoryFileSystemTest, OpenFileForRead) {
   FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
-  FS.addFile("./c", 0, MemoryBuffer::getMemBuffer("c"));
+  FS.addFile("././c", 0, MemoryBuffer::getMemBuffer("c"));
+  FS.addFile("./d/../d", 0, MemoryBuffer::getMemBuffer("d"));
+  NormalizedFS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
+  NormalizedFS.addFile("././c", 0, MemoryBuffer::getMemBuffer("c"));
+  NormalizedFS.addFile("./d/../d", 0, MemoryBuffer::getMemBuffer("d"));
   auto File = FS.openFileForRead("/a");
   ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
   File = FS.openFileForRead("/a"); // Open again.
   ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
+  File = NormalizedFS.openFileForRead("/././a"); // Open again.
+  ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
   File = FS.openFileForRead("/");
   ASSERT_EQ(File.getError(), errc::invalid_argument) << FS.toString();
   File = FS.openFileForRead("/b");
   ASSERT_EQ(File.getError(), errc::no_such_file_or_directory) << FS.toString();
-  File = FS.openFileForRead("c");
+  File = FS.openFileForRead("./c");
+  ASSERT_FALSE(File);
+  File = FS.openFileForRead("e/../d");
+  ASSERT_FALSE(File);
+  File = NormalizedFS.openFileForRead("./c");
   ASSERT_EQ("c", (*(*File)->getBuffer("ignored"))->getBuffer());
+  File = NormalizedFS.openFileForRead("e/../d");
+  ASSERT_EQ("d", (*(*File)->getBuffer("ignored"))->getBuffer());
+}
+
+TEST_F(InMemoryFileSystemTest, DuplicatedFile) {
+  ASSERT_TRUE(FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a")));
+  ASSERT_FALSE(FS.addFile("/a/b", 0, MemoryBuffer::getMemBuffer("a")));
+  ASSERT_TRUE(FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a")));
+  ASSERT_FALSE(FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("b")));
 }
 
 TEST_F(InMemoryFileSystemTest, DirectoryIteration) {
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -10,6 +10,7 @@
 //===--===//
 
 #include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Basic/FileManager.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
@@ -474,19 +475,20 @@
 };
 }
 
-InMemoryFileSystem::InMemoryFileSystem()
+InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths)
 : Root(new detail::InMemoryDirectory(
   Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(),
  0, 0, 0, llvm::sys::fs::file_type::directory_file,
- llvm::sys::fs::perms::all_all))) {}
+ llvm::sys::fs::perms::all_all))),
+  UseNormalizedPaths(UseNormalizedPaths) {}
 
 InMemoryFileSystem::~InMemoryFileSystem() {}
 
 std::string InMemoryFileSystem::toString() const {
   return Root->toString(/*Indent=*/0);
 }
 
-void InMemoryFileSystem::addFile(const Twine , time_t ModificationTime,
+bool InMemoryFileSystem::addFile(const Twine , time_t ModificationTime,
  std::unique_ptr Buffer) {
   SmallString<128> Path;
   P.toVector(Path);
@@ -496,14 +498,14 @@
   assert(!EC);
   (void)EC;
 
-  detail::InMemoryDirectory *Dir = Root.get();
-  auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
-  if (*I == ".")
-++I;
+  if (useNormalizedPaths())
+FileManager::removeDotPaths(Path, /*RemoveDotDot=*/true);
 
-  if (I == E)
-return;
+  if (Path.empty())

Re: [PATCH] D13357: [Concepts] Add diagnostic; specializations of variable and function concepts

2015-10-12 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 37099.
nwilson added a comment.

Moving tests to the correct file.
Modifying the diagnostic id and message so it's more applicable to the checks 
in this Patch. Update the quoted sections of the standard as well.
Use ternary operator for Partial Specialization check.
Add missing period in comment.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -39,3 +39,20 @@
 template  concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template concept bool VCEI { true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool VCPS { true };
+template concept bool VCPS { true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template concept bool VCES { true };
+template<> concept bool VCES { true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool FCES() { return true; }
+template<> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7597,6 +7597,17 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope. A concept definition refers to either a
+  // function concept and its definition or a variable concept and its
+  // initializer.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag:: err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5898,6 +5898,17 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+  << (IsPartialSpecialization ? 2 : 1);
+NewVD->setInvalidDecl(true);
+  }
 }
   }
 
@@ -7544,6 +7555,9 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  NewFD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7595,6 +7609,16 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+NewFD->setInvalidDecl();
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7858,8 +7882,8 @@
  TemplateArgs);

Re: [PATCH] D13620: Documentation for "Throw by value, catch by reference" check in clang-tidy

2015-10-12 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for doing this!


http://reviews.llvm.org/D13620



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


Re: [PATCH] D13620: Documentation for "Throw by value, catch by reference" check in clang-tidy

2015-10-12 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I have commit in r250034. I noticed that there was a missing reference to the 
new documentation in list.rst, so I went ahead and added that as part of your 
patch during the commit.


http://reviews.llvm.org/D13620



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


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-10-12 Thread Nathan Wilson via cfe-commits
nwilson marked 2 inline comments as done.


Comment at: lib/Sema/SemaDecl.cpp:7886
@@ -7863,1 +7885,3 @@
+
+  if (NewFD->isInvalidDecl() && !NewFD->isConcept()) {
 HasExplicitTemplateArgs = false;

Maybe there could be a problem further down if we think there aren't explicit 
template args and there really are. We could do a check similar to the isFriend 
check in the same block below like this:

else if (isConcept && isFunctionTemplateSpecialization) {
  HasExplicitTemplateArgs = true;
}

But it seems like that's essentially the same thing. 




http://reviews.llvm.org/D13357



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


r250037 - [VFS] Unbreak test.

2015-10-12 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct 12 08:39:33 2015
New Revision: 250037

URL: http://llvm.org/viewvc/llvm-project?rev=250037=rev
Log:
[VFS] Unbreak test.

Modified:
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=250037=250036=250037=diff
==
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original)
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Mon Oct 12 08:39:33 2015
@@ -571,8 +571,6 @@ TEST_F(InMemoryFileSystemTest, OpenFileF
   ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
   File = FS.openFileForRead("/a"); // Open again.
   ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
-  File = FS.openFileForRead("./a"); // Open again.
-  ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
   File = FS.openFileForRead("/");
   ASSERT_EQ(File.getError(), errc::invalid_argument) << FS.toString();
   File = FS.openFileForRead("/b");


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


Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Marek Kurdej via cfe-commits
curdeius marked 5 inline comments as done.
curdeius added a comment.

Assume-Filename option will now give an error when there are quotes in the 
filename.


http://reviews.llvm.org/D13549



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


Re: [PATCH] D13549: Added new options to ClangFormat VSIX package.

2015-10-12 Thread Marek Kurdej via cfe-commits
curdeius updated this revision to Diff 37115.
curdeius added a comment.

Add option converters for filenames (prohibiting quotes) and styles (giving a 
list of predefined styles).


http://reviews.llvm.org/D13549

Files:
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
  tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
  tools/clang-format/ClangFormat.cpp

Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -199,17 +199,25 @@
 }
 
 static void outputReplacementXML(StringRef Text) {
+  // FIXME: When we sort includes, we need to make sure the stream is correct
+  // utf-8.
   size_t From = 0;
   size_t Index;
-  while ((Index = Text.find_first_of("\n\r", From)) != StringRef::npos) {
+  while ((Index = Text.find_first_of("\n\r<&", From)) != StringRef::npos) {
 llvm::outs() << Text.substr(From, Index - From);
 switch (Text[Index]) {
 case '\n':
   llvm::outs() << "";
   break;
 case '\r':
   llvm::outs() << "";
   break;
+case '<':
+  llvm::outs() << "";
+  break;
+case '&':
+  llvm::outs() << "";
+  break;
 default:
   llvm_unreachable("Unexpected character encountered!");
 }
Index: tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
===
--- tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
+++ tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@
 // You can specify all the values or you can default the Revision and Build Numbers 
 // by using the '*' as shown below:
 
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]
Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -19,6 +19,7 @@
 using Microsoft.VisualStudio.Text.Editor;
 using Microsoft.VisualStudio.TextManager.Interop;
 using System;
+using System.Collections;
 using System.ComponentModel;
 using System.ComponentModel.Design;
 using System.IO;
@@ -32,13 +33,53 @@
 [CLSCompliant(false), ComVisible(true)]
 public class OptionPageGrid : DialogPage
 {
-private string style = "File";
+private string assumeFilename = "";
+private string fallbackStyle = "LLVM";
+private bool sortIncludes = false;
+private string style = "file";
+
+public class StyleConverter : TypeConverter
+{
+protected ArrayList values;
+public StyleConverter()
+{
+// Initializes the standard values list with defaults.
+values = new ArrayList(new string[] { "file", "Chromium", "Google", "LLVM", "Mozilla", "WebKit" });
+}
+
+public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
+{
+return true;
+}
+
+public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
+{
+StandardValuesCollection svc = new StandardValuesCollection(values);
+return svc;
+}
+
+public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+{
+if (sourceType == typeof(string))
+return true;
+else 
+return base.CanConvertFrom(context, sourceType);
+}
+
+public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
+{
+if (value.GetType() == typeof(string))
+return value;
+else
+return base.ConvertFrom(context, culture, value);
+}
+}
 
 [Category("LLVM/Clang")]
 [DisplayName("Style")]
 [Description("Coding style, currently supports:\n" +
- "  - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla').\n" +
- "  - 'File' to search for a YAML .clang-format or _clang-format\n" +
+ "  - Predefined styles ('LLVM', 'Google', 'Chromium', 'Mozilla', 'WebKit').\n" +
+ "  - 'file' to search for a YAML .clang-format or _clang-format\n" +
  "configuration file.\n" +
  "  - A YAML configuration snippet.\n\n" +
  "'File':\n" +
@@ -48,11 +89,79 @@
  "  The content of a .clang-format configuration file, as string.\n" +
  "  Example: '{BasedOnStyle: \"LLVM\", 

Re: [PATCH] D13014: [X86] Add XSAVE intrinsics (Clang part)

2015-10-12 Thread Amjad Aboud via cfe-commits
aaboud updated this revision to Diff 37108.
aaboud added a comment.

Added two LIT tests to check the xsave intrinsic instructions.


Repository:
  rL LLVM

http://reviews.llvm.org/D13014

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/Intrin.h
  lib/Headers/immintrin.h
  lib/Headers/xsavecintrin.h
  lib/Headers/xsaveintrin.h
  lib/Headers/xsaveoptintrin.h
  lib/Headers/xsavesintrin.h
  test/CodeGen/builtins-x86.c
  test/CodeGen/x86_32-xsave.c
  test/CodeGen/x86_64-xsave.c

Index: lib/Headers/xsaveintrin.h
===
--- lib/Headers/xsaveintrin.h
+++ lib/Headers/xsaveintrin.h
@@ -0,0 +1,58 @@
+/*=== xsaveintrin.h - XSAVE intrinsic ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifndef __XSAVEINTRIN_H
+#define __XSAVEINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  __target__("xsave")))
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_xsave(void *__p, unsigned long long __m) {
+  return __builtin_ia32_xsave(__p, __m);
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_xrstor(void *__p, unsigned long long __m) {
+  return __builtin_ia32_xrstor(__p, __m);
+}
+
+#ifdef __x86_64__
+static __inline__ void __DEFAULT_FN_ATTRS
+_xsave64(void *__p, unsigned long long __m) {
+  return __builtin_ia32_xsave64(__p, __m);
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_xrstor64(void *__p, unsigned long long __m) {
+  return __builtin_ia32_xrstor64(__p, __m);
+}
+#endif
+
+#undef __DEFAULT_FN_ATTRS
+
+#endif
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -66,6 +66,10 @@
   x86intrin.h
   xmmintrin.h
   xopintrin.h
+  xsaveintrin.h
+  xsaveoptintrin.h
+  xsavecintrin.h
+  xsavesintrin.h
   xtestintrin.h
   )
 
Index: lib/Headers/immintrin.h
===
--- lib/Headers/immintrin.h
+++ lib/Headers/immintrin.h
@@ -144,6 +144,14 @@
 
 #include 
 
+#include 
+
+#include 
+
+#include 
+
+#include 
+
 /* Some intrinsics inside adxintrin.h are available only on processors with ADX,
  * whereas others are also available at all times. */
 #include 
Index: lib/Headers/xsavesintrin.h
===
--- lib/Headers/xsavesintrin.h
+++ lib/Headers/xsavesintrin.h
@@ -0,0 +1,58 @@
+/*=== xsavesintrin.h - XSAVES intrinsic ===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ 

Re: r250036 - [VFS] Don't try to be heroic with '.' in paths.

2015-10-12 Thread Manuel Klimek via cfe-commits
I believe we need a more principled approach here :)

1. The first thing we need is to actually produce nice errors when we hit
an addFile() with the same path (normalized or non-normalized)
I'd propose the following approach: we compare the buffers; if the buffer
contents are equal, we declare success; otherwise we return a nice
descriptive error ("trying to add the same file with different content").

2. I think we'll want 2 different modes in InMemoryFileSystem: Normalize
should be either on or off; if on, we should normalize everything, and
return an error if we hop up over /. if off, we should not normalize
anything.

On Mon, Oct 12, 2015 at 3:32 PM Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Mon Oct 12 08:30:38 2015
> New Revision: 250036
>
> URL: http://llvm.org/viewvc/llvm-project?rev=250036=rev
> Log:
> [VFS] Don't try to be heroic with '.' in paths.
>
> Actually the only special path we have to handle is ./foo, the rest is
> tricky to get right so do the same thing as the existing YAML vfs here.
>
> Modified:
> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
>
> Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=250036=250035=250036=diff
>
> ==
> --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
> +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct 12 08:30:38 2015
> @@ -10,7 +10,6 @@
>
>  
> //===--===//
>
>  #include "clang/Basic/VirtualFileSystem.h"
> -#include "clang/Basic/FileManager.h"
>  #include "llvm/ADT/DenseMap.h"
>  #include "llvm/ADT/STLExtras.h"
>  #include "llvm/ADT/StringExtras.h"
> @@ -497,12 +496,14 @@ void InMemoryFileSystem::addFile(const T
>assert(!EC);
>(void)EC;
>
> -  FileManager::removeDotPaths(Path, /*RemoveDotDot=*/false);
> -  if (Path.empty())
> -return;
> -
>detail::InMemoryDirectory *Dir = Root.get();
>auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
> +  if (*I == ".")
> +++I;
> +
> +  if (I == E)
> +return;
> +
>while (true) {
>  StringRef Name = *I;
>  detail::InMemoryNode *Node = Dir->getChild(Name);
> @@ -556,11 +557,13 @@ lookupInMemoryNode(const InMemoryFileSys
>assert(!EC);
>(void)EC;
>
> -  FileManager::removeDotPaths(Path, /*RemoveDotDot=*/false);
> -  if (Path.empty())
> +  auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
> +  if (*I == ".")
> +++I;
> +
> +  if (I == E)
>  return Dir;
>
> -  auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
>while (true) {
>  detail::InMemoryNode *Node = Dir->getChild(*I);
>  ++I;
>
> Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=250036=250035=250036=diff
>
> ==
> --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original)
> +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Mon Oct 12
> 08:30:38 2015
> @@ -551,8 +551,6 @@ TEST_F(InMemoryFileSystemTest, OverlayFi
>FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
>auto Stat = FS.status("/");
>ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
> -  Stat = FS.status("/.");
> -  ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
>Stat = FS.status("/a");
>ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" <<
> FS.toString();
>ASSERT_EQ("/a", Stat->getName());
> @@ -568,18 +566,18 @@ TEST_F(InMemoryFileSystemTest, OverlayFi
>
>  TEST_F(InMemoryFileSystemTest, OpenFileForRead) {
>FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
> -  FS.addFile("././c", 0, MemoryBuffer::getMemBuffer("c"));
> +  FS.addFile("./c", 0, MemoryBuffer::getMemBuffer("c"));
>auto File = FS.openFileForRead("/a");
>ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
>File = FS.openFileForRead("/a"); // Open again.
>ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
> -  File = FS.openFileForRead("/././a"); // Open again.
> +  File = FS.openFileForRead("./a"); // Open again.
>ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
>File = FS.openFileForRead("/");
>ASSERT_EQ(File.getError(), errc::invalid_argument) << FS.toString();
>File = FS.openFileForRead("/b");
>ASSERT_EQ(File.getError(), errc::no_such_file_or_directory) <<
> FS.toString();
> -  File = FS.openFileForRead("./c");
> +  File = FS.openFileForRead("c");
>ASSERT_EQ("c", (*(*File)->getBuffer("ignored"))->getBuffer());
>  }
>
>
>
> ___
> cfe-commits mailing list
> 

r250043 - [Driver] Remove `else` after `return`

2015-10-12 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Mon Oct 12 09:32:57 2015
New Revision: 250043

URL: http://llvm.org/viewvc/llvm-project?rev=250043=rev
Log:
[Driver] Remove `else` after `return`

Modified:
cfe/trunk/lib/Driver/Multilib.cpp

Modified: cfe/trunk/lib/Driver/Multilib.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Multilib.cpp?rev=250043=250042=250043=diff
==
--- cfe/trunk/lib/Driver/Multilib.cpp (original)
+++ cfe/trunk/lib/Driver/Multilib.cpp Mon Oct 12 09:32:57 2015
@@ -260,16 +260,15 @@ bool MultilibSet::select(const Multilib:
 return false;
   }, Multilibs);
 
-  if (Filtered.size() == 0) {
+  if (Filtered.size() == 0)
 return false;
-  } else if (Filtered.size() == 1) {
+  if (Filtered.size() == 1) {
 M = Filtered[0];
 return true;
   }
 
   // TODO: pick the "best" multlib when more than one is suitable
   assert(false);
-
   return false;
 }
 


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


RE: [Patch][OpenCL] Custom atomic Builtin check ignores address space of a non-atomic pointer

2015-10-12 Thread Anastasia Stulova via cfe-commits
I have just made one minor update in the CodeGen test 
(test/CodeGen/atomic-ops.c) that is now checking the IR output rather than only 
making sure frontend doesn't crash.

The final patch is attached here!

Thanks,
Anastasia
 

-Original Message-
From: Pekka Jääskeläinen [mailto:pekka.jaaskelai...@tut.fi] 
Sent: 02 October 2015 10:20
To: Anastasia Stulova; cfe-commits@lists.llvm.org
Subject: Re: [Patch][OpenCL] Custom atomic Builtin check ignores address space 
of a non-atomic pointer

LGTM.

Related to it:
There has been so many getPointerTo() issues with multi-AS in the past that I 
wonder if it'd be time to drop the default value from it, and go through all 
the places where it's called with the default AS, thus breaking multi-AS.  
Might be a worthwhile job to do at some point.

On 09/30/2015 01:23 PM, Anastasia Stulova via cfe-commits wrote:
> Hi all,
>
> Address spaces are not handled in custom semantic checks of atomic Builtins.
>
> If there are two pointers passed to the Builtin, it doesn't allow the 
> second
>
> (non-atomic) one to be qualified with an address space.
>
> This patch removed this restriction by recording the address space of 
> the
>
> passed pointers while checking its type correctness.
>
> Currently, the following code:
>
> _Atomic int __attribute__((address_space(1))) *A;
>
> int __attribute__((address_space(2))) *B;
>
> ...
>
> ... = __c11_atomic_compare_exchange_strong(A, B, 1, 
> memory_order_seq_cst, memory_order_seq_cst);
>
> fails to compile with an error:
>
> "passing '__attribute__((address_space(2))) int *' to parameter of 
> type 'int *' changes address space of pointer".
>
> Please, review the attached fix for it!
>
> Cheers,
>
> Anastasia
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>

--
Pekka



atomics-builtin-adrspace-v2.patch
Description: Binary data
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D13664: [Fix] Don't emit multiple diagnostics for the same error

2015-10-12 Thread George Burgess IV via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added a subscriber: cfe-commits.

Given code like the following (stolen from tests):

```
template  int f(T1 *, const T2 *);
template  int f(const T1 *, T2 *);
int (*p)(const int *, const int *) = f;
```

Clang will currently emit two "address of overloaded function f is ambiguous" 
errors for the same assignment (on line 3). 

This patch makes us only emit one.

http://reviews.llvm.org/D13664

Files:
  lib/Sema/SemaOverload.cpp
  test/SemaCXX/addr-of-overloaded-function.cpp

Index: test/SemaCXX/addr-of-overloaded-function.cpp
===
--- test/SemaCXX/addr-of-overloaded-function.cpp
+++ test/SemaCXX/addr-of-overloaded-function.cpp
@@ -125,13 +125,9 @@
 }
 
 namespace PR8033 {
-  template  int f(T1 *, const T2 *); // 
expected-note {{candidate function [with T1 = const int, T2 = int]}} \
-  // expected-note{{candidate function}}
-  template  int f(const T1 *, T2 *); // 
expected-note {{candidate function [with T1 = int, T2 = const int]}} \
-  // expected-note{{candidate function}}
-  int (*p)(const int *, const int *) = f; // expected-error{{address of 
overloaded function 'f' is ambiguous}} \
-  // expected-error{{address of overloaded function 'f' is ambiguous}}
-
+  template  int f(T1 *, const T2 *); // 
expected-note {{candidate function [with T1 = const int, T2 = int]}}
+  template  int f(const T1 *, T2 *); // 
expected-note {{candidate function [with T1 = int, T2 = const int]}}
+  int (*p)(const int *, const int *) = f; // expected-error{{address of 
overloaded function 'f' is ambiguous}}
 }
 
 namespace PR8196 {
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -9911,6 +9911,7 @@
   bool TargetTypeIsNonStaticMemberFunction;
   bool FoundNonTemplateFunction;
   bool StaticMemberFunctionFromBoundPointer;
+  bool HasComplained;
 
   OverloadExpr::FindResult OvlExprInfo; 
   OverloadExpr *OvlExpr;
@@ -9927,6 +9928,7 @@
 !!TargetType->getAs()),
 FoundNonTemplateFunction(false),
 StaticMemberFunctionFromBoundPointer(false),
+HasComplained(false),
 OvlExprInfo(OverloadExpr::find(SourceExpr)),
 OvlExpr(OvlExprInfo.Expression),
 FailedCandidates(OvlExpr->getNameLoc()) {
@@ -9977,7 +9979,9 @@
 Matches.size() > 1)
   EliminateSuboptimalCudaMatches();
   }
-  
+
+  bool hasComplained() const { return HasComplained; }
+
 private:
   bool isTargetTypeAFunction() const {
 return TargetFunctionType->isFunctionType();
@@ -10056,9 +10060,12 @@
   // If any candidate has a placeholder return type, trigger its deduction
   // now.
   if (S.getLangOpts().CPlusPlus14 &&
-  FunDecl->getReturnType()->isUndeducedType() &&
-  S.DeduceReturnType(FunDecl, SourceExpr->getLocStart(), Complain))
-return false;
+  FunDecl->getReturnType()->isUndeducedType()) {
+if (S.DeduceReturnType(FunDecl, SourceExpr->getLocStart(), Complain)) {
+  HasComplained |= Complain;
+  return false;
+}
+  }
 
   QualType ResultTy;
   if (Context.hasSameUnqualifiedType(TargetFunctionType, 
@@ -10140,7 +10147,8 @@
   Matches[0].first = Matches[Result - MatchesCopy.begin()].first;
   Matches[0].second = cast(*Result);
   Matches.resize(1);
-}
+} else
+  HasComplained |= Complain;
   }
 
   void EliminateAllTemplateMatches() {
@@ -10261,13 +10269,14 @@
  Complain);
   int NumMatches = Resolver.getNumMatches();
   FunctionDecl *Fn = nullptr;
-  if (NumMatches == 0 && Complain) {
+  bool ShouldComplain = Complain && !Resolver.hasComplained();
+  if (NumMatches == 0 && ShouldComplain) {
 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
   Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
 else
   Resolver.ComplainNoMatchesFound();
   }
-  else if (NumMatches > 1 && Complain)
+  else if (NumMatches > 1 && ShouldComplain)
 Resolver.ComplainMultipleMatchesFound();
   else if (NumMatches == 1) {
 Fn = Resolver.getMatchingFunctionDecl();


Index: test/SemaCXX/addr-of-overloaded-function.cpp
===
--- test/SemaCXX/addr-of-overloaded-function.cpp
+++ test/SemaCXX/addr-of-overloaded-function.cpp
@@ -125,13 +125,9 @@
 }
 
 namespace PR8033 {
-  template  int f(T1 *, const T2 *); // expected-note {{candidate function [with T1 = const int, T2 = int]}} \
-  // expected-note{{candidate function}}
-  template  int f(const T1 *, T2 *); // expected-note {{candidate function [with T1 = int, T2 = const int]}} \
-  // expected-note{{candidate function}}
-  int (*p)(const int *, const int *) = f; // expected-error{{address of overloaded function 'f' is ambiguous}} \
-  // 

Re: [PATCH] D13607: [Fix] Make it an error to take the address of (most) enable_if functions.

2015-10-12 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D13607



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


Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-10-12 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1726
@@ -1720,1 +1725,3 @@
+def err_auto_bitfield : Error<
+  "cannot pass bit-field as __auto_type initializer in C">;
 

pass -> use

Also, why not? Just because GCC messes this up, doesn't mean we have to.


Comment at: lib/AST/ItaniumMangle.cpp:2557-2558
@@ -2557,1 +2556,4 @@
+  if (D.isNull()) {
+assert(T->getKeyword() != AutoTypeKeyword::GNUAutoType &&
+   "shouldn't need to mangle __auto_type!");
 Out << (T->isDecltypeAuto() ? "Dc" : "Da");

Why not?

  template void f(decltype(new __auto_type(T(;

... would need a mangling, right? (Or do you prohibit `__auto_type` there?)


Comment at: lib/Parse/ParseDeclCXX.cpp:1119
@@ -1118,2 +1118,3 @@
   case tok::kw_auto:// struct foo {...} auto  x;
+  case tok::kw___auto_type: // struct foo {...} __auto_type x;
   case tok::kw_mutable: // struct foo {...} mutable   x;

That would be ill-formed; revert this change.


Comment at: lib/Sema/SemaExpr.cpp:352
@@ -351,1 +351,3 @@
   if (ParsingInitForAutoVars.count(D)) {
+const AutoType* AT = cast(D)->getType()->getContainedAutoType();
+

This has not been addressed.


Comment at: lib/Sema/SemaType.cpp:1457
@@ -1455,3 +1456,3 @@
 // being analyzed (which tracks the invented type template parameter).
 if (declarator.getContext() == Declarator::LambdaExprParameterContext) {
   sema::LambdaScopeInfo *LSI = S.getCurLambda();

Should we really allow using `__auto_type` to introduce a generic lambda? It 
seems like there's a major open design question here: either we should allow 
`__auto_type` only in GCC-compatible contexts (that is, as a decl-specifier 
that's not a function return type), or we should allow it everywhere we allow 
`auto` and make it a synonym for `auto` in C++ (in which case it needs to be 
mangled, and the distinction between `auto` and `__auto_type` should probably 
not affect the canonical type).


Comment at: lib/Sema/SemaType.cpp:2654-2655
@@ -2648,4 +2653,4 @@
 case Declarator::ConversionIdContext:
   if (!SemaRef.getLangOpts().CPlusPlus14)
-Error = 12; // conversion-type-id
+Error = 14; // conversion-type-id
   break;

Do you really want to allow `__auto_type` here? This is inconsistent with what 
you do for return types.


http://reviews.llvm.org/D12686



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


Re: [PATCH] D13664: [Fix] Don't emit multiple diagnostics for the same error

2015-10-12 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


http://reviews.llvm.org/D13664



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


Re: [PATCH] D13664: [Fix] Don't emit multiple diagnostics for the same error

2015-10-12 Thread George Burgess IV via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250078: [Sema] Don't emit multiple diags for one error 
(authored by gbiv).

Changed prior to commit:
  http://reviews.llvm.org/D13664?vs=37137=37138#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13664

Files:
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp

Index: cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp
===
--- cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp
+++ cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -125,13 +125,9 @@
 }
 
 namespace PR8033 {
-  template  int f(T1 *, const T2 *); // 
expected-note {{candidate function [with T1 = const int, T2 = int]}} \
-  // expected-note{{candidate function}}
-  template  int f(const T1 *, T2 *); // 
expected-note {{candidate function [with T1 = int, T2 = const int]}} \
-  // expected-note{{candidate function}}
-  int (*p)(const int *, const int *) = f; // expected-error{{address of 
overloaded function 'f' is ambiguous}} \
-  // expected-error{{address of overloaded function 'f' is ambiguous}}
-
+  template  int f(T1 *, const T2 *); // 
expected-note {{candidate function [with T1 = const int, T2 = int]}}
+  template  int f(const T1 *, T2 *); // 
expected-note {{candidate function [with T1 = int, T2 = const int]}}
+  int (*p)(const int *, const int *) = f; // expected-error{{address of 
overloaded function 'f' is ambiguous}}
 }
 
 namespace PR8196 {
Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -9911,6 +9911,7 @@
   bool TargetTypeIsNonStaticMemberFunction;
   bool FoundNonTemplateFunction;
   bool StaticMemberFunctionFromBoundPointer;
+  bool HasComplained;
 
   OverloadExpr::FindResult OvlExprInfo; 
   OverloadExpr *OvlExpr;
@@ -9927,6 +9928,7 @@
 !!TargetType->getAs()),
 FoundNonTemplateFunction(false),
 StaticMemberFunctionFromBoundPointer(false),
+HasComplained(false),
 OvlExprInfo(OverloadExpr::find(SourceExpr)),
 OvlExpr(OvlExprInfo.Expression),
 FailedCandidates(OvlExpr->getNameLoc()) {
@@ -9977,7 +9979,9 @@
 Matches.size() > 1)
   EliminateSuboptimalCudaMatches();
   }
-  
+
+  bool hasComplained() const { return HasComplained; }
+
 private:
   bool isTargetTypeAFunction() const {
 return TargetFunctionType->isFunctionType();
@@ -10057,8 +10061,10 @@
   // now.
   if (S.getLangOpts().CPlusPlus14 &&
   FunDecl->getReturnType()->isUndeducedType() &&
-  S.DeduceReturnType(FunDecl, SourceExpr->getLocStart(), Complain))
+  S.DeduceReturnType(FunDecl, SourceExpr->getLocStart(), Complain)) {
+HasComplained |= Complain;
 return false;
+  }
 
   QualType ResultTy;
   if (Context.hasSameUnqualifiedType(TargetFunctionType, 
@@ -10140,7 +10146,8 @@
   Matches[0].first = Matches[Result - MatchesCopy.begin()].first;
   Matches[0].second = cast(*Result);
   Matches.resize(1);
-}
+} else
+  HasComplained |= Complain;
   }
 
   void EliminateAllTemplateMatches() {
@@ -10261,13 +10268,14 @@
  Complain);
   int NumMatches = Resolver.getNumMatches();
   FunctionDecl *Fn = nullptr;
-  if (NumMatches == 0 && Complain) {
+  bool ShouldComplain = Complain && !Resolver.hasComplained();
+  if (NumMatches == 0 && ShouldComplain) {
 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
   Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
 else
   Resolver.ComplainNoMatchesFound();
   }
-  else if (NumMatches > 1 && Complain)
+  else if (NumMatches > 1 && ShouldComplain)
 Resolver.ComplainMultipleMatchesFound();
   else if (NumMatches == 1) {
 Fn = Resolver.getMatchingFunctionDecl();


Index: cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp
===
--- cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp
+++ cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -125,13 +125,9 @@
 }
 
 namespace PR8033 {
-  template  int f(T1 *, const T2 *); // expected-note {{candidate function [with T1 = const int, T2 = int]}} \
-  // expected-note{{candidate function}}
-  template  int f(const T1 *, T2 *); // expected-note {{candidate function [with T1 = int, T2 = const int]}} \
-  // expected-note{{candidate function}}
-  int (*p)(const int *, const int *) = f; // expected-error{{address of overloaded function 'f' is ambiguous}} \
-  // expected-error{{address of overloaded function 'f' is ambiguous}}
-
+  template  int f(T1 *, const T2 *); // expected-note {{candidate function [with T1 = const int, T2 = int]}}
+  template  int f(const T1 *, T2 *); // expected-note {{candidate function [with T1 = int, T2 = const 

r250078 - [Sema] Don't emit multiple diags for one error

2015-10-12 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon Oct 12 13:40:58 2015
New Revision: 250078

URL: http://llvm.org/viewvc/llvm-project?rev=250078=rev
Log:
[Sema] Don't emit multiple diags for one error

Fixed a bug where we'd emit multiple diagnostics if there was a problem
taking the address of an overloaded template function.

Differential Revision: http://reviews.llvm.org/D13664

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=250078=250077=250078=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Oct 12 13:40:58 2015
@@ -9911,6 +9911,7 @@ class AddressOfFunctionResolver {
   bool TargetTypeIsNonStaticMemberFunction;
   bool FoundNonTemplateFunction;
   bool StaticMemberFunctionFromBoundPointer;
+  bool HasComplained;
 
   OverloadExpr::FindResult OvlExprInfo; 
   OverloadExpr *OvlExpr;
@@ -9927,6 +9928,7 @@ public:
 !!TargetType->getAs()),
 FoundNonTemplateFunction(false),
 StaticMemberFunctionFromBoundPointer(false),
+HasComplained(false),
 OvlExprInfo(OverloadExpr::find(SourceExpr)),
 OvlExpr(OvlExprInfo.Expression),
 FailedCandidates(OvlExpr->getNameLoc()) {
@@ -9977,7 +9979,9 @@ public:
 Matches.size() > 1)
   EliminateSuboptimalCudaMatches();
   }
-  
+
+  bool hasComplained() const { return HasComplained; }
+
 private:
   bool isTargetTypeAFunction() const {
 return TargetFunctionType->isFunctionType();
@@ -10057,8 +10061,10 @@ private:
   // now.
   if (S.getLangOpts().CPlusPlus14 &&
   FunDecl->getReturnType()->isUndeducedType() &&
-  S.DeduceReturnType(FunDecl, SourceExpr->getLocStart(), Complain))
+  S.DeduceReturnType(FunDecl, SourceExpr->getLocStart(), Complain)) {
+HasComplained |= Complain;
 return false;
+  }
 
   QualType ResultTy;
   if (Context.hasSameUnqualifiedType(TargetFunctionType, 
@@ -10140,7 +10146,8 @@ private:
   Matches[0].first = Matches[Result - MatchesCopy.begin()].first;
   Matches[0].second = cast(*Result);
   Matches.resize(1);
-}
+} else
+  HasComplained |= Complain;
   }
 
   void EliminateAllTemplateMatches() {
@@ -10261,13 +10268,14 @@ Sema::ResolveAddressOfOverloadedFunction
  Complain);
   int NumMatches = Resolver.getNumMatches();
   FunctionDecl *Fn = nullptr;
-  if (NumMatches == 0 && Complain) {
+  bool ShouldComplain = Complain && !Resolver.hasComplained();
+  if (NumMatches == 0 && ShouldComplain) {
 if (Resolver.IsInvalidFormOfPointerToMemberFunction())
   Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
 else
   Resolver.ComplainNoMatchesFound();
   }
-  else if (NumMatches > 1 && Complain)
+  else if (NumMatches > 1 && ShouldComplain)
 Resolver.ComplainMultipleMatchesFound();
   else if (NumMatches == 1) {
 Fn = Resolver.getMatchingFunctionDecl();

Modified: cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp?rev=250078=250077=250078=diff
==
--- cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp (original)
+++ cfe/trunk/test/SemaCXX/addr-of-overloaded-function.cpp Mon Oct 12 13:40:58 
2015
@@ -125,13 +125,9 @@ namespace PR7971 {
 }
 
 namespace PR8033 {
-  template  int f(T1 *, const T2 *); // 
expected-note {{candidate function [with T1 = const int, T2 = int]}} \
-  // expected-note{{candidate function}}
-  template  int f(const T1 *, T2 *); // 
expected-note {{candidate function [with T1 = int, T2 = const int]}} \
-  // expected-note{{candidate function}}
-  int (*p)(const int *, const int *) = f; // expected-error{{address of 
overloaded function 'f' is ambiguous}} \
-  // expected-error{{address of overloaded function 'f' is ambiguous}}
-
+  template  int f(T1 *, const T2 *); // 
expected-note {{candidate function [with T1 = const int, T2 = int]}}
+  template  int f(const T1 *, T2 *); // 
expected-note {{candidate function [with T1 = int, T2 = const int]}}
+  int (*p)(const int *, const int *) = f; // expected-error{{address of 
overloaded function 'f' is ambiguous}}
 }
 
 namespace PR8196 {


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


Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-10-12 Thread Vedant Kumar via cfe-commits
vsk added a comment.

This lgtm. If you don't have commit rights, I can land this for you if you'd 
like.


http://reviews.llvm.org/D12686



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


Re: [PATCH] D13582: [DEBUG INFO] Emit debug info for type used in explicit cast only.

2015-10-12 Thread John McCall via cfe-commits
> On Oct 12, 2015, at 10:50 AM, David Blaikie  wrote:
> +John, author of the original patch - in case it's an obvious mistake. I 
> haven't looked at John's change yet & compared it to the intended behavior, 
> etc. Will do so soon and/or if John doesn't see something at a glance.

The functionality looks fine to me; I definitely just overlooked the debug-info 
side of things.

Let’s extract out a function to emit the cast type of an explicit cast and make 
sure we call it consistently.  It can do both the VLA binding and the 
debug-info emission.

John.

> 
> On Sun, Oct 11, 2015 at 11:09 PM, Bataev, Alexey  > wrote:
> Yes, revision 246985 
>   
> >
>  broke th debug info for types in explicit casts.
> 
> Best regards,
> Alexey Bataev
> =
> Software Engineer
> Intel Compiler Team
> 
> 09.10.2015 18:26, David Blaikie пишет:
> 
> 
> On Fri, Oct 9, 2015 at 2:26 AM, Alexey Bataev via cfe-commits 
>  
> >> 
> wrote:
> 
> ABataev created this revision.
> ABataev added a reviewer: echristo.
> ABataev added a subscriber: cfe-commits.
> 
> Currently debug info for types used in explicit cast only is not
> emitted. It happened after a patch for better alignment handling.
> 
> 
> You mean a patch related to alignment regressed this functionality? Do you 
> have the specific revision number of that change (since it sounds like you 
> tracked it down)?
> 
> This patch fixes this bug.
> 
> http://reviews.llvm.org/D13582 
> 
> Files:
>   lib/CodeGen/CGExpr.cpp
>   test/CodeGenCXX/debug-info-explicit-cast.cpp
> 
> Index: lib/CodeGen/CGExpr.cpp
> ===
> --- lib/CodeGen/CGExpr.cpp
> +++ lib/CodeGen/CGExpr.cpp
> @@ -799,6 +799,10 @@
>  if (E->getType()->isVariablyModifiedType())
>EmitVariablyModifiedType(E->getType());
> 
> +if (isa(CE))
> +  if (CGDebugInfo *DI = getDebugInfo())
> +DI->EmitExplicitCastType(E->getType());
> +
>  switch (CE->getCastKind()) {
>  // Non-converting casts (but not C's implicit conversion from
> void*).
>  case CK_BitCast:
> Index: test/CodeGenCXX/debug-info-explicit-cast.cpp
> ===
> --- test/CodeGenCXX/debug-info-explicit-cast.cpp
> +++ test/CodeGenCXX/debug-info-explicit-cast.cpp
> @@ -0,0 +1,18 @@
> +// RUN: %clangxx -c -target x86_64-unknown-unknown -g %s
> -emit-llvm -S -o - | FileCheck %s
> +struct Foo {
> +  int a;
> +  Foo() : a(1){};
> +};
> +
> +struct Bar {
> +  int b;
> +  Bar() : b(2){};
> +};
> +
> +int main() {
> +  Bar *pb = new Bar;
> +
> +  return reinterpret_cast(pb)->a;
> +}
> +
> +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Foo",
> 
> 
> 
> ___
> 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


r250094 - Support Debug Info path remapping

2015-10-12 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Oct 12 15:21:08 2015
New Revision: 250094

URL: http://llvm.org/viewvc/llvm-project?rev=250094=rev
Log:
Support Debug Info path remapping

Add support for the `-fdebug-prefix-map=` option as in GCC.  The syntax is
`-fdebug-prefix-map=OLD=NEW`.  When compiling files from a path beginning with
OLD, change the debug info to indicate the path as start with NEW.  This is
particularly helpful if you are preprocessing in one path and compiling in
another (e.g. for a build cluster with distcc).

Note that the linearity of the implementation is not as terrible as it may seem.
This is normally done once per file with an expectation that the map will be
small (1-2) entries, making this roughly linear in the number of input paths.

Addresses PR24619.

Added:
cfe/trunk/test/CodeGen/debug-prefix-map.c
cfe/trunk/test/Driver/debug-prefix-map.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=250094=250093=250094=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Oct 12 15:21:08 
2015
@@ -81,6 +81,8 @@ def err_drv_invalid_mfloat_abi : Error<
   "invalid float ABI '%0'">;
 def err_drv_invalid_libcxx_deployment : Error<
   "invalid deployment target for -stdlib=libc++ (requires %0 or later)">;
+def err_drv_invalid_argument_to_fdebug_prefix_map : Error<
+  "invalid argument '%0' to -fdebug-prefix-map">;
 def err_drv_malformed_sanitizer_blacklist : Error<
   "malformed sanitizer blacklist: '%0'">;
 

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=250094=250093=250094=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Oct 12 15:21:08 2015
@@ -1109,6 +1109,9 @@ def fdebug_types_section: Flag <["-"], "
   Flags<[CC1Option]>, HelpText<"Place debug types in their own section (ELF 
Only)">;
 def fno_debug_types_section: Flag<["-"], "fno-debug-types-section">, 
Group,
   Flags<[CC1Option]>;
+def fdebug_prefix_map_EQ
+  : Joined<["-"], "fdebug-prefix-map=">, Group, Flags<[CC1Option]>,
+HelpText<"remap file source paths in debug info">;
 def g_Flag : Flag<["-"], "g">, Group,
   HelpText<"Generate source-level debug information">;
 def gline_tables_only : Flag<["-"], "gline-tables-only">, Group,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=250094=250093=250094=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Mon Oct 12 15:21:08 2015
@@ -16,6 +16,7 @@
 
 #include "clang/Basic/Sanitizers.h"
 #include "llvm/Support/Regex.h"
+#include 
 #include 
 #include 
 #include 
@@ -120,6 +121,8 @@ public:
   /// non-empty.
   std::string DwarfDebugFlags;
 
+  std::map DebugPrefixMap;
+
   /// The ABI to use for passing floating point arguments.
   std::string FloatABI;
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=250094=250093=250094=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Oct 12 15:21:08 2015
@@ -47,6 +47,8 @@ CGDebugInfo::CGDebugInfo(CodeGenModule &
 : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
   DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
   DBuilder(CGM.getModule()) {
+  for (const auto  : CGM.getCodeGenOpts().DebugPrefixMap)
+DebugPrefixMap[KV.first] = KV.second;
   CreateCompileUnit();
 }
 
@@ -255,14 +257,16 @@ StringRef CGDebugInfo::getClassName(cons
 llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
   if (!Loc.isValid())
 // If Location is not valid then use main input file.
-return DBuilder.createFile(TheCU->getFilename(), TheCU->getDirectory());
+return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
+   remapDIPath(TheCU->getDirectory()));
 
   SourceManager  = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc);

r250090 - [Sema] Make `_with_enable_if_attrs` an error

2015-10-12 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon Oct 12 14:57:04 2015
New Revision: 250090

URL: http://llvm.org/viewvc/llvm-project?rev=250090=rev
Log:
[Sema] Make `_with_enable_if_attrs` an error

This fixes a bug where one can take the address of a conditionally
enabled function to drop its enable_if guards. For example:

  int foo(int a) __attribute__((enable_if(a > 0, "")));
  int (*p)(int) = 
  int result = p(-1); // compilation succeeds; calls foo(-1)

Overloading logic has been updated to reflect this change, as well.

Functions with enable_if attributes that are always true are still
allowed to have their address taken.

Differential Revision: http://reviews.llvm.org/D13607

Added:
cfe/trunk/test/CodeGen/enable_if.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/Sema/enable_if.c
cfe/trunk/test/SemaCXX/enable_if.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=250090=250089=250090=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 12 14:57:04 
2015
@@ -1496,7 +1496,8 @@ def err_init_conversion_failed : Error<
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
   "volatile and restrict|const, volatile, and restrict}5 vs "
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}6)}4">;
+  "volatile and restrict|const, volatile, and restrict}6)"
+  "|: cannot take the address of a potentially disabled function}4">;
 
 def err_lvalue_to_rvalue_ref : Error<"rvalue reference %diff{to type $ cannot "
   "bind to lvalue of type $|cannot bind to incompatible lvalue}0,1">;
@@ -2967,7 +2968,8 @@ def note_ovl_candidate : Note<"candidate
 "%select{none|const|restrict|const and restrict|volatile|const and 
volatile"
 "|volatile and restrict|const, volatile, and restrict}3 but found "
 "%select{none|const|restrict|const and restrict|volatile|const and 
volatile"
-"|volatile and restrict|const, volatile, and restrict}4)}2">;
+"|volatile and restrict|const, volatile, and restrict}4)"
+"| made ineligible by enable_if}2">;
 
 def note_ovl_candidate_inherited_constructor : Note<"inherited from here">;
 def note_ovl_candidate_illegal_constructor : Note<
@@ -5662,7 +5664,8 @@ def note_hidden_overloaded_virtual_decla
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
   "volatile and restrict|const, volatile, and restrict}2 vs "
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}3)}1">;
+  "volatile and restrict|const, volatile, and restrict}3)"
+  "|: mismatch in enable_if attributes}1">;
 def warn_using_directive_in_header : Warning<
   "using namespace directive in global context in header">,
   InGroup, DefaultIgnore;
@@ -5899,7 +5902,8 @@ def err_typecheck_convert_incompatible :
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
   "volatile and restrict|const, volatile, and restrict}5 vs "
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}6)}4">;
+  "volatile and restrict|const, volatile, and restrict}6)"
+  "|: cannot take the address of a potentially disabled function}4">;
 def err_typecheck_missing_return_type_incompatible : Error<
   "%diff{return type $ must match previous return type $|"
   "return type must match previous return type}0,1 when %select{block "

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=250090=250089=250090=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct 12 14:57:04 2015
@@ -2440,11 +2440,13 @@ public:
 bool PartialOverloading = false);
 
   // Emit as a 'note' the specific overload candidate
-  void NoteOverloadCandidate(FunctionDecl *Fn, QualType DestType = QualType());
+  void NoteOverloadCandidate(FunctionDecl *Fn, QualType DestType = QualType(),
+ bool TakingAddress = false);
 
-  // Emit as a series of 'note's all template and non-templates
-  // identified by the expression Expr
-  void NoteAllOverloadCandidates(Expr* E, QualType DestType = QualType());
+  // Emit as a series of 'note's all template and non-templates identified by
+  // the expression 

Re: [PATCH] D13607: [Fix] Make it an error to take the address of (most) enable_if functions.

2015-10-12 Thread George Burgess IV via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250090: [Sema] Make `_with_enable_if_attrs` an 
error (authored by gbiv).

Changed prior to commit:
  http://reviews.llvm.org/D13607?vs=37075=37152#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13607

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaCast.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/CodeGen/enable_if.c
  cfe/trunk/test/Sema/enable_if.c
  cfe/trunk/test/SemaCXX/enable_if.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -2440,11 +2440,13 @@
 bool PartialOverloading = false);
 
   // Emit as a 'note' the specific overload candidate
-  void NoteOverloadCandidate(FunctionDecl *Fn, QualType DestType = QualType());
+  void NoteOverloadCandidate(FunctionDecl *Fn, QualType DestType = QualType(),
+ bool TakingAddress = false);
 
-  // Emit as a series of 'note's all template and non-templates
-  // identified by the expression Expr
-  void NoteAllOverloadCandidates(Expr* E, QualType DestType = QualType());
+  // Emit as a series of 'note's all template and non-templates identified by
+  // the expression Expr
+  void NoteAllOverloadCandidates(Expr *E, QualType DestType = QualType(),
+ bool TakingAddress = false);
 
   /// Check the enable_if expressions on the given function. Returns the first
   /// failing attribute, or NULL if they were all successful.
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1496,7 +1496,8 @@
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
   "volatile and restrict|const, volatile, and restrict}5 vs "
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}6)}4">;
+  "volatile and restrict|const, volatile, and restrict}6)"
+  "|: cannot take the address of a potentially disabled function}4">;
 
 def err_lvalue_to_rvalue_ref : Error<"rvalue reference %diff{to type $ cannot "
   "bind to lvalue of type $|cannot bind to incompatible lvalue}0,1">;
@@ -2967,7 +2968,8 @@
 "%select{none|const|restrict|const and restrict|volatile|const and volatile"
 "|volatile and restrict|const, volatile, and restrict}3 but found "
 "%select{none|const|restrict|const and restrict|volatile|const and volatile"
-"|volatile and restrict|const, volatile, and restrict}4)}2">;
+"|volatile and restrict|const, volatile, and restrict}4)"
+"| made ineligible by enable_if}2">;
 
 def note_ovl_candidate_inherited_constructor : Note<"inherited from here">;
 def note_ovl_candidate_illegal_constructor : Note<
@@ -5662,7 +5664,8 @@
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
   "volatile and restrict|const, volatile, and restrict}2 vs "
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}3)}1">;
+  "volatile and restrict|const, volatile, and restrict}3)"
+  "|: mismatch in enable_if attributes}1">;
 def warn_using_directive_in_header : Warning<
   "using namespace directive in global context in header">,
   InGroup, DefaultIgnore;
@@ -5899,7 +5902,8 @@
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
   "volatile and restrict|const, volatile, and restrict}5 vs "
   "%select{none|const|restrict|const and restrict|volatile|const and volatile|"
-  "volatile and restrict|const, volatile, and restrict}6)}4">;
+  "volatile and restrict|const, volatile, and restrict}6)"
+  "|: cannot take the address of a potentially disabled function}4">;
 def err_typecheck_missing_return_type_incompatible : Error<
   "%diff{return type $ must match previous return type $|"
   "return type must match previous return type}0,1 when %select{block "
Index: cfe/trunk/test/SemaCXX/enable_if.cpp
===
--- cfe/trunk/test/SemaCXX/enable_if.cpp
+++ cfe/trunk/test/SemaCXX/enable_if.cpp
@@ -163,3 +163,74 @@
 fn3(sizeof(T) == 1);
   }
 }
+
+namespace FnPtrs {
+  int ovlFoo(int m) __attribute__((enable_if(m > 0, "")));
+  int ovlFoo(int m);
+
+  void test() {
+// Assignment gives us a different code path than declarations, and ``
+// gives us a different code path than `foo`
+int (*p)(int) = ovlFoo;
+int (*p2)(int) = 
+int (*a)(int);
+a = ovlFoo;
+a = 
+  }
+
+  int 

Re: [PATCH] D13368: [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast

2015-10-12 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 37155.
mgehre marked an inline comment as done.
mgehre added a comment.

Add test for static_cast with const


http://reviews.llvm.org/D13368

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-static-cast-downcast.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp
@@ -0,0 +1,118 @@
+// RUN: %python %S/check_clang_tidy.py %s cppcoreguidelines-pro-type-static-cast-downcast %t
+
+class Base {
+};
+
+class Derived : public Base {
+};
+
+class Base2 {
+};
+
+class MultiDerived : public Base, public Base2 {
+};
+
+class PolymorphicBase {
+public:
+  virtual ~PolymorphicBase();
+};
+
+class PolymorphicDerived : public PolymorphicBase {
+};
+
+class PolymorphicMultiDerived : public Base, public PolymorphicBase {
+};
+
+void pointers() {
+
+  auto P0 = static_cast(new Base());
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
+
+  const Base* B0;
+  auto PC0 = static_cast(B0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
+
+  auto P1 = static_cast(new Derived()); // OK, upcast to a public base
+  auto P2 = static_cast(new MultiDerived()); // OK, upcast to a public base
+  auto P3 = static_cast(new MultiDerived()); // OK, upcast to a public base
+}
+
+void pointers_polymorphic() {
+
+  auto PP0 = static_cast(new PolymorphicBase());
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-static-cast-downcast]
+  // CHECK-FIXES: auto PP0 = dynamic_cast(new PolymorphicBase());
+
+  const PolymorphicBase* B0;
+  auto PPC0 = static_cast(B0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-static-cast-downcast]
+  // CHECK-FIXES: auto PPC0 = dynamic_cast(B0);
+
+
+  auto B1 = static_cast(new PolymorphicDerived()); // OK, upcast to a public base
+  auto B2 = static_cast(new PolymorphicMultiDerived()); // OK, upcast to a public base
+  auto B3 = static_cast(new PolymorphicMultiDerived()); // OK, upcast to a public base
+}
+
+void arrays() {
+  Base ArrayOfBase[10];
+  auto A0 = static_cast(ArrayOfBase);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
+}
+
+void arrays_polymorphic() {
+  PolymorphicBase ArrayOfPolymorphicBase[10];
+  auto AP0 = static_cast(ArrayOfPolymorphicBase);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead
+  // CHECK-FIXES: auto AP0 = dynamic_cast(ArrayOfPolymorphicBase);
+}
+
+void references() {
+  Base B0;
+  auto R0 = static_cast(B0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
+  Base& RefToBase = B0;
+  auto R1 = static_cast(RefToBase);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
+
+  const Base& ConstRefToBase = B0;
+  auto RC1 = static_cast(ConstRefToBase);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
+
+
+  Derived RD1;
+  auto R2 = static_cast(RD1); // OK, upcast to a public base
+}
+
+void references_polymorphic() {
+  PolymorphicBase B0;
+  auto RP0 = static_cast(B0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead
+  // CHECK-FIXES: auto RP0 = dynamic_cast(B0);
+
+  PolymorphicBase& RefToPolymorphicBase = B0;
+  auto RP1 = static_cast(RefToPolymorphicBase);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use static_cast to downcast from a base to a derived class; 

[libcxxabi] r250097 - Fix Bug 25103 - _cxa_demangle improperly demangles virtual thunks. Thanks to Jason King for the report and suggested fix

2015-10-12 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Oct 12 15:45:05 2015
New Revision: 250097

URL: http://llvm.org/viewvc/llvm-project?rev=250097=rev
Log:
Fix Bug 25103 - _cxa_demangle improperly demangles virtual thunks. Thanks to 
Jason King for the report and suggested fix

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=250097=250096=250097=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Mon Oct 12 15:45:05 2015
@@ -4415,7 +4415,7 @@ parse_special_name(const char* first, co
 {
 if (db.names.empty())
 return first;
-if (first[2] == 'v')
+if (first[1] == 'v')
 {
 db.names.back().first.insert(0, "virtual thunk to ");
 first = t;

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=250097=250096=250097=diff
==
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Mon Oct 12 15:45:05 2015
@@ -29594,6 +29594,8 @@ const char* cases[][2] =
 {"_Zli2_xy", "operator\"\" _x(unsigned long long)"},
 {"_Z1fIiEDcT_", "decltype(auto) f(int)"},
 {"_ZZ4testvEN1g3fooE5Point", "test()::g::foo(Point)"},
+{"_ZThn12_NSt9strstreamD0Ev",   "non-virtual thunk to 
std::strstream::~strstream()"},
+{"_ZTv0_n12_NSt9strstreamD0Ev", "virtual thunk to 
std::strstream::~strstream()"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);


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


[clang-tools-extra] r250098 - [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast

2015-10-12 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Mon Oct 12 15:46:53 2015
New Revision: 250098

URL: http://llvm.org/viewvc/llvm-project?rev=250098=rev
Log:
[clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast

Summary:
This check flags all usages of static_cast, where a base class is casted
to a derived class.
In those cases, a fixit is provided to convert the cast to a
dynamic_cast.

Use of these casts can violate type safety and cause the program to
access a variable that is actually of type X to be accessed as if it
were of an unrelated type Z.

This rule is part of the "Type safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type2-dont-use-static_cast-downcasts-use-dynamic_cast-instead

Depends on D13313

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D13368

Added:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-static-cast-downcast.rst

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=250098=250097=250098=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Mon Oct 
12 15:46:53 2015
@@ -4,6 +4,7 @@ add_clang_library(clangTidyCppCoreGuidel
   CppCoreGuidelinesTidyModule.cpp
   ProTypeConstCastCheck.cpp
   ProTypeReinterpretCastCheck.cpp
+  ProTypeStaticCastDowncastCheck.cpp
 
   LINK_LIBS
   clangAST

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=250098=250097=250098=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Mon Oct 12 15:46:53 2015
@@ -12,6 +12,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "ProTypeConstCastCheck.h"
 #include "ProTypeReinterpretCastCheck.h"
+#include "ProTypeStaticCastDowncastCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -25,6 +26,8 @@ public:
 "cppcoreguidelines-pro-type-const-cast");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-type-reinterpret-cast");
+CheckFactories.registerCheck(
+"cppcoreguidelines-pro-type-static-cast-downcast");
   }
 };
 

Added: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp?rev=250098=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp
 Mon Oct 12 15:46:53 2015
@@ -0,0 +1,52 @@
+//===--- ProTypeStaticCastDowncastCheck.cpp - 
clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ProTypeStaticCastDowncastCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+void ProTypeStaticCastDowncastCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Finder->addMatcher(
+  cxxStaticCastExpr(unless(isInTemplateInstantiation())).bind("cast"),
+  this);
+}
+
+void ProTypeStaticCastDowncastCheck::check(const MatchFinder::MatchResult 
) {
+  const auto *MatchedCast = Result.Nodes.getNodeAs("cast");
+  if (MatchedCast->getCastKind() != CK_BaseToDerived)
+return;
+
+  QualType SourceType = MatchedCast->getSubExpr()->getType();
+  const auto *SourceDecl = SourceType->getPointeeCXXRecordDecl();
+  

Re: [PATCH] D13368: [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast

2015-10-12 Thread Matthias Gehre via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250098: [clang-tidy] add check 
cppcoreguidelines-pro-type-static-cast-downcast (authored by mgehre).

Changed prior to commit:
  http://reviews.llvm.org/D13368?vs=37155=37164#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13368

Files:
  clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.h
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-static-cast-downcast.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp

Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp
@@ -0,0 +1,52 @@
+//===--- ProTypeStaticCastDowncastCheck.cpp - clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ProTypeStaticCastDowncastCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+void ProTypeStaticCastDowncastCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Finder->addMatcher(
+  cxxStaticCastExpr(unless(isInTemplateInstantiation())).bind("cast"),
+  this);
+}
+
+void ProTypeStaticCastDowncastCheck::check(const MatchFinder::MatchResult ) {
+  const auto *MatchedCast = Result.Nodes.getNodeAs("cast");
+  if (MatchedCast->getCastKind() != CK_BaseToDerived)
+return;
+
+  QualType SourceType = MatchedCast->getSubExpr()->getType();
+  const auto *SourceDecl = SourceType->getPointeeCXXRecordDecl();
+  if (!SourceDecl) // The cast is from object to reference
+SourceDecl = SourceType->getAsCXXRecordDecl();
+  if (!SourceDecl)
+return;
+
+  if (SourceDecl->isPolymorphic())
+diag(MatchedCast->getOperatorLoc(),
+ "do not use static_cast to downcast from a base to a derived class; "
+ "use dynamic_cast instead")
+<< FixItHint::CreateReplacement(MatchedCast->getOperatorLoc(),
+"dynamic_cast");
+  else
+diag(MatchedCast->getOperatorLoc(),
+ "do not use static_cast to downcast from a base to a derived class");
+}
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -12,6 +12,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "ProTypeConstCastCheck.h"
 #include "ProTypeReinterpretCastCheck.h"
+#include "ProTypeStaticCastDowncastCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -25,6 +26,8 @@
 "cppcoreguidelines-pro-type-const-cast");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-type-reinterpret-cast");
+CheckFactories.registerCheck(
+"cppcoreguidelines-pro-type-static-cast-downcast");
   }
 };
 
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -4,6 +4,7 @@
   CppCoreGuidelinesTidyModule.cpp
   ProTypeConstCastCheck.cpp
   ProTypeReinterpretCastCheck.cpp
+  ProTypeStaticCastDowncastCheck.cpp
 
   LINK_LIBS
   clangAST
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.h
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.h
@@ -0,0 +1,33 @@
+//===--- ProTypeStaticCastDowncastCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for 

r250099 - Parse and ignore #pragma runtime_checks in MS extensions mode (PR25138)

2015-10-12 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Oct 12 15:47:58 2015
New Revision: 250099

URL: http://llvm.org/viewvc/llvm-project?rev=250099=rev
Log:
Parse and ignore #pragma runtime_checks in MS extensions mode (PR25138)

We already silently ignore the /RTC, which controls the same functionality.

Modified:
cfe/trunk/include/clang/Lex/Pragma.h
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Lex/Pragma.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/test/Preprocessor/pragma_microsoft.c

Modified: cfe/trunk/include/clang/Lex/Pragma.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Pragma.h?rev=250099=250098=250099=diff
==
--- cfe/trunk/include/clang/Lex/Pragma.h (original)
+++ cfe/trunk/include/clang/Lex/Pragma.h Mon Oct 12 15:47:58 2015
@@ -76,7 +76,7 @@ public:
 /// used to ignore particular pragmas.
 class EmptyPragmaHandler : public PragmaHandler {
 public:
-  EmptyPragmaHandler();
+  explicit EmptyPragmaHandler(StringRef Name = StringRef());
 
   void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
 Token ) override;

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=250099=250098=250099=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Oct 12 15:47:58 2015
@@ -163,6 +163,7 @@ class Parser : public CodeCompletionHand
   std::unique_ptr MSConstSeg;
   std::unique_ptr MSCodeSeg;
   std::unique_ptr MSSection;
+  std::unique_ptr MSRuntimeChecks;
   std::unique_ptr OptimizeHandler;
   std::unique_ptr LoopHintHandler;
   std::unique_ptr UnrollHintHandler;

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=250099=250098=250099=diff
==
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Mon Oct 12 15:47:58 2015
@@ -38,7 +38,7 @@ PragmaHandler::~PragmaHandler() {
 // EmptyPragmaHandler Implementation.
 
//===--===//
 
-EmptyPragmaHandler::EmptyPragmaHandler() {}
+EmptyPragmaHandler::EmptyPragmaHandler(StringRef Name) : PragmaHandler(Name) {}
 
 void EmptyPragmaHandler::HandlePragma(Preprocessor , 
   PragmaIntroducerKind Introducer,

Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=250099=250098=250099=diff
==
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Mon Oct 12 15:47:58 2015
@@ -156,6 +156,10 @@ struct PragmaUnrollHintHandler : public
 Token ) override;
 };
 
+struct PragmaMSRuntimeChecksHandler : public EmptyPragmaHandler {
+  PragmaMSRuntimeChecksHandler() : EmptyPragmaHandler("runtime_checks") {}
+};
+
 }  // end namespace
 
 void Parser::initializePragmaHandlers() {
@@ -222,6 +226,8 @@ void Parser::initializePragmaHandlers()
 PP.AddPragmaHandler(MSCodeSeg.get());
 MSSection.reset(new PragmaMSPragma("section"));
 PP.AddPragmaHandler(MSSection.get());
+MSRuntimeChecks.reset(new PragmaMSRuntimeChecksHandler());
+PP.AddPragmaHandler(MSRuntimeChecks.get());
   }
 
   OptimizeHandler.reset(new PragmaOptimizeHandler(Actions));
@@ -288,6 +294,8 @@ void Parser::resetPragmaHandlers() {
 MSCodeSeg.reset();
 PP.RemovePragmaHandler(MSSection.get());
 MSSection.reset();
+PP.RemovePragmaHandler(MSRuntimeChecks.get());
+MSRuntimeChecks.reset();
   }
 
   PP.RemovePragmaHandler("STDC", FPContractHandler.get());

Modified: cfe/trunk/test/Preprocessor/pragma_microsoft.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/pragma_microsoft.c?rev=250099=250098=250099=diff
==
--- cfe/trunk/test/Preprocessor/pragma_microsoft.c (original)
+++ cfe/trunk/test/Preprocessor/pragma_microsoft.c Mon Oct 12 15:47:58 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -Wunknown-pragmas
 // RUN: not %clang_cc1 %s -fms-extensions -E | FileCheck %s
 // REQUIRES: non-ps4-sdk
 
@@ -53,7 +53,7 @@ __pragma(comment(linker," bar=" BAR))
 
 void f()
 {
-  __pragma()
+  __pragma() // expected-warning{{unknown pragma ignored}}
 // CHECK: #pragma
 
   // If we ever actually *support* __pragma(warning(disable: x)),
@@ -159,3 +159,6 @@ void g() {}
 #pragma warning(default 321) // expected-warning {{expected ':'}}
 #pragma warning(asdf : 321) // expected-warning {{expected 'push', 'pop'}}
 #pragma 

Re: [PATCH] D13192: Fix incorrect parsing of arguments for nested functions

2015-10-12 Thread Marshall Clow via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

landed as revision 249649


http://reviews.llvm.org/D13192



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


r250105 - Add warning flags for #include_next and some nearby warnings.

2015-10-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct 12 16:05:54 2015
New Revision: 250105

URL: http://llvm.org/viewvc/llvm-project?rev=250105=rev
Log:
Add warning flags for #include_next and some nearby warnings.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/test/Misc/warning-flags.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=250105=250104=250105=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Oct 12 16:05:54 2015
@@ -202,6 +202,7 @@ def InfiniteRecursion : DiagGroup<"infin
 def GNUImaginaryConstant : DiagGroup<"gnu-imaginary-constant">;
 def IgnoredQualifiers : DiagGroup<"ignored-qualifiers">;
 def : DiagGroup<"import">;
+def GNUIncludeNext : DiagGroup<"gnu-include-next">;
 def IncompatibleMSStruct : DiagGroup<"incompatible-ms-struct">;
 def IncompatiblePointerTypesDiscardsQualifiers 
   : DiagGroup<"incompatible-pointer-types-discards-qualifiers">;
@@ -708,7 +709,8 @@ def GNU : DiagGroup<"gnu", [GNUAlignofEx
 GNUEmptyInitializer, GNUEmptyStruct,
 VLAExtension, GNUFlexibleArrayInitializer,
 GNUFlexibleArrayUnionMember, GNUFoldingConstant,
-GNUImaginaryConstant, GNULabelsAsValue,
+GNUImaginaryConstant, GNUIncludeNext,
+GNULabelsAsValue,
 RedeclaredClassMember, GNURedeclaredEnum,
 GNUStatementExpression, GNUStaticFloatInit,
 GNUStringLiteralOperatorTemplate,

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=250105=250104=250105=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Mon Oct 12 16:05:54 2015
@@ -256,10 +256,13 @@ def err_pp_hash_error : Error<"%0">;
 }
 
 def pp_include_next_in_primary : Warning<
-  "#include_next in primary source file">;
+  "#include_next in primary source file">,
+  InGroup>;
 def pp_include_macros_out_of_predefines : Error<
   "the #__include_macros directive is only for internal use by -imacros">;
-def pp_include_next_absolute_path : Warning<"#include_next with absolute 
path">;
+def pp_include_next_absolute_path : Warning<
+  "#include_next with absolute path">,
+  InGroup>;
 def ext_c99_whitespace_required_after_macro_name : ExtWarn<
   "ISO C99 requires whitespace after the macro name">, InGroup;
 def ext_missing_whitespace_after_macro_name : ExtWarn<
@@ -267,9 +270,11 @@ def ext_missing_whitespace_after_macro_n
 def warn_missing_whitespace_after_macro_name : Warning<
   "whitespace recommended after macro name">;
   
-def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">;
+def pp_pragma_once_in_main_file : Warning<"#pragma once in main file">,
+  InGroup>;
 def pp_pragma_sysheader_in_main_file : Warning<
-  "#pragma system_header ignored in main file">;
+  "#pragma system_header ignored in main file">,
+  InGroup>;
 def pp_poisoning_existing_macro : Warning<"poisoning existing macro">;
 def pp_out_of_date_dependency : Warning<
   "current file is older than dependency %0">;
@@ -316,7 +321,7 @@ def ext_pp_include_search_ms : ExtWarn<
 
 def ext_pp_ident_directive : Extension<"#ident is a language extension">;
 def ext_pp_include_next_directive : Extension<
-  "#include_next is a language extension">;
+  "#include_next is a language extension">, InGroup;
 def ext_pp_warning_directive : Extension<"#warning is a language extension">;
 
 def ext_pp_extra_tokens_at_eol : ExtWarn<

Modified: cfe/trunk/test/Misc/warning-flags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warning-flags.c?rev=250105=250104=250105=diff
==
--- cfe/trunk/test/Misc/warning-flags.c (original)
+++ cfe/trunk/test/Misc/warning-flags.c Mon Oct 12 16:05:54 2015
@@ -18,7 +18,7 @@ This test serves two purposes:
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (89):
+CHECK: Warnings without flags (85):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -35,13 +35,9 @@ CHECK-NEXT:   ext_typecheck_cond_incompa
 CHECK-NEXT:   

[PATCH] D13673: Add initial support for the MUSL C library.

2015-10-12 Thread Vasileios Kalintiris via cfe-commits
vkalintiris created this revision.
vkalintiris added reviewers: mclow.lists, jroelofs, EricWF.
vkalintiris added a subscriber: cfe-commits.
vkalintiris added a dependency: D13407: [libcxx] Capture configuration 
information when installing the libc++ headers.
Herald added subscribers: srhines, danalbert, tberghammer, jfb.

This patch adds the LIBCXX_LIBC_IS_MUSL cmake option to allow the
building of libcxx with the Musl C library. The option is necessary as
Musl does not provide any predefined macro in order to test for its
presence, like GLIBC. Most of the changes specify the correct path to
choose through the various #if/#else constructs in the locale code.

Depends on D13407.

http://reviews.llvm.org/D13673

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in
  include/__locale
  include/support/musl/xlocale.h
  src/locale.cpp

Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -812,7 +812,8 @@
 {
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__NetBSD__) || defined(_LIBCXX_LIBC_IS_MUSL)
 return isascii(c) ? ctype::__classic_upper_table()[c] : c;
 #else
 return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c;
@@ -825,7 +826,8 @@
 for (; low != high; ++low)
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__NetBSD__) || defined(_LIBCXX_LIBC_IS_MUSL)
 *low = isascii(*low) ? ctype::__classic_upper_table()[*low]
  : *low;
 #else
@@ -839,7 +841,8 @@
 {
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__NetBSD_) || defined(_LIBCXX_LIBC_IS_MUSL)
 return isascii(c) ? ctype::__classic_lower_table()[c] : c;
 #else
 return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c;
@@ -852,7 +855,8 @@
 for (; low != high; ++low)
 #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
 *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
+  defined(__NetBSD__) || defined(_LIBCXX_LIBC_IS_MUSL)
 *low = isascii(*low) ? ctype::__classic_lower_table()[*low]
  : *low;
 #else
@@ -921,8 +925,8 @@
   static_cast(_DefaultRuneLocale.__mapupper[static_cast(c)]) : c;
 #elif defined(__NetBSD__)
 return static_cast(__classic_upper_table()[static_cast(c)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
-return isascii(c) ? 
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(_LIBCXX_LIBC_IS_MUSL)
+return isascii(c) ?
   static_cast(__classic_upper_table()[static_cast(c)]) : c;
 #else
 return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c;
@@ -938,7 +942,7 @@
   static_cast(_DefaultRuneLocale.__mapupper[static_cast(*low)]) : *low;
 #elif defined(__NetBSD__)
 *low = static_cast(__classic_upper_table()[static_cast(*low)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(_LIBCXX_LIBC_IS_MUSL)
 *low = isascii(*low) ?
   static_cast(__classic_upper_table()[static_cast(*low)]) : *low;
 #else
@@ -955,7 +959,7 @@
   static_cast(_DefaultRuneLocale.__maplower[static_cast(c)]) : c;
 #elif defined(__NetBSD__)
 return static_cast(__classic_lower_table()[static_cast(c)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(_LIBCXX_LIBC_IS_MUSL)
 return isascii(c) ?
   static_cast(__classic_lower_table()[static_cast(c)]) : c;
 #else
@@ -971,7 +975,7 @@
 *low = isascii(*low) ? static_cast(_DefaultRuneLocale.__maplower[static_cast(*low)]) : *low;
 #elif defined(__NetBSD__)
 *low = static_cast(__classic_lower_table()[static_cast(*low)]);
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__)
+#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(_LIBCXX_LIBC_IS_MUSL)
 *low = isascii(*low) ? static_cast(__classic_lower_table()[static_cast(*low)]) : *low;
 #else
 *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'A'+'a' : *low;
@@ -1012,7 +1016,7 @@
 return low;
 }
 
-#ifdef __EMSCRIPTEN__
+#if defined(__EMSCRIPTEN__) || defined(_LIBCXX_LIBC_IS_MUSL)
 extern 

Re: [PATCH] D12508: [libcxx] Make it drastically simpler to link libc++.

2015-10-12 Thread Richard Smith via cfe-commits
rsmith added a comment.

I think this is a good direction. I used to link libc++abi into libc++, and 
switched to using a hand-rolled linker script a while back. It's been working 
great for me.


http://reviews.llvm.org/D12508



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


Re: [PATCH] D13673: Add initial support for the MUSL C library.

2015-10-12 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

LGTM, with one small nit (and once http://reviews.llvm.org/D13407 lands):



Comment at: src/locale.cpp:1176
@@ -1171,3 +1175,3 @@
 }
-#endif // __GLIBC__ || __EMSCRIPTEN__ || __NETBSD__
+#endif // __GLIBC__ || __NETBSD__ || || __EMSCRIPTEN__ || 
defined(_LIBCXX_LIBC_IS_MUSL)
 

s/|| ||/||/


http://reviews.llvm.org/D13673



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


Re: [PATCH] D13639: Add decayedType and hasDecayedType AST matchers

2015-10-12 Thread Matthias Gehre via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250114: Add decayedType and hasDecayedType AST matchers 
(authored by mgehre).

Changed prior to commit:
  http://reviews.llvm.org/D13639?vs=37066=37178#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13639

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -1244,6 +1244,18 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypedecayedTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1DecayedType.html;>DecayedType...
+Matches decayed type
+Example matches i[] in declaration of f.
+(matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())
+Example matches i[1].
+(matcher = expr(hasType(decayedType(hasDecayedType(pointerType())
+  void f(int i[]) {
+i[1] = 0;
+  }
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypedependentSizedArrayTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html;>DependentSizedArrayType...
 Matches C++ 
arrays whose size is a value-dependent expression.
 
@@ -3565,6 +3577,11 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1DecayedType.html;>DecayedTypehasDecayedTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualType
 InnerType
+Matches the decayed 
type, whos decayed type matches InnerMatcher
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html;>DeclRefExprhasDeclarationMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>Decl  
InnerMatcher
 Matches a node if 
the declaration associated with that node
 matches the given matcher.
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -4123,6 +4123,24 @@
 /// \endcode
 AST_TYPE_MATCHER(InjectedClassNameType, injectedClassNameType);
 
+/// \brief Matches decayed type
+/// Example matches i[] in declaration of f.
+/// (matcher = 
valueDecl(hasType(decayedType(hasDecayedType(pointerType())
+/// Example matches i[1].
+/// (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())
+/// \code
+///   void f(int i[]) {
+/// i[1] = 0;
+///   }
+/// \endcode
+AST_TYPE_MATCHER(DecayedType, decayedType);
+
+/// \brief Matches the decayed type, whos decayed type matches \c InnerMatcher
+AST_MATCHER_P(DecayedType, hasDecayedType, internal::Matcher,
+  InnerType) {
+  return InnerType.matches(Node.getDecayedType(), Finder, Builder);
+}
+
 /// \brief Matches declarations whose declaration context, interpreted as a
 /// Decl, matches \c InnerMatcher.
 ///
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -152,6 +152,7 @@
   REGISTER_MATCHER(cxxThrowExpr);
   REGISTER_MATCHER(cxxTryStmt);
   REGISTER_MATCHER(cxxUnresolvedConstructExpr);
+  REGISTER_MATCHER(decayedType);
   REGISTER_MATCHER(decl);
   REGISTER_MATCHER(declaratorDecl);
   REGISTER_MATCHER(declCountIs);
@@ -199,6 +200,7 @@
   REGISTER_MATCHER(hasCaseConstant);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
+  REGISTER_MATCHER(hasDecayedType);
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -4109,6 +4109,11 @@
   EXPECT_TRUE(matches("const int a = 0;", qualType(isInteger(;
 }
 
+TEST(TypeMatching, DecayedType) {
+  EXPECT_TRUE(matches("void f(int i[]);", 
valueDecl(hasType(decayedType(hasDecayedType(pointerType()));
+  EXPECT_TRUE(notMatches("int i[7];", decayedType()));
+}
+
 TEST(TypeMatching, MatchesComplexTypes) {
   EXPECT_TRUE(matches("_Complex float f;", complexType()));
   EXPECT_TRUE(matches(


Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -1244,6 +1244,18 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypedecayedTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1DecayedType.html;>DecayedType...
+Matches 

r250114 - Add decayedType and hasDecayedType AST matchers

2015-10-12 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Mon Oct 12 16:46:07 2015
New Revision: 250114

URL: http://llvm.org/viewvc/llvm-project?rev=250114=rev
Log:
Add decayedType and hasDecayedType AST matchers

Summary: Add decayedType and hasDecayedType AST matchers

Reviewers: klimek

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D13639

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=250114=250113=250114=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Oct 12 16:46:07 2015
@@ -1244,6 +1244,18 @@ constantArrayType()
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypedecayedTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1DecayedType.html;>DecayedType...
+Matches decayed type
+Example matches i[] in declaration of f.
+(matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())
+Example matches i[1].
+(matcher = expr(hasType(decayedType(hasDecayedType(pointerType())
+  void f(int i[]) {
+i[1] = 0;
+  }
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>TypedependentSizedArrayTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html;>DependentSizedArrayType...
 Matches C++ 
arrays whose size is a value-dependent expression.
 
@@ -3565,6 +3577,11 @@ Example matches a
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1DecayedType.html;>DecayedTypehasDecayedTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualType
 InnerType
+Matches the decayed 
type, whos decayed type matches InnerMatcher
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html;>DeclRefExprhasDeclarationMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>Decl  
InnerMatcher
 Matches a node if 
the declaration associated with that node
 matches the given matcher.

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=250114=250113=250114=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Oct 12 16:46:07 2015
@@ -4123,6 +4123,24 @@ AST_TYPE_MATCHER(TemplateTypeParmType, t
 /// \endcode
 AST_TYPE_MATCHER(InjectedClassNameType, injectedClassNameType);
 
+/// \brief Matches decayed type
+/// Example matches i[] in declaration of f.
+/// (matcher = 
valueDecl(hasType(decayedType(hasDecayedType(pointerType())
+/// Example matches i[1].
+/// (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())
+/// \code
+///   void f(int i[]) {
+/// i[1] = 0;
+///   }
+/// \endcode
+AST_TYPE_MATCHER(DecayedType, decayedType);
+
+/// \brief Matches the decayed type, whos decayed type matches \c InnerMatcher
+AST_MATCHER_P(DecayedType, hasDecayedType, internal::Matcher,
+  InnerType) {
+  return InnerType.matches(Node.getDecayedType(), Finder, Builder);
+}
+
 /// \brief Matches declarations whose declaration context, interpreted as a
 /// Decl, matches \c InnerMatcher.
 ///

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=250114=250113=250114=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Oct 12 16:46:07 2015
@@ -152,6 +152,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(cxxThrowExpr);
   REGISTER_MATCHER(cxxTryStmt);
   REGISTER_MATCHER(cxxUnresolvedConstructExpr);
+  REGISTER_MATCHER(decayedType);
   REGISTER_MATCHER(decl);
   REGISTER_MATCHER(declaratorDecl);
   REGISTER_MATCHER(declCountIs);
@@ -199,6 +200,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasCaseConstant);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
+  REGISTER_MATCHER(hasDecayedType);
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=250114=250113=250114=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon 

r250137 - [modules] Allow the error on importing a C++ module within an extern "C"

2015-10-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct 12 19:39:40 2015
New Revision: 250137

URL: http://llvm.org/viewvc/llvm-project?rev=250137=rev
Log:
[modules] Allow the error on importing a C++ module within an extern "C"
context (but otherwise at the top level) to be disabled, to support use of C++
standard library implementations that (legitimately) mark their 
headers as being C++ headers from C libraries that wrap things in 'extern "C"'
a bit too enthusiastically.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Modules/extern_c.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=250137=250136=250137=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct 12 19:39:40 
2015
@@ -7803,9 +7803,10 @@ def err_module_unimported_use : Error<
 def err_module_unimported_use_multiple : Error<
   "%select{declaration|definition|default argument}0 of %1 must be imported "
   "from one of the following modules before it is required:%2">;
-def err_module_import_in_extern_c : Error<
+def ext_module_import_in_extern_c : ExtWarn<
   "import of C++ module '%0' appears within extern \"C\" language linkage "
-  "specification">;
+  "specification">, DefaultError,
+  InGroup>;
 def note_module_import_in_extern_c : Note<
   "extern \"C\" language linkage specification begins here">;
 def err_module_import_not_at_top_level_fatal : Error<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=250137=250136=250137=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Oct 12 19:39:40 2015
@@ -14424,15 +14424,13 @@ Decl *Sema::ActOnFileScopeAsmDecl(Expr *
 static void checkModuleImportContext(Sema , Module *M,
  SourceLocation ImportLoc,
  DeclContext *DC) {
+  SourceLocation ExternCLoc;
+
   if (auto *LSD = dyn_cast(DC)) {
 switch (LSD->getLanguage()) {
 case LinkageSpecDecl::lang_c:
-  if (!M->IsExternC) {
-S.Diag(ImportLoc, diag::err_module_import_in_extern_c)
-  << M->getFullModuleName();
-S.Diag(LSD->getLocStart(), diag::note_module_import_in_extern_c);
-return;
-  }
+  if (ExternCLoc.isInvalid())
+ExternCLoc = LSD->getLocStart();
   break;
 case LinkageSpecDecl::lang_cxx:
   break;
@@ -14442,11 +14440,16 @@ static void checkModuleImportContext(Sem
 
   while (isa(DC))
 DC = DC->getParent();
+
   if (!isa(DC)) {
 S.Diag(ImportLoc, diag::err_module_import_not_at_top_level_fatal)
 << M->getFullModuleName() << DC;
 S.Diag(cast(DC)->getLocStart(),
diag::note_module_import_not_at_top_level) << DC;
+  } else if (!M->IsExternC && ExternCLoc.isValid()) {
+S.Diag(ImportLoc, diag::ext_module_import_in_extern_c)
+  << M->getFullModuleName();
+S.Diag(ExternCLoc, diag::note_module_import_in_extern_c);
   }
 }
 

Modified: cfe/trunk/test/Modules/extern_c.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/extern_c.cpp?rev=250137=250136=250137=diff
==
--- cfe/trunk/test/Modules/extern_c.cpp (original)
+++ cfe/trunk/test/Modules/extern_c.cpp Mon Oct 12 19:39:40 2015
@@ -9,6 +9,8 @@
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify 
-fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_CXX
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify 
-fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C -DEXTERN_CXX
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify 
-fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C -DNAMESPACE
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify 
-fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C 
-DNO_EXTERN_C_ERROR -Wno-module-import-in-extern-c
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify 
-fmodules-cache-path=%t -I %S/Inputs %s -DCXX_HEADER -DEXTERN_C -DNAMESPACE 
-DNO_EXTERN_C_ERROR -Wno-module-import-in-extern-c
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify 
-fmodules-cache-path=%t -I %S/Inputs -x c %s
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify 
-fmodules-cache-path=%t -I %S/Inputs/elsewhere -I %S/Inputs %s -DEXTERN_C 
-DINDIRECT
 
@@ -36,12 +38,12 @@ extern "C++" {
 
 #include HEADER
 
-#if defined(EXTERN_C) && !defined(EXTERN_CXX) && defined(CXX_HEADER)
-// expected-error@-3 {{import of C++ module 'cxx_library' appears within 
extern "C" language linkage 

r250112 - test: change argument

2015-10-12 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Oct 12 16:19:30 2015
New Revision: 250112

URL: http://llvm.org/viewvc/llvm-project?rev=250112=rev
Log:
test: change argument

This failed on AArch64 due to the type mismatch using int instead of
__builtin_va_list.

Modified:
cfe/trunk/test/CodeGen/Inputs/stdio.h

Modified: cfe/trunk/test/CodeGen/Inputs/stdio.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/stdio.h?rev=250112=250111=250112=diff
==
--- cfe/trunk/test/CodeGen/Inputs/stdio.h (original)
+++ cfe/trunk/test/CodeGen/Inputs/stdio.h Mon Oct 12 16:19:30 2015
@@ -5,5 +5,5 @@ extern int vprintf(const char *format, _
 extern __inline __attribute__((gnu_inline,always_inline)) int
 vprintf(const char *x, __builtin_va_list y)
 {
-  return vfprintf (0, 0, 0);
+  return vfprintf (0, 0, y);
 }


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


Re: [PATCH] D13311: [clang-tidy] Add check cppcoreguidelines-pro-bounds-pointer-arithmetic

2015-10-12 Thread Matthias Gehre via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250116: [clang-tidy] new check 
cppcoreguidelines-pro-bounds-pointer-arithmetic (authored by mgehre).

Changed prior to commit:
  http://reviews.llvm.org/D13311?vs=36564=37183#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13311

Files:
  clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-pointer-arithmetic.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp

Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_library(clangTidyCppCoreGuidelinesModule
   CppCoreGuidelinesTidyModule.cpp
+  ProBoundsPointerArithmeticCheck.cpp
   ProTypeConstCastCheck.cpp
   ProTypeReinterpretCastCheck.cpp
   ProTypeStaticCastDowncastCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
@@ -0,0 +1,34 @@
+//===--- ProBoundsPointerArithmeticCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_POINTER_ARITHMETIC_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_POINTER_ARITHMETIC_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Flags all kinds of pointer arithmetic that have result of pointer type, i.e.
+/// +, -, +=, -=, ++, --. In addition, the [] operator on pointers (not on arrays) is flagged.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-bounds-pointer-arithmetic.html
+class ProBoundsPointerArithmeticCheck : public ClangTidyCheck {
+public:
+  ProBoundsPointerArithmeticCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_POINTER_ARITHMETIC_H
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
@@ -0,0 +1,53 @@
+//===--- ProBoundsPointerArithmeticCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ProBoundsPointerArithmeticCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  // Flag all operators +, -, +=, -=, ++, -- that result in a pointer
+  Finder->addMatcher(
+  binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-"),
+   hasOperatorName("+="), hasOperatorName("-=")),
+ hasType(pointerType()))
+  .bind("expr"),
+  this);
+
+  Finder->addMatcher(
+  unaryOperator(anyOf(hasOperatorName("++"), hasOperatorName("--")),
+hasType(pointerType()))
+  .bind("expr"),
+  this);
+
+  // Array subscript on a pointer (not an array) is also pointer arithmetic
+  Finder->addMatcher(
+  arraySubscriptExpr(hasBase(ignoringImpCasts(anyOf(hasType(pointerType()),
+ 

[clang-tools-extra] r250116 - [clang-tidy] new check cppcoreguidelines-pro-bounds-pointer-arithmetic

2015-10-12 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Mon Oct 12 16:53:19 2015
New Revision: 250116

URL: http://llvm.org/viewvc/llvm-project?rev=250116=rev
Log:
[clang-tidy] new check cppcoreguidelines-pro-bounds-pointer-arithmetic

Summary:
This check flags all usage of pointer arithmetic, because it could lead
to an
invalid pointer.
Subtraction of two pointers is not flagged by this check.

Pointers should only refer to single objects, and pointer arithmetic is
fragile and easy to get wrong. array_view is a bounds-checked, safe type
for accessing arrays of data.

This rule is part of the "Bounds safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds1-dont-use-pointer-arithmetic-use-array_view-instead

Depends on D13313

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D13311

Added:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-pointer-arithmetic.rst

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=250116=250115=250116=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Mon Oct 
12 16:53:19 2015
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCppCoreGuidelinesModule
   CppCoreGuidelinesTidyModule.cpp
+  ProBoundsPointerArithmeticCheck.cpp
   ProTypeConstCastCheck.cpp
   ProTypeReinterpretCastCheck.cpp
   ProTypeStaticCastDowncastCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=250116=250115=250116=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Mon Oct 12 16:53:19 2015
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "ProBoundsPointerArithmeticCheck.h"
 #include "ProTypeConstCastCheck.h"
 #include "ProTypeReinterpretCastCheck.h"
 #include "ProTypeStaticCastDowncastCheck.h"
@@ -22,6 +23,8 @@ namespace cppcoreguidelines {
 class CppCoreGuidelinesModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"cppcoreguidelines-pro-bounds-pointer-arithmetic");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-type-const-cast");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp?rev=250116=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
 Mon Oct 12 16:53:19 2015
@@ -0,0 +1,53 @@
+//===--- ProBoundsPointerArithmeticCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ProBoundsPointerArithmeticCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  // Flag all operators +, -, +=, -=, ++, -- that result in a pointer
+  Finder->addMatcher(
+  binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-"),
+   hasOperatorName("+="), hasOperatorName("-=")),
+ 

Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-10-12 Thread Richard Smith via cfe-commits
rsmith added a comment.

Thanks, this essentially looks good to me. I can't think of any other cases 
where C++ allows `auto` that you've not covered.



Comment at: lib/Sema/SemaExprCXX.cpp:1172-1173
@@ -1171,1 +1171,4 @@
 
+  if (D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_auto_type)
+  return ExprError(Diag(StartLoc, diag::err_new_auto_type));
+

How about instead handling this...


Comment at: lib/Sema/SemaType.cpp:2687
@@ -2682,3 +2686,3 @@
 case Declarator::ConditionContext:
 case Declarator::CXXNewContext:
   break;

... here.


http://reviews.llvm.org/D12686



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


Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-10-12 Thread Nicholas Allegra via cfe-commits
comex updated the summary for this revision.
comex updated this revision to Diff 37202.
comex marked 3 inline comments as done.
comex added a comment.

Fixed raised issues.

(I don't have commit rights.)


http://reviews.llvm.org/D12686

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseObjc.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp
  test/Sema/auto-type.c
  test/Sema/bitfield.c
  test/Sema/exprs.c
  test/SemaCXX/auto-type-from-cxx.cpp

Index: test/SemaCXX/auto-type-from-cxx.cpp
===
--- /dev/null
+++ test/SemaCXX/auto-type-from-cxx.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
+
+struct A {
+operator __auto_type() {} // expected-error {{'__auto_type' not allowed in conversion function type}}
+};
+
+__auto_type a() -> int; // expected-error {{function with trailing return type must specify return type 'auto', not '__auto_type'}}
+template 
+__auto_type b() { return T::x; } // expected-error {{'__auto_type' not allowed in function return type}}
+auto c() -> __auto_type { __builtin_unreachable(); } // expected-error {{'__auto_type' not allowed in function return type}}
+int d() {
+  decltype(__auto_type) e = 1; // expected-error {{expected expression}}
+  auto _ = [](__auto_type f) {}; // expected-error {{'__auto_type' not allowed in lambda parameter}}
+  __auto_type g = 2;
+  struct BitField { int field:2; };
+  __auto_type h = BitField{1}.field; // (should work from C++)
+  new __auto_type; // expected-error {{cannot use '__auto_type' as 'new' type}}
+}
+
Index: test/Sema/exprs.c
===
--- test/Sema/exprs.c
+++ test/Sema/exprs.c
@@ -97,6 +97,7 @@
   R = __alignof(P->x);  // expected-error {{invalid application of 'alignof' to bit-field}}
   R = __alignof(P->y);   // ok.
   R = sizeof(P->x); // expected-error {{invalid application of 'sizeof' to bit-field}}
+  __extension__ ({ R = (__typeof__(P->x)) 2; }); // expected-error {{invalid application of 'typeof' to bit-field}}
   return R;
 }
 
Index: test/Sema/bitfield.c
===
--- test/Sema/bitfield.c
+++ test/Sema/bitfield.c
@@ -63,7 +63,8 @@
 typedef signed Signed;
 
 struct Test5 { unsigned n : 2; } t5;
-typedef __typeof__(t5.n) Unsigned; // Bitfield is unsigned
+// Bitfield is unsigned
+struct Test5 sometest5 = {-1}; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -1 to 3}}
 typedef __typeof__(+t5.n) Signed;  // ... but promotes to signed.
 
 typedef __typeof__(t5.n + 0) Signed; // Arithmetic promotes.
Index: test/Sema/auto-type.c
===
--- /dev/null
+++ test/Sema/auto-type.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -std=c11
+
+__auto_type a = 5; // expected-warning {{'__auto_type' is a GNU extension}}
+__extension__ __auto_type a1 = 5;
+#pragma clang diagnostic ignored "-Wgnu-auto-type"
+__auto_type b = 5.0;
+__auto_type c = 
+__auto_type d = (struct {int a;}) {5};
+_Static_assert(__builtin_types_compatible_p(__typeof(a), int), "");
+__auto_type e = e; // expected-error {{variable 'e' declared with '__auto_type' type cannot appear in its own initializer}}
+
+struct s { __auto_type a; }; // expected-error {{'__auto_type' not allowed in struct member}}
+
+__auto_type f = 1, g = 1.0; // expected-error {{'__auto_type' deduced as 'int' in declaration of 'f' and deduced as 'double' in declaration of 'g'}}
+
+__auto_type h() {} // expected-error {{'__auto_type' not allowed in function return type}}
+
+int i() {
+  struct bitfield { int field:2; };
+  __auto_type j = (struct bitfield){1}.field; // expected-error {{cannot pass bit-field as __auto_type initializer in C}}
+
+}
Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp
@@ -3,9 +3,9 @@
 
 // FIXME: This is in p11 (?) in C++1y.
 void f() {
-  

Re: [PATCH] D13640: [clang-tidy] Add new check cppcoreguidelines-pro-bounds-array-to-pointer-decay

2015-10-12 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: 
clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:29
@@ +28,3 @@
+  implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
+   
unless(hasSourceExpression(declRefExpr(to(varDecl(hasName("__range")),
+   unless(hasSourceExpression(stringLiteral()))

__range is an implementation detail and should not be used here.
Check that this is the range init of a cxxForRangeStmt parent node or something 
like that.


Comment at: 
test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp:12
@@ +11,3 @@
+  pointerfun((int*)a);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: do not (implicitly) convert an 
array to a pointer
+  arrayfun(a);

this is not implicit. Is the 'implicit' optional?


http://reviews.llvm.org/D13640



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


Re: [PATCH] D12922: Add support for function attribute "notail"

2015-10-12 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 37172.
ahatanak added a comment.

I've made some changes following the discussion I had and the feedback I got on 
the llvm-side patch.

This is the link to the discussion thread:
http://thread.gmane.org/gmane.comp.compilers.llvm.cvs/271105/

The difference between the previous patch and this patch lies in the way 
indirect calls (at the source level) are handled. The approach taken in the 
previous patch attached the notail attribute to the declaration or definition 
of functions in the IR, which enabled blocking tail call optimization on an 
indirect call site if the compiler could statically determine it was calling a 
function marked notail. In this patch, clang marks a call instruction in the IR 
as notail only if it is a direct call to a function marked "notail". It does 
nothing to prevent tail call on indirect call sites.

I think there are a couple of things that have to be discussed:

1. Name of the attribute: Should it be "notail" or "notailcall"? Perhaps it 
should be named something like "nodirecttail" to indicate it is used to block 
direct calls, but not indirect calls?

2. Can we guarantee or promise that the attribute will *always* block direct 
calls (but do nothing for indirect calls)? Or should we say this attribute only 
prevents tail call (even for direct calls) on a best effort basis in case it 
turns out there are cases where it isn't possible to keep that promise?


http://reviews.llvm.org/D12922

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/attr-no-tail.c
  test/Sema/attr-notail.c

Index: test/Sema/attr-notail.c
===
--- /dev/null
+++ test/Sema/attr-notail.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int callee() __attribute__((notail,always_inline)); // expected-error{{'notail' and 'always_inline' attributes are not compatible}}
+
+int foo() {
+  return callee();
+}
Index: test/CodeGen/attr-no-tail.c
===
--- /dev/null
+++ test/CodeGen/attr-no-tail.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: %{{[a-z0-9]+}} = notail call i32 @callee0(i32 %
+// CHECK: %{{[a-z0-9]+}} = notail call i32 @callee1(i32 %
+
+// Check that indirect calls do not have the notail marker.
+// CHECK: store i32 (i32)* @callee1, i32 (i32)** [[ALLOCA1:%[A-Za-z0-9]+]], align 8
+// CHECK: [[INDIRFUNC:%[0-9]+]] = load i32 (i32)*, i32 (i32)** [[ALLOCA1]], align 8
+// CHECK: %{{[a-z0-9]+}} = call i32 [[INDIRFUNC]](i32 %6)
+
+// CHECK: %{{[a-z0-9]+}} = call i32 @callee2(i32 %
+
+int callee0(int a) __attribute__((notail)) {
+  return a + 1;
+}
+
+int callee1(int) __attribute__((notail));
+
+int callee2(int);
+
+typedef int (*FuncTy)(int);
+
+int foo0(int a) {
+  if (a > 1)
+return callee0(a);
+  if (a == 1)
+return callee1(a);
+  if (a < 0) {
+FuncTy F = callee1;
+return (*F)(a);
+  }
+  return callee2(a);
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1701,6 +1701,14 @@
Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleNoTailAttr(Sema , Decl *D, const AttributeList ) {
+  if (checkAttrMutualExclusion(S, D, Attr))
+return;
+
+  D->addAttr(::new (S.Context) NoTailAttr(
+  Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+}
+
 static void handleUsedAttr(Sema , Decl *D, const AttributeList ) {
   if (const VarDecl *VD = dyn_cast(D)) {
 if (VD->hasLocalStorage()) {
@@ -4907,6 +4915,9 @@
   case AttributeList::AT_ReturnsTwice:
 handleSimpleAttribute(S, D, Attr);
 break;
+  case AttributeList::AT_NoTail:
+handleNoTailAttr(S, D, Attr);
+break;
   case AttributeList::AT_Used:
 handleUsedAttr(S, D, Attr);
 break;
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -3492,6 +3492,10 @@
   // lexical order, so deactivate it and run it manually here.
   CallArgs.freeArgumentMemory(*this);
 
+  if (llvm::CallInst *Call = dyn_cast(CI))
+if (TargetDecl && TargetDecl->hasAttr())
+  Call->setTailCallKind(llvm::CallInst::TCK_NoTail);
+
   RValue Ret = [&] {
 switch (RetAI.getKind()) {
 case ABIArgInfo::InAlloca:
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -1612,3 +1612,10 @@
 arguments, with arbitrary offsets.
   }];
 }
+
+def NoTailDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Tail call optimization is not performed on direct calls to a function marked ``notail``.
+  

Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-10-12 Thread Nicholas Allegra via cfe-commits
comex marked 5 inline comments as done.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1726
@@ -1720,1 +1725,3 @@
+def err_auto_bitfield : Error<
+  "cannot pass bit-field as __auto_type initializer in C">;
 

rsmith wrote:
> pass -> use
> 
> Also, why not? Just because GCC messes this up, doesn't mean we have to.
By analogy with the standards-defined inability to use sizeof on bit fields, it 
made sense to me to do what GCC does and forbid getting their type in other 
ways.  Though I suppose the restriction is somewhat questionable in the first 
place.


Comment at: lib/AST/ItaniumMangle.cpp:2557-2558
@@ -2557,1 +2556,4 @@
+  if (D.isNull()) {
+assert(T->getKeyword() != AutoTypeKeyword::GNUAutoType &&
+   "shouldn't need to mangle __auto_type!");
 Out << (T->isDecltypeAuto() ? "Dc" : "Da");

rsmith wrote:
> Why not?
> 
>   template void f(decltype(new __auto_type(T(;
> 
> ... would need a mangling, right? (Or do you prohibit `__auto_type` there?)
Since my goal is to only allow `__auto_type` in C-compatible contexts, this 
should be prohibited, but wasn't.  Fixed.  (Any other cases I haven't thought 
of?)


Comment at: lib/Parse/ParseDeclCXX.cpp:1119
@@ -1118,2 +1118,3 @@
   case tok::kw_auto:// struct foo {...} auto  x;
+  case tok::kw___auto_type: // struct foo {...} __auto_type x;
   case tok::kw_mutable: // struct foo {...} mutable   x;

rsmith wrote:
> That would be ill-formed; revert this change.
Fixed.  Durr.


Comment at: lib/Sema/SemaType.cpp:1457
@@ -1455,3 +1456,3 @@
 // being analyzed (which tracks the invented type template parameter).
 if (declarator.getContext() == Declarator::LambdaExprParameterContext) {
   sema::LambdaScopeInfo *LSI = S.getCurLambda();

rsmith wrote:
> Should we really allow using `__auto_type` to introduce a generic lambda? It 
> seems like there's a major open design question here: either we should allow 
> `__auto_type` only in GCC-compatible contexts (that is, as a decl-specifier 
> that's not a function return type), or we should allow it everywhere we allow 
> `auto` and make it a synonym for `auto` in C++ (in which case it needs to be 
> mangled, and the distinction between `auto` and `__auto_type` should probably 
> not affect the canonical type).
My goal was to do the former; if you'd prefer to just make it a synonym.  In 
this case, the patch prevents `__auto_type` from being used in lambda 
parameters elsewhere.


http://reviews.llvm.org/D12686



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


r250140 - [modules] Improve error message on failed module load due to a missing file to

2015-10-12 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct 12 20:26:26 2015
New Revision: 250140

URL: http://llvm.org/viewvc/llvm-project?rev=250140=rev
Log:
[modules] Improve error message on failed module load due to a missing file to
say which module file referenced the missing file.

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=250140=250139=250140=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Oct 12 20:26:26 2015
@@ -1948,7 +1948,9 @@ InputFile ASTReader::getInputFile(Module
 if (Complain) {
   std::string ErrorStr = "could not find file '";
   ErrorStr += Filename;
-  ErrorStr += "' referenced by AST file";
+  ErrorStr += "' referenced by AST file '";
+  ErrorStr += F.FileName;
+  ErrorStr += "'";
   Error(ErrorStr.c_str());
 }
 // Record that we didn't find the file.


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


r250111 - test: relax path matching for windows

2015-10-12 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Oct 12 16:19:27 2015
New Revision: 250111

URL: http://llvm.org/viewvc/llvm-project?rev=250111=rev
Log:
test: relax path matching for windows

The test failed on Windows due to use of \ as a path separator rather than /.

Modified:
cfe/trunk/test/CodeGen/debug-prefix-map.c

Modified: cfe/trunk/test/CodeGen/debug-prefix-map.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-prefix-map.c?rev=250111=250110=250111=diff
==
--- cfe/trunk/test/CodeGen/debug-prefix-map.c (original)
+++ cfe/trunk/test/CodeGen/debug-prefix-map.c Mon Oct 12 16:19:27 2015
@@ -16,19 +16,19 @@ void test_rewrite_includes() {
   vprintf("string", argp);
 }
 
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty/"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty/{{.*}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty/Inputs/stdio.h"
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{[/\\]}}"
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}"
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/var/empty{{[/\\]}}Inputs/stdio.h"
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
-// CHECK-EVIL: !DIFile(filename: "/var=empty/{{.*}}"
-// CHECK-EVIL: !DIFile(filename: "/var=empty/Inputs/stdio.h"
+// CHECK-EVIL: !DIFile(filename: "/var=empty{{[/\\]}}{{.*}}"
+// CHECK-EVIL: !DIFile(filename: "/var=empty{{[/\\]}}Inputs/stdio.h"
 // CHECK-EVIL-NOT: !DIFile(filename:
 
-// CHECK: !DIFile(filename: "/var/empty/{{.*}}"
-// CHECK: !DIFile(filename: "/var/empty/Inputs/stdio.h"
+// CHECK: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}"
+// CHECK: !DIFile(filename: "/var/empty{{[/\\]}}Inputs/stdio.h"
 // CHECK-NOT: !DIFile(filename:
 
-// CHECK-COMPILATION-DIR: !DIFile(filename: "/var/empty/{{.*}}", directory: 
"/var/empty")
-// CHECK-COMPILATION-DIR: !DIFile(filename: "/var/empty/Inputs/stdio.h", 
directory: "/var/empty")
+// CHECK-COMPILATION-DIR: !DIFile(filename: "/var/empty{{[/\\]}}{{.*}}", 
directory: "/var/empty")
+// CHECK-COMPILATION-DIR: !DIFile(filename: 
"/var/empty{{[/\\]}}Inputs/stdio.h", directory: "/var/empty")
 // CHECK-COMPILATION-DIR-NOT: !DIFile(filename:


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


Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-10-12 Thread Nicholas Allegra via cfe-commits
comex updated this revision to Diff 37215.
comex added a comment.

Okay.


http://reviews.llvm.org/D12686

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseObjc.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp
  test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp
  test/Sema/auto-type.c
  test/Sema/bitfield.c
  test/Sema/exprs.c
  test/SemaCXX/auto-type-from-cxx.cpp

Index: test/SemaCXX/auto-type-from-cxx.cpp
===
--- /dev/null
+++ test/SemaCXX/auto-type-from-cxx.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
+
+struct A {
+operator __auto_type() {} // expected-error {{'__auto_type' not allowed in conversion function type}}
+};
+
+__auto_type a() -> int; // expected-error {{function with trailing return type must specify return type 'auto', not '__auto_type'}}
+template 
+__auto_type b() { return T::x; } // expected-error {{'__auto_type' not allowed in function return type}}
+auto c() -> __auto_type { __builtin_unreachable(); } // expected-error {{'__auto_type' not allowed in function return type}}
+int d() {
+  decltype(__auto_type) e = 1; // expected-error {{expected expression}}
+  auto _ = [](__auto_type f) {}; // expected-error {{'__auto_type' not allowed in lambda parameter}}
+  __auto_type g = 2;
+  struct BitField { int field:2; };
+  __auto_type h = BitField{1}.field; // (should work from C++)
+  new __auto_type; // expected-error {{'__auto_type' not allowed in 'new' argument}}
+}
+
Index: test/Sema/exprs.c
===
--- test/Sema/exprs.c
+++ test/Sema/exprs.c
@@ -97,6 +97,7 @@
   R = __alignof(P->x);  // expected-error {{invalid application of 'alignof' to bit-field}}
   R = __alignof(P->y);   // ok.
   R = sizeof(P->x); // expected-error {{invalid application of 'sizeof' to bit-field}}
+  __extension__ ({ R = (__typeof__(P->x)) 2; }); // expected-error {{invalid application of 'typeof' to bit-field}}
   return R;
 }
 
Index: test/Sema/bitfield.c
===
--- test/Sema/bitfield.c
+++ test/Sema/bitfield.c
@@ -63,7 +63,8 @@
 typedef signed Signed;
 
 struct Test5 { unsigned n : 2; } t5;
-typedef __typeof__(t5.n) Unsigned; // Bitfield is unsigned
+// Bitfield is unsigned
+struct Test5 sometest5 = {-1}; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -1 to 3}}
 typedef __typeof__(+t5.n) Signed;  // ... but promotes to signed.
 
 typedef __typeof__(t5.n + 0) Signed; // Arithmetic promotes.
Index: test/Sema/auto-type.c
===
--- /dev/null
+++ test/Sema/auto-type.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -std=c11
+
+__auto_type a = 5; // expected-warning {{'__auto_type' is a GNU extension}}
+__extension__ __auto_type a1 = 5;
+#pragma clang diagnostic ignored "-Wgnu-auto-type"
+__auto_type b = 5.0;
+__auto_type c = 
+__auto_type d = (struct {int a;}) {5};
+_Static_assert(__builtin_types_compatible_p(__typeof(a), int), "");
+__auto_type e = e; // expected-error {{variable 'e' declared with '__auto_type' type cannot appear in its own initializer}}
+
+struct s { __auto_type a; }; // expected-error {{'__auto_type' not allowed in struct member}}
+
+__auto_type f = 1, g = 1.0; // expected-error {{'__auto_type' deduced as 'int' in declaration of 'f' and deduced as 'double' in declaration of 'g'}}
+
+__auto_type h() {} // expected-error {{'__auto_type' not allowed in function return type}}
+
+int i() {
+  struct bitfield { int field:2; };
+  __auto_type j = (struct bitfield){1}.field; // expected-error {{cannot pass bit-field as __auto_type initializer in C}}
+
+}
Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp
===
--- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp
+++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp
@@ -3,9 +3,9 @@
 
 // FIXME: This is in p11 (?) in C++1y.
 void f() {
-  decltype(auto) a = a; // expected-error{{variable 'a' declared with 'auto' type cannot appear in its own initializer}}
-  if (decltype(auto) b = b) {} // 

r250149 - [X86] LLVM now prints XOP immediates as unsigned after r250147. Fix expected check string accordingly.

2015-10-12 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue Oct 13 00:15:17 2015
New Revision: 250149

URL: http://llvm.org/viewvc/llvm-project?rev=250149=rev
Log:
[X86] LLVM now prints XOP immediates as unsigned after r250147. Fix expected 
check string accordingly.

Modified:
cfe/trunk/test/CodeGen/xop-builtins.c

Modified: cfe/trunk/test/CodeGen/xop-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xop-builtins.c?rev=250149=250148=250149=diff
==
--- cfe/trunk/test/CodeGen/xop-builtins.c (original)
+++ cfe/trunk/test/CodeGen/xop-builtins.c Tue Oct 13 00:15:17 2015
@@ -225,7 +225,7 @@ __m128i test_mm_roti_epi16(__m128i a) {
 
 __m128i test_mm_roti_epi32(__m128i a) {
   // CHECK: @llvm.x86.xop.vprotdi
-  // CHECK-ASM: vprotd $-30, %xmm{{.*}}, %xmm{{.*}}
+  // CHECK-ASM: vprotd $226, %xmm{{.*}}, %xmm{{.*}}
   return _mm_roti_epi32(a, -30);
 }
 


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