Re: [PATCH] D18221: [Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TS

2016-04-08 Thread Nathan Wilson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL265868: [Concepts] Implement subsection [dcl.spec.concept]p7 
of the Concepts TS (authored by nwilson).

Changed prior to commit:
  http://reviews.llvm.org/D18221?vs=53103=53110#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18221

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp

Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp
@@ -6920,6 +6920,15 @@
   // Ignore access information;  it doesn't figure into redeclaration checking.
   FunctionDecl *Specialization = cast(*Result);
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+  // an explicit specialization (14.8.3) [...] of a concept definition.
+  if (Specialization->getPrimaryTemplate()->isConcept()) {
+Diag(FD->getLocation(), diag::err_concept_specialized)
+<< 0 /*function*/ << 1 /*explicitly specialized*/;
+Diag(Specialization->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   FunctionTemplateSpecializationInfo *SpecInfo
 = Specialization->getTemplateSpecializationInfo();
   assert(SpecInfo && "Function template specialization info missing?");
@@ -7774,6 +7783,15 @@
 return true;
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (PrevTemplate->isConcept()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_specialized)
+<< 1 /*variable*/ << 0 /*explicitly instantiated*/;
+Diag(PrevTemplate->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   // Translate the parser's template argument list into our AST format.
   TemplateArgumentListInfo TemplateArgs =
   makeTemplateArgumentListInfo(*this, *D.getName().TemplateId);
@@ -7988,6 +8006,16 @@
  diag::ext_explicit_instantiation_without_qualified_id)
 << Specialization << D.getCXXScopeSpec().getRange();
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (FunTmpl && FunTmpl->isConcept() &&
+  !D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_specialized)
+<< 0 /*function*/ << 0 /*explicitly instantiated*/;
+Diag(FunTmpl->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   CheckExplicitInstantiationScope(*this,
FunTmpl? (NamedDecl *)FunTmpl
   : Specialization->getInstantiatedFromMemberFunction(),
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6285,6 +6285,25 @@
 if (!IsVariableTemplateSpecialization)
   D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous));
 
+// C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+// an explicit specialization (14.8.3) or a partial specialization of a
+// concept definition.
+if (IsVariableTemplateSpecialization &&
+!D.getDeclSpec().isConceptSpecified() && !Previous.empty() &&
+Previous.isSingleResult()) {
+  NamedDecl *PreviousDecl = Previous.getFoundDecl();
+  if (VarTemplateDecl *VarTmpl = dyn_cast(PreviousDecl)) {
+if (VarTmpl->isConcept()) {
+  Diag(NewVD->getLocation(), diag::err_concept_specialized)
+  << 1/*variable*/
+  << (IsPartialSpecialization ? 2 /*partially specialized*/
+  : 1 /*explicitly specialized*/);
+  Diag(VarTmpl->getLocation(), diag::note_previous_declaration);
+  NewVD->setInvalidDecl();
+}
+  }
+}
+
 if (NewTemplate) {
   VarTemplateDecl *PrevVarTemplate =
   NewVD->getPreviousDecl()
@@ -7823,6 +7842,8 @@
   if (isFunctionTemplateSpecialization) {
 Diag(D.getDeclSpec().getConceptSpecLoc(),
  diag::err_concept_specified_specialization) << 1;
+NewFD->setInvalidDecl(true);
+return NewFD;
   }
 }
 
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2098,6 +2098,9 @@
 def err_concept_specified_specialization : Error<
   "'concept' cannot be applied on an "
   "%select{explicit instantiation|explicit specialization|partial specialization}0">;
+def 

r265868 - [Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TS

2016-04-08 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Fri Apr  8 21:55:27 2016
New Revision: 265868

URL: http://llvm.org/viewvc/llvm-project?rev=265868=rev
Log:
[Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TS

Summary: A program shall not declare an explicit instantiation (14.8.2), an 
explicit specialization (14.8.3), or a partial specialization of a concept 
definition.

Reviewers: rsmith, hubert.reinterpretcast, faisalv, aaron.ballman

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=265868=265867=265868=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr  8 21:55:27 
2016
@@ -2098,6 +2098,9 @@ def err_variable_concept_bool_decl : Err
 def err_concept_specified_specialization : Error<
   "'concept' cannot be applied on an "
   "%select{explicit instantiation|explicit specialization|partial 
specialization}0">;
+def err_concept_specialized : Error<
+  "%select{function|variable}0 concept cannot be "
+  "%select{explicitly instantiated|explicitly specialized|partially 
specialized}1">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=265868=265867=265868=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Apr  8 21:55:27 2016
@@ -6285,6 +6285,25 @@ Sema::ActOnVariableDeclarator(Scope *S,
 if (!IsVariableTemplateSpecialization)
   D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous));
 
+// C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+// an explicit specialization (14.8.3) or a partial specialization of a
+// concept definition.
+if (IsVariableTemplateSpecialization &&
+!D.getDeclSpec().isConceptSpecified() && !Previous.empty() &&
+Previous.isSingleResult()) {
+  NamedDecl *PreviousDecl = Previous.getFoundDecl();
+  if (VarTemplateDecl *VarTmpl = dyn_cast(PreviousDecl)) {
+if (VarTmpl->isConcept()) {
+  Diag(NewVD->getLocation(), diag::err_concept_specialized)
+  << 1/*variable*/
+  << (IsPartialSpecialization ? 2 /*partially specialized*/
+  : 1 /*explicitly specialized*/);
+  Diag(VarTmpl->getLocation(), diag::note_previous_declaration);
+  NewVD->setInvalidDecl();
+}
+  }
+}
+
 if (NewTemplate) {
   VarTemplateDecl *PrevVarTemplate =
   NewVD->getPreviousDecl()
@@ -7823,6 +7842,8 @@ Sema::ActOnFunctionDeclarator(Scope *S,
   if (isFunctionTemplateSpecialization) {
 Diag(D.getDeclSpec().getConceptSpecLoc(),
  diag::err_concept_specified_specialization) << 1;
+NewFD->setInvalidDecl(true);
+return NewFD;
   }
 }
 

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=265868=265867=265868=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Apr  8 21:55:27 2016
@@ -6920,6 +6920,15 @@ bool Sema::CheckFunctionTemplateSpeciali
   // Ignore access information;  it doesn't figure into redeclaration checking.
   FunctionDecl *Specialization = cast(*Result);
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+  // an explicit specialization (14.8.3) [...] of a concept definition.
+  if (Specialization->getPrimaryTemplate()->isConcept()) {
+Diag(FD->getLocation(), diag::err_concept_specialized)
+<< 0 /*function*/ << 1 /*explicitly specialized*/;
+Diag(Specialization->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   FunctionTemplateSpecializationInfo *SpecInfo
 = Specialization->getTemplateSpecializationInfo();
   assert(SpecInfo && "Function template specialization info missing?");
@@ -7774,6 +7783,15 @@ DeclResult Sema::ActOnExplicitInstantiat
 return true;
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (PrevTemplate->isConcept()) {
+Diag(D.getIdentifierLoc(), 

Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-04-08 Thread Weiming Zhao via cfe-commits
weimingz updated this revision to Diff 53105.
weimingz added a comment.

per Alex's suggestion, split into 2 flags:
-ffile-macro-prefix-to-remove=xxx : remove matched prefix
-ffile-macro-basename-only  : remove the whole dir part


http://reviews.llvm.org/D17741

Files:
  include/clang/Driver/Options.td
  include/clang/Lex/PreprocessorOptions.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/PPMacroExpansion.cpp

Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -12,7 +12,6 @@
 //
 //===--===//
 
-#include "clang/Lex/Preprocessor.h"
 #include "clang/Basic/Attributes.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
@@ -22,12 +21,15 @@
 #include "clang/Lex/LexDiagnostic.h"
 #include "clang/Lex/MacroArgs.h"
 #include "clang/Lex/MacroInfo.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1595,7 +1597,7 @@
 PLoc = SourceMgr.getPresumedLoc(NextLoc);
 if (PLoc.isInvalid())
   break;
-
+
 NextLoc = PLoc.getIncludeLoc();
   }
 }
@@ -1603,7 +1605,18 @@
 // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
 SmallString<128> FN;
 if (PLoc.isValid()) {
-  FN += PLoc.getFilename();
+  StringRef Filename(PLoc.getFilename());
+  if (II == Ident__FILE__) {
+const std::string  =
+getPreprocessorOpts().__FILE__PrefixToRemove;
+if (getPreprocessorOpts().__FILE__BasenameOnly)
+  FN += llvm::sys::path::filename(Filename);
+else if (!PrefixToRemove.empty() && Filename.startswith(PrefixToRemove))
+  FN += Filename.substr(PrefixToRemove.size());
+else
+  FN += Filename;
+  } else
+FN += Filename;
   Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2010,6 +2010,14 @@
 else
   Opts.ObjCXXARCStandardLibrary = (ObjCXXARCStandardLibraryKind)Library;
   }
+
+  if (Arg *A =
+  Args.getLastArg(OPT_FILE_prefix_to_remove, OPT_FILE_basename_only)) {
+if (A->getOption().matches(options::OPT_FILE_basename_only))
+  Opts.__FILE__BasenameOnly = true;
+else
+  Opts.__FILE__PrefixToRemove = A->getValue();
+  }
 }
 
 static void ParsePreprocessorOutputArgs(PreprocessorOutputOptions ,
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -570,6 +570,16 @@
   // Add CUDA include arguments, if needed.
   if (types::isCuda(Inputs[0].getType()))
 getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
+
+  // Add FILE macro prefix removing arguments or basename only flags.
+  if (const Arg *A = Args.getLastArg(options::OPT_FILE_prefix_to_remove,
+ options::OPT_FILE_basename_only)) {
+if (A->getOption().matches(options::OPT_FILE_basename_only))
+  CmdArgs.push_back(Args.MakeArgString("-ffile-macro-basename-only"));
+else if (!StringRef(A->getValue()).empty())
+  CmdArgs.push_back(Args.MakeArgString(
+  Twine("-ffile-macro-prefix-to-remove=") + A->getValue()));
+  }
 }
 
 // FIXME: Move to target hook.
Index: include/clang/Lex/PreprocessorOptions.h
===
--- include/clang/Lex/PreprocessorOptions.h
+++ include/clang/Lex/PreprocessorOptions.h
@@ -108,15 +108,23 @@
   /// the buffers associated with remapped files.
   ///
   /// This flag defaults to false; it can be set true only through direct
-  /// manipulation of the compiler invocation object, in cases where the 
+  /// manipulation of the compiler invocation object, in cases where the
   /// compiler invocation and its buffers will be reused.
   bool RetainRemappedFileBuffers;
-  
+
   /// \brief The Objective-C++ ARC standard library that we should support,
   /// by providing appropriate definitions to retrofit the standard library
   /// with support for lifetime-qualified pointers.
   ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary;
-
+
+  /// \brief This string will be used in expanding __FILE__ macro. If it
+  /// matches the prefix of __FILE__, the matched part won't be expanded.
+  std::string __FILE__PrefixToRemove;
+
+  /// \brief This falgs defaults to false; If it is set to true, only the
+  /// 

Re: [PATCH] D18914: [clang-tidy] new readability-redundant-inline

2016-04-08 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: docs/clang-tidy/checks/readability-redundant-inline.rst:6
@@ +5,3 @@
+
+This check flags redundant 'inline' specifiers.
+It flags 'inline' on member functions defined inside a class definition like

Please use `` for language construction highlighting. Same for other 
occurrences of inline and constexpr.


http://reviews.llvm.org/D18914



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


Re: [PATCH] D18914: [clang-tidy] new readability-redundant-inline

2016-04-08 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).


http://reviews.llvm.org/D18914



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


Re: [PATCH] D18221: [Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TS

2016-04-08 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 53103.
nwilson added a comment.

- Address Aaron's comments by putting comments next to the magic numbers


http://reviews.llvm.org/D18221

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

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
@@ -0,0 +1,18 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template  concept bool FCEI() { return true; } // expected-note {{previous declaration is here}} expected-note {{previous declaration is here}}
+template bool FCEI(); // expected-error {{function concept cannot be explicitly instantiated}}
+extern template bool FCEI(); // expected-error {{function concept cannot be explicitly instantiated}}
+
+template  concept bool FCES() { return true; } // expected-note {{previous declaration is here}}
+template <> bool FCES() { return true; } // expected-error {{function concept cannot be explicitly specialized}}
+
+template  concept bool VC { true }; // expected-note {{previous declaration is here}} expected-note {{previous declaration is here}}
+template bool VC; // expected-error {{variable concept cannot be explicitly instantiated}}
+extern template bool VC; // expected-error {{variable concept cannot be explicitly instantiated}}
+
+template  concept bool VCES { true }; // expected-note {{previous declaration is here}}
+template <> bool VCES { true }; // expected-error {{variable concept cannot be explicitly specialized}}
+
+template  concept bool VCPS { true }; // expected-note {{previous declaration is here}}
+template  bool VCPS { true }; // expected-error {{variable concept cannot be partially specialized}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -6920,6 +6920,15 @@
   // Ignore access information;  it doesn't figure into redeclaration checking.
   FunctionDecl *Specialization = cast(*Result);
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+  // an explicit specialization (14.8.3) [...] of a concept definition.
+  if (Specialization->getPrimaryTemplate()->isConcept()) {
+Diag(FD->getLocation(), diag::err_concept_specialized)
+<< 0 /*function*/ << 1 /*explicitly specialized*/;
+Diag(Specialization->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   FunctionTemplateSpecializationInfo *SpecInfo
 = Specialization->getTemplateSpecializationInfo();
   assert(SpecInfo && "Function template specialization info missing?");
@@ -7774,6 +7783,15 @@
 return true;
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (PrevTemplate->isConcept()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_specialized)
+<< 1 /*variable*/ << 0 /*explicitly instantiated*/;
+Diag(PrevTemplate->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   // Translate the parser's template argument list into our AST format.
   TemplateArgumentListInfo TemplateArgs =
   makeTemplateArgumentListInfo(*this, *D.getName().TemplateId);
@@ -7988,6 +8006,16 @@
  diag::ext_explicit_instantiation_without_qualified_id)
 << Specialization << D.getCXXScopeSpec().getRange();
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (FunTmpl && FunTmpl->isConcept() &&
+  !D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_specialized)
+<< 0 /*function*/ << 0 /*explicitly instantiated*/;
+Diag(FunTmpl->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   CheckExplicitInstantiationScope(*this,
FunTmpl? (NamedDecl *)FunTmpl
   : Specialization->getInstantiatedFromMemberFunction(),
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6285,6 +6285,25 @@
 if (!IsVariableTemplateSpecialization)
   D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous));
 
+// C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+// an explicit specialization (14.8.3) or a partial specialization of a
+// concept definition.
+if (IsVariableTemplateSpecialization &&
+!D.getDeclSpec().isConceptSpecified() && !Previous.empty() &&
+Previous.isSingleResult()) {
+  NamedDecl *PreviousDecl = Previous.getFoundDecl();
+  

[PATCH] D18914: [clang-tidy] new readability-redundant-inline

2016-04-08 Thread Matthias Gehre via cfe-commits
mgehre created this revision.
mgehre added reviewers: sbenza, bkramer, aaron.ballman, alexfh.
mgehre added a subscriber: cfe-commits.

This check flags redundant 'inline' specifiers.
It flags 'inline' on member functions defined inside a class definition
like
.. code-block:: c++

  struct S {
inline int f() {
  return 0;
}
  };

and 'inline' specifiers on functions that are also declared 'constexpr'.

http://reviews.llvm.org/D18914

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantInlineCheck.cpp
  clang-tidy/readability/RedundantInlineCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-inline.rst
  test/clang-tidy/readability-redundant-inline.cpp

Index: test/clang-tidy/readability-redundant-inline.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-inline.cpp
@@ -0,0 +1,67 @@
+// RUN: %check_clang_tidy %s readability-redundant-inline %t
+
+struct S {
+  inline int f1() {
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'inline' is redundant because method body is defined inside class [readability-redundant-inline]
+// CHECK-FIXES: {{^}}  int f1()
+return 0;
+  }
+  inline int f2(); // OK
+  
+  inline constexpr int f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 'inline' is redundant because 'constexpr' implies 'inline' [readability-redundant-inline]
+// CHECK-FIXES: {{^}}  constexpr int f3()
+return 0;
+  }
+  static inline constexpr int f4() {
+// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'inline' is redundant because 'constexpr' implies 'inline'
+// CHECK-FIXES: {{^}}  static constexpr int f4()
+return 0;
+  }
+  
+  static inline int f5();
+
+  static inline int f6() {
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'inline' is redundant because method body is defined inside class
+// CHECK-FIXES: {{^}}  static int f6()
+return 0;
+  }
+
+  inline friend int f7() {
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'inline' is redundant because function body is defined inside class [readability-redundant-inline]
+// CHECK-FIXES: {{^}}  friend int f7()
+  return 0;
+  }
+
+  inline friend int f8(); // OK
+};
+
+class S2 {
+  inline int f1() {
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'inline' is redundant because method body is defined inside class
+// CHECK-FIXES: {{^}}  int f1()
+return 0;
+  }
+};
+
+inline int S::f2() { // OK
+  return 0;
+}
+
+inline int S::f5() { // OK
+  return 0;
+}
+
+inline int f3() { // OK
+  return 0;
+}
+
+inline constexpr int f4() {
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: 'inline' is redundant because 'constexpr' implies 'inline'
+// CHECK-FIXES: {{^}}constexpr int f4()
+  return 1;
+}
+
+constexpr int f5() { // OK
+  return 1;
+}
\ No newline at end of file
Index: docs/clang-tidy/checks/readability-redundant-inline.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-inline.rst
@@ -0,0 +1,16 @@
+.. title:: clang-tidy - readability-redundant-inline
+
+readability-redundant-inline
+
+
+This check flags redundant 'inline' specifiers.
+It flags 'inline' on member functions defined inside a class definition like
+.. code-block:: c++
+
+  struct S {
+inline int f() {
+	  return 0;
+	}
+  };
+
+and 'inline' specifiers on functions that are also declared 'constexpr'.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -105,6 +105,7 @@
readability-inconsistent-declaration-parameter-name
readability-named-parameter
readability-redundant-control-flow
+   readability-redundant-inline
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
Index: clang-tidy/readability/RedundantInlineCheck.h
===
--- /dev/null
+++ clang-tidy/readability/RedundantInlineCheck.h
@@ -0,0 +1,35 @@
+//===--- RedundantInlineCheck.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_READABILITY_REDUNDANT_INLINE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_INLINE_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Flags redundant 'inline' when used on a method with inline body or on a constexpr function.
+///
+/// For the user-facing documentation see:
+/// 

Re: [PATCH] D18808: Use the NoDebug emission kind to identify compile units that no debug info should be created from.

2016-04-08 Thread Adrian Prantl via cfe-commits
aprantl closed this revision.
aprantl marked an inline comment as done.
aprantl added a comment.

265860+265861


http://reviews.llvm.org/D18808



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


r265864 - [Perf-Training] Reworked workflow improvements for order-file generation

2016-04-08 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Apr  8 17:48:18 2016
New Revision: 265864

URL: http://llvm.org/viewvc/llvm-project?rev=265864=rev
Log:
[Perf-Training] Reworked workflow improvements for order-file generation

This is re-landing r260742. I've reworked the conditionals so that it only hits 
when targeting Apple platforms with ld64.

Original Summary:
With this change generating clang order files using dtrace uses the following 
workflow:

cmake 

ninja generate-order-file

ninja clang

This patch works by setting a default path to the order file (which can be 
overridden by the user). If the order file doesn't exist during configuration 
CMake will create an empty one.

CMake then ties up the dependencies between the clang link job and the order 
file, and generate-order-file overwrites CLANG_ORDER_FILE with the new order 
file.

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/tools/driver/CMakeLists.txt
cfe/trunk/utils/perf-training/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=265864=265863=265864=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Apr  8 17:48:18 2016
@@ -595,17 +595,28 @@ if( CLANG_INCLUDE_DOCS )
   add_subdirectory(docs)
 endif()
 
-if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/clang.order")
-  file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/clang.order")
-endif()
 
-if(CLANG_ORDER_FILE STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/clang.order")
-  unset(CLANG_ORDER_FILE CACHE)
-  unset(CLANG_ORDER_FILE)
-endif()
+if(APPLE)
+  # this line is needed as a cleanup to ensure that any CMakeCaches with the 
old
+  # default value get updated to the new default.
+  if(CLANG_ORDER_FILE STREQUAL "")
+unset(CLANG_ORDER_FILE CACHE)
+unset(CLANG_ORDER_FILE)
+  endif()
+
 
-set(CLANG_ORDER_FILE "" CACHE FILEPATH
-  "Order file to use when compiling clang in order to improve startup time.")
+  set(CLANG_ORDER_FILE ${CMAKE_CURRENT_BINARY_DIR}/clang.order CACHE FILEPATH
+"Order file to use when compiling clang in order to improve startup time 
(Darwin Only - requires ld64).")
+
+  if(CLANG_ORDER_FILE AND NOT EXISTS ${CLANG_ORDER_FILE})
+string(FIND "${CLANG_ORDER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" PATH_START)
+if(PATH_START EQUAL 0)
+  file(WRITE ${CLANG_ORDER_FILE} "\n")
+else()
+  message(FATAL_ERROR "Specified order file '${CLANG_ORDER_FILE}' does not 
exist.")
+endif()
+  endif()
+endif()
 
 if (CLANG_BUILT_STANDALONE OR CMAKE_VERSION VERSION_EQUAL 3 OR
 CMAKE_VERSION VERSION_GREATER 3)

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=265864=265863=265864=diff
==
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Fri Apr  8 17:48:18 2016
@@ -87,8 +87,25 @@ if (APPLE)
   set(TOOL_INFO_BUILD_VERSION)
 endif()
 
-if(CLANG_ORDER_FILE AND EXISTS ${CLANG_ORDER_FILE})
-  target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
+# the linker -order_file flag is only supported by ld64
+if(LD64_EXECUTABLE AND CLANG_ORDER_FILE)
+  include(CMakePushCheckState)
+
+  function(check_linker_flag flag out_var)
+cmake_push_check_state()
+set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag}")
+check_cxx_compiler_flag("" ${out_var})
+cmake_pop_check_state()
+  endfunction()
+
+  # This is a test to ensure the actual order file works with the linker.
+  check_linker_flag("-Wl,-order_file,${CLANG_ORDER_FILE}"
+LINKER_ORDER_FILE_WORKS)
+  
+  if(LINKER_ORDER_FILE_WORKS)
+target_link_libraries(clang "-Wl,-order_file,${CLANG_ORDER_FILE}")
+set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE})
+  endif()
 endif()
 
 if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)

Modified: cfe/trunk/utils/perf-training/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/CMakeLists.txt?rev=265864=265863=265864=diff
==
--- cfe/trunk/utils/perf-training/CMakeLists.txt (original)
+++ cfe/trunk/utils/perf-training/CMakeLists.txt Fri Apr  8 17:48:18 2016
@@ -55,9 +55,8 @@ if(DTRACE)
 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
clean ${CMAKE_CURRENT_BINARY_DIR} dtrace
 COMMENT "Clearing old dtrace data")
 
-
   add_custom_target(generate-order-file
-COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
gen-order-file --binary $ --output 
${CMAKE_CURRENT_BINARY_DIR}/clang.order ${CMAKE_CURRENT_BINARY_DIR}
+COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py 
gen-order-file --binary $ --output ${CLANG_ORDER_FILE} 
${CMAKE_CURRENT_BINARY_DIR}
 COMMENT "Generating order file"
 DEPENDS 

Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-04-08 Thread Weiming Zhao via cfe-commits
weimingz added a subscriber: weimingz.
weimingz added a comment.

Sounds good. Will do.

Thanks for reviewing


http://reviews.llvm.org/D17741



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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-04-08 Thread Zhao, Weiming via cfe-commits

Sounds good. Will do.

Thanks for reviewing

On 4/8/2016 11:46 AM, Alex Rosenberg wrote:

alexr added a subscriber: alexr.
alexr added a comment.

There are multiple features in this patch that should be considered separately. 
Please split the patch.

That said, I don't think we want to add a fundamental new preprocessor feature 
like __FILE_BASENAME__ without at least getting some early buy-in from the WG14 
and WG21 committees. I suspect they’d not want to add to the preprocessor at 
all.

The flag concept seems much more tractable. Please split it into two flags, one 
to force __FILE__ to only be the basename, and one that handles the prefix 
stripping. That is, a magic value of __ALL_DIR__ seems like the wrong choice 
here.


http://reviews.llvm.org/D17741





--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by 
The Linux Foundation

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


r265862 - Use NoDebug compile units to mark debug metadata used only for sample-based

2016-04-08 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Apr  8 17:43:06 2016
New Revision: 265862

URL: http://llvm.org/viewvc/llvm-project?rev=265862=rev
Log:
Use NoDebug compile units to mark debug metadata used only for sample-based
profiling and optimization remarks and indicate that no debug info shall
be emitted for these compile units.

http://reviews.llvm.org/D18808


Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/Frontend/optimization-remark.c
cfe/trunk/test/Frontend/profile-sample-use-loc-tracking.c

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=265862=265861=265862=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr  8 17:43:06 2016
@@ -396,16 +396,27 @@ void CGDebugInfo::CreateCompileUnit() {
   if (LO.ObjC1)
 RuntimeVers = LO.ObjCRuntime.isNonFragile() ? 2 : 1;
 
+  llvm::DICompileUnit::DebugEmissionKind EmissionKind;
+  switch (DebugKind) {
+  case codegenoptions::NoDebugInfo:
+  case codegenoptions::LocTrackingOnly:
+EmissionKind = llvm::DICompileUnit::NoDebug;
+break;
+  case codegenoptions::DebugLineTablesOnly:
+EmissionKind = llvm::DICompileUnit::LineTablesOnly;
+break;
+  case codegenoptions::LimitedDebugInfo:
+  case codegenoptions::FullDebugInfo:
+EmissionKind = llvm::DICompileUnit::FullDebug;
+break;
+  }
+
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
   LangTag, remapDIPath(MainFileName), remapDIPath(getCurrentDirname()),
   Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
-  CGM.getCodeGenOpts().SplitDwarfFile,
-  DebugKind <= codegenoptions::DebugLineTablesOnly
-  ? llvm::DICompileUnit::LineTablesOnly
-  : llvm::DICompileUnit::FullDebug,
-  0 /* DWOid */, DebugKind != codegenoptions::LocTrackingOnly);
+  CGM.getCodeGenOpts().SplitDwarfFile, EmissionKind, 0 /* DWOid */);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {

Modified: cfe/trunk/test/Frontend/optimization-remark.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark.c?rev=265862=265861=265862=diff
==
--- cfe/trunk/test/Frontend/optimization-remark.c (original)
+++ cfe/trunk/test/Frontend/optimization-remark.c Fri Apr  8 17:43:06 2016
@@ -27,9 +27,10 @@
 // CHECK: , !dbg !
 // CHECK-NOT: DW_TAG_base_type
 
-// But llvm.dbg.cu should be missing (to prevent writing debug info to
+// The CU should be marked NoDebug (to prevent writing debug info to
 // the final output).
-// CHECK-NOT: !llvm.dbg.cu = !{
+// CHECK: !llvm.dbg.cu = !{![[CU:.*]]}
+// CHECK: ![[CU]] = distinct !DICompileUnit({{.*}}emissionKind: NoDebug
 
 int foo(int x, int y) __attribute__((always_inline));
 int foo(int x, int y) { return x + y; }

Modified: cfe/trunk/test/Frontend/profile-sample-use-loc-tracking.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/profile-sample-use-loc-tracking.c?rev=265862=265861=265862=diff
==
--- cfe/trunk/test/Frontend/profile-sample-use-loc-tracking.c (original)
+++ cfe/trunk/test/Frontend/profile-sample-use-loc-tracking.c Fri Apr  8 
17:43:06 2016
@@ -10,9 +10,10 @@
 // CHECK: , !dbg !
 // CHECK-NOT: DW_TAG_base_type
 
-// But llvm.dbg.cu should be missing (to prevent writing debug info to
+// The CU should be marked NoDebug (to prevent writing debug info to
 // the final output).
-// CHECK-NOT: !llvm.dbg.cu = !{
+// CHECK: !llvm.dbg.cu = !{![[CU:.*]]}
+// CHECK: ![[CU]] = distinct !DICompileUnit({{.*}}emissionKind: NoDebug
 
 int bar(int j) {
   return (j + j - 2) * (j - 2) * j;


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


Re: [PATCH] D15032: [clang-tidy] new checker cppcoreguidelines-pro-lifetime

2016-04-08 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 53097.
mgehre added a comment.

Update for renaming in http://reviews.llvm.org/D15031


http://reviews.llvm.org/D15032

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/ProLifetimeCheck.cpp
  clang-tidy/cppcoreguidelines/ProLifetimeCheck.h
  clang-tidy/cppcoreguidelines/ProLifetimeVisitor.cpp
  clang-tidy/cppcoreguidelines/ProLifetimeVisitor.h
  docs/clang-tidy/checks/cppcoreguidelines-pro-lifetime.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-pro-lifetime-psets.cpp
  test/clang-tidy/cppcoreguidelines-pro-lifetime.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-lifetime.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-lifetime.cpp
@@ -0,0 +1,87 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-lifetime %t -- -config="{CheckOptions: [{key: cppcoreguidelines-pro-lifetime.Debug, value: 1}]}" -- -std=c++11
+
+struct S {
+  ~S();
+  int m;
+  int f();
+};
+
+void deref_uninitialized() {
+  int *p;
+  *p = 3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dereferencing a dangling pointer [cppcoreguidelines-pro-lifetime]
+  // CHECK-MESSAGES: :[[@LINE-3]]:8: note: it became invalid because was never initialized here
+}
+
+void deref_nullptr() {
+  int *q = nullptr;
+  *q = 3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dereferencing a null pointer
+}
+
+void ref_leaves_scope() {
+  int *p;
+  {
+int i = 0;
+p = 
+*p = 2; // OK
+  }
+  *p = 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dereferencing a dangling pointer
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: note: it became invalid because the pointee i left the scope here
+}
+
+void ref_to_member_leaves_scope_call() {
+  S *p;
+  {
+S s;
+p = 
+p->f(); // OK
+  }
+  p->f();
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: dereferencing a dangling pointer
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: note: it became invalid because the pointee s left the scope here
+  int i = p->m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: dereferencing a dangling pointer
+  // CHECK-MESSAGES: :[[@LINE-6]]:3: note: it became invalid because the pointee s left the scope here
+  p->m = 4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: dereferencing a dangling pointer
+  // CHECK-MESSAGES: :[[@LINE-9]]:3: note: it became invalid because the pointee s left the scope here
+}
+
+// No Pointer involved, thus not checked
+void ignore_access_on_non_ref_ptr() {
+  S s;
+  s.m = 3;
+  s.f();
+}
+
+// Note: the messages below are for the template instantiation in instantiate_ref_leaves_scope_template
+// The checker only checks instantiations
+template
+void ref_leaves_scope_template() {
+  T p;
+  {
+int i = 0;
+p = 
+*p = 2; // OK
+  }
+  *p = 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: dereferencing a dangling pointer
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: note: it became invalid because the pointee i left the scope here
+}
+
+void instantiate_ref_leaves_scope_template() {
+  ref_leaves_scope_template();
+}
+
+int global_i = 4;
+int *global_init_p = _i; // OK
+int *global_uninit_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: the pset of global_uninit_p must be a subset of {(static), (null)}, but is {(invalid)}
+int *global_null_p = nullptr; // OK
+
+void uninitialized_static() {
+  static int* p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: the pset of p must be a subset of {(static), (null)}, but is {(invalid)}
+}
Index: test/clang-tidy/cppcoreguidelines-pro-lifetime-psets.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-lifetime-psets.cpp
@@ -0,0 +1,512 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-lifetime %t -- -config="{CheckOptions: [{key: cppcoreguidelines-pro-lifetime.Debug, value: 1}]}" -- -std=c++11
+
+// TODO:
+// lifetime annotations
+// lambda
+// function calls
+
+template
+void clang_analyzer_pset(const T&);
+
+int rand();
+
+struct S {
+  ~S();
+  int m;
+  void f() {
+int* p =  // pset becomes m, not *this
+clang_analyzer_pset(p);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pset(p) = {m}
+  }
+};
+
+struct D : public S {
+  ~D();
+};
+
+void pointer_exprs() {
+  int *p;
+  clang_analyzer_pset(p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: pset(p) = {(invalid)} [cppcoreguidelines-pro-lifetime]
+  int *q = nullptr;
+  clang_analyzer_pset(q);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: pset(q) = {(null)}
+  int *q2 = 0;
+  clang_analyzer_pset(q2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: pset(q2) = {(null)}
+  S s;
+  p = 
+  clang_analyzer_pset(p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: pset(p) = {s}
+  int a[2];
+  p = [0];
+  clang_analyzer_pset(p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: pset(p) = {a}
+
+  D d;
+  S* ps =  // Ignore implicit cast
+  

r265857 - Remove unused functions from ASTWriter interface.

2016-04-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Apr  8 16:54:32 2016
New Revision: 265857

URL: http://llvm.org/viewvc/llvm-project?rev=265857=rev
Log:
Remove unused functions from ASTWriter interface.

Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=265857=265856=265857=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Fri Apr  8 16:54:32 2016
@@ -593,15 +593,6 @@ public:
   /// \brief Emit a source range.
   void AddSourceRange(SourceRange Range, RecordDataImpl );
 
-  /// \brief Emit an integral value.
-  void AddAPInt(const llvm::APInt , RecordDataImpl );
-
-  /// \brief Emit a signed integral value.
-  void AddAPSInt(const llvm::APSInt , RecordDataImpl );
-
-  /// \brief Emit a floating-point value.
-  void AddAPFloat(const llvm::APFloat , RecordDataImpl );
-
   /// \brief Emit a reference to an identifier.
   void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl );
 
@@ -869,19 +860,13 @@ public:
   }
 
   /// \brief Emit an integral value.
-  void AddAPInt(const llvm::APInt ) {
-return Writer->AddAPInt(Value, *Record);
-  }
+  void AddAPInt(const llvm::APInt );
 
   /// \brief Emit a signed integral value.
-  void AddAPSInt(const llvm::APSInt ) {
-return Writer->AddAPSInt(Value, *Record);
-  }
+  void AddAPSInt(const llvm::APSInt );
 
   /// \brief Emit a floating-point value.
-  void AddAPFloat(const llvm::APFloat ) {
-return Writer->AddAPFloat(Value, *Record);
-  }
+  void AddAPFloat(const llvm::APFloat );
 
   /// \brief Emit a reference to an identifier.
   void AddIdentifierRef(const IdentifierInfo *II) {

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=265857=265856=265857=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Apr  8 16:54:32 2016
@@ -4802,19 +4802,19 @@ void ASTWriter::AddSourceRange(SourceRan
   AddSourceLocation(Range.getEnd(), Record);
 }
 
-void ASTWriter::AddAPInt(const llvm::APInt , RecordDataImpl ) {
-  Record.push_back(Value.getBitWidth());
+void ASTRecordWriter::AddAPInt(const llvm::APInt ) {
+  Record->push_back(Value.getBitWidth());
   const uint64_t *Words = Value.getRawData();
-  Record.append(Words, Words + Value.getNumWords());
+  Record->append(Words, Words + Value.getNumWords());
 }
 
-void ASTWriter::AddAPSInt(const llvm::APSInt , RecordDataImpl ) {
-  Record.push_back(Value.isUnsigned());
-  AddAPInt(Value, Record);
+void ASTRecordWriter::AddAPSInt(const llvm::APSInt ) {
+  Record->push_back(Value.isUnsigned());
+  AddAPInt(Value);
 }
 
-void ASTWriter::AddAPFloat(const llvm::APFloat , RecordDataImpl ) 
{
-  AddAPInt(Value.bitcastToAPInt(), Record);
+void ASTRecordWriter::AddAPFloat(const llvm::APFloat ) {
+  AddAPInt(Value.bitcastToAPInt());
 }
 
 void ASTWriter::AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl 
) {


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


[libcxx] r265856 - Update filesystem status

2016-04-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Apr  8 16:52:32 2016
New Revision: 265856

URL: http://llvm.org/viewvc/llvm-project?rev=265856=rev
Log:
Update filesystem status

Modified:
libcxx/trunk/www/ts1z_status.html

Modified: libcxx/trunk/www/ts1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/ts1z_status.html?rev=265856=265855=265856=diff
==
--- libcxx/trunk/www/ts1z_status.html (original)
+++ libcxx/trunk/www/ts1z_status.html Fri Apr  8 16:52:32 2016
@@ -91,7 +91,7 @@
   Features in Filesystem
   
Feature NameStatus
-   All featuresNot started
+   All featuresIn Review
 
   
 


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


Re: [PATCH] D15031: CFG: Add CFGElement for automatic variables that leave the scope

2016-04-08 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 53092.
mgehre added a comment.

Fix assert in LocalScope::const_iterator::distance when using goto to jump over 
trivially constructable variable declarations
Added two test cases for this


http://reviews.llvm.org/D15031

Files:
  include/clang/Analysis/AnalysisContext.h
  include/clang/Analysis/CFG.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/CFG.cpp
  lib/StaticAnalyzer/Core/AnalysisManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/lifetime-cfg-output.cpp

Index: test/Analysis/lifetime-cfg-output.cpp
===
--- /dev/null
+++ test/Analysis/lifetime-cfg-output.cpp
@@ -0,0 +1,735 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-lifetime=true -analyzer-config cfg-implicit-dtors=false %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+extern bool UV;
+class A {
+public:
+// CHECK:   [B2 (ENTRY)]
+// CHECK-NEXT:Succs (1): B1
+// CHECK:   [B1]
+// CHECK-NEXT:1: true
+// CHECK-NEXT:2: UV
+// CHECK-NEXT:3: [B1.2] = [B1.1]
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B0 (EXIT)]
+// CHECK-NEXT:Preds (1): B1
+A() { 
+UV = true;
+}
+// CHECK:   [B3 (ENTRY)]
+// CHECK-NEXT:Succs (1): B2
+// CHECK:   [B1]
+// CHECK-NEXT:1: 0
+// CHECK-NEXT:2: this
+// CHECK-NEXT:3: [B1.2]->p
+// CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, LValueToRValue, int *)
+// CHECK-NEXT:5: *[B1.4]
+// CHECK-NEXT:6: [B1.5] = [B1.1]
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B2]
+// CHECK-NEXT:1: this
+// CHECK-NEXT:2: [B2.1]->p
+// CHECK-NEXT:3: [B2.2] (ImplicitCastExpr, LValueToRValue, int *)
+// CHECK-NEXT:4: [B2.3] (ImplicitCastExpr, PointerToBoolean, _Bool)
+// CHECK-NEXT:T: if [B2.4]
+// CHECK-NEXT:Preds (1): B3
+// CHECK-NEXT:Succs (2): B1 B0
+// CHECK:   [B0 (EXIT)]
+// CHECK-NEXT:Preds (2): B1 B2
+~A() {
+if(p)
+*p = 0;
+}
+// CHECK:   [B2 (ENTRY)]
+// CHECK-NEXT:Succs (1): B1
+// CHECK:   [B1]
+// CHECK-NEXT:1: 1
+// CHECK-NEXT:2: return [B1.1];
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B0 (EXIT)]
+// CHECK-NEXT:Preds (1): B1
+operator int() const { return 1; }
+int* p;
+};
+
+// CHECK:   [B2 (ENTRY)]
+// CHECK-NEXT:Succs (1): B1
+// CHECK:   [B1]
+// CHECK-NEXT:1:  (CXXConstructExpr, class A)
+// CHECK-NEXT:2: A a;
+// CHECK-NEXT:3: a
+// CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK-NEXT:5: const A  = a;
+// CHECK-NEXT:6: A() (CXXConstructExpr, class A)
+// CHECK-NEXT:7: [B1.6] (BindTemporary)
+// CHECK-NEXT:8: [B1.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK-NEXT:9: [B1.8]
+// CHECK-NEXT:   10: const A  = A();
+// CHECK-NEXT:   11: [B1.10] (Lifetime ends)
+// CHECK-NEXT:   12: [B1.2] (Lifetime ends)
+// CHECK-NEXT:   13: [B1.5] (Lifetime ends)
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B0 (EXIT)]
+// CHECK-NEXT:Preds (1): B1
+void test_const_ref() {
+  A a;
+  const A& b = a;
+  const A& c = A();
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:   [B1]
+// CHECK-NEXT:1:  (CXXConstructExpr, class A [2])
+// CHECK-NEXT:2: A a[2];
+// CHECK-NEXT:3:  (CXXConstructExpr, class A [0])
+// CHECK-NEXT:4: A b[0];
+// lifetime of a ends when its destructors are run
+// CHECK-NEXT:5: [B1.2] (Lifetime ends)
+// lifetime of b ends when its storage duration ends
+// CHECK-NEXT:6: [B1.4] (Lifetime ends)
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_array() {
+  A a[2];
+  A b[0];
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:   [B1]
+// CHECK-NEXT:1:  (CXXConstructExpr, class A)
+// CHECK-NEXT:2: A a;
+// CHECK-NEXT:3:  (CXXConstructExpr, class A)
+// CHECK-NEXT:4: A c;
+// CHECK-NEXT:5:  (CXXConstructExpr, class A)
+// CHECK-NEXT:6: A d;
+// CHECK-NEXT:7: [B1.6] (Lifetime ends)
+// CHECK-NEXT:8: [B1.4] (Lifetime ends)
+// CHECK-NEXT:9:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   10: A b;
+// CHECK-NEXT:   11: [B1.10] (Lifetime ends)
+// CHECK-NEXT:   12: [B1.2] (Lifetime ends)
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_scope() {
+  A a;
+  { A c;
+A d;
+  }
+  A b;
+}
+
+// CHECK:  [B4 (ENTRY)]
+// CHECK-NEXT:   Succs 

Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-08 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include/clang/Format/Format.h:769
@@ -768,1 +768,3 @@
 
+/// \brief Returns the replacements corresponding to applying and fixing
+/// \p Replaces.

I am actually not sure that fixReplacements is the right terminology here 
(sorry that I haven't discovered this earlier). It isn't really fixing the 
replacements (they aren't necessarily broken). How about 
cleanupAroundReplacements? Manuel, what do you think?


Comment at: lib/Format/Format.cpp:1596
@@ +1595,3 @@
+RangeMgr(SourceMgr,
+ SmallVector(Ranges.begin(), 
Ranges.end())),
+UnwrappedLines(1),

But like this, it is way to much code duplication for me, both in number of 
lines of code as well as code complexity. Basically everything in fix() is 
duplicated along with most of the class members etc. The main difference seems 
to be that runFix() is called instead of format. There must be a way to have 
only one implementation of that code.

I think (but cannot see all the consequences yet) you should merge the two 
classes. And if that leads to too much complexity, you can probably pull out 
runFix and everything it calls into a separate class as well as possibly 
format() and everything that format calls.


Comment at: lib/Format/Format.cpp:1597
@@ +1596,3 @@
+ SmallVector(Ranges.begin(), 
Ranges.end())),
+UnwrappedLines(1),
+Encoding(encoding::detectEncoding(SourceMgr.getBufferData(ID))),

Why are you doing this?


Comment at: lib/Format/Format.cpp:1664
@@ +1663,3 @@
+
+  if (Line.IsConstructorInitializer)
+checkConstructorInitList(Line);

Can you move the ConstructorInitializer fixer and everything that belongs to it 
to a different patch? I want to look at that in more detail and two smaller 
patches make this easier for me.


Comment at: lib/Format/Format.cpp:1672
@@ +1671,3 @@
+  bool containsOnlyComments(const AnnotatedLine ) {
+bool CommentsOnly = true;
+FormatToken *Tok = Line.First;

No need for this boolean. Write this as:

  for (FormatToken *Tok = Line.First;; Tok = Tok->Next) {
if (!Tok->is(tok::comment))
  return false;
  }
  return true;

And maybe we should (in a separate patch) add an iterator interface to 
AnnotatedLine so that we can use range-based for loops.


Comment at: lib/Format/Format.cpp:1695
@@ +1694,3 @@
+if (NewLine == -1) {
+  IsEmpty = false;
+  continue;

Why not return -1 here?


Comment at: lib/Format/Format.cpp:1699
@@ +1698,3 @@
+CurrentLine = NewLine;
+  } else if (AnnotatedLines[CurrentLine]->startsWith(tok::comment) &&
+ containsOnlyComments(*AnnotatedLines[CurrentLine]))

Move the startsWith into containsOnlyComments.


Comment at: lib/Format/Format.cpp:1701
@@ +1700,3 @@
+ containsOnlyComments(*AnnotatedLines[CurrentLine]))
+continue;
+  else if (AnnotatedLines[CurrentLine]->startsWith(tok::r_brace))

I'd write this in a very different order:

  if (AnnotatedLines[CurrentLine]->startsWith(tok::r_brace))
break;
  if (AnnotatedLines[CurrentLine]->startsWith(kw_namespaces) || ..) {
int NewLine = checkEmptyNamespace(CurrentLine);
if (NewLine == -1)
  return -1;
continue;
  if (!containsOnlyComments(..))
return -1;



Comment at: lib/Format/Format.cpp:1702
@@ +1701,3 @@
+continue;
+  else if (AnnotatedLines[CurrentLine]->startsWith(tok::r_brace))
+break;

It's a bit subtle that this works correctly. At least I needed to think quickly 
why you wouldn't falsely run into this in

  namespace N {
  void f() {
  }
  }

But of course, then the namespace wouldn't be empty. Please leave a comment 
explaining this briefly.


Comment at: lib/Format/Format.cpp:1717
@@ +1716,3 @@
+
+for (unsigned i = InitLine; i <= CurrentLine; ++i) {
+  AnnotatedLines[i]->Deleted = true;

Hm, this seems very inelegant. If you have:

  namespace A {
  namespace B {
  namespace C {
  }
  }
  }

"namespace C {" and "}" gets delete three times. At the very least you should 
add

  if (AnnotatedLines[i]->Deleted)
continue;

Thinking about this some more, it will get deleted even more often has even the 
outer loop in runFix will call checkEmptyNamespace again for the inner 
namespaces even though they have been deleted already. So inner namespaces will 
bei deleted O(N^2) times if N is the nesting depth. Lets get that down to 1 
instead ;-)


Comment at: lib/Format/Format.cpp:1818
@@ +1817,3 @@
+
+// Merge multiple continuous token deletions into one big deletion.
+unsigned Idx = 0;

Can 

r265848 - PR25501: Delay loading visible updates for a declaration until after we've

2016-04-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Apr  8 15:53:26 2016
New Revision: 265848

URL: http://llvm.org/viewvc/llvm-project?rev=265848=rev
Log:
PR25501: Delay loading visible updates for a declaration until after we've
processed update records. If an update record adds a definition, we need to
merge that with any pre-existing definition to determine which the canonical
definition is before we apply the visible update, otherwise we wouldn't know
where to apply it.

Thanks to Vassil Vassilev for help reducing this and tracking down the problem.

Added:
cfe/trunk/test/Modules/Inputs/PR25501/
cfe/trunk/test/Modules/Inputs/PR25501/Vector.h
cfe/trunk/test/Modules/Inputs/PR25501/a0.h
cfe/trunk/test/Modules/Inputs/PR25501/a1.h
cfe/trunk/test/Modules/Inputs/PR25501/a2.h
cfe/trunk/test/Modules/Inputs/PR25501/b.h
cfe/trunk/test/Modules/Inputs/PR25501/module.modulemap
cfe/trunk/test/Modules/pr25501.cpp
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=265848=265847=265848=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Apr  8 15:53:26 2016
@@ -3436,20 +3436,6 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
 }
 
 void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) {
-  // Load the pending visible updates for this decl context, if it has any.
-  auto I = PendingVisibleUpdates.find(ID);
-  if (I != PendingVisibleUpdates.end()) {
-auto VisibleUpdates = std::move(I->second);
-PendingVisibleUpdates.erase(I);
-
-auto *DC = cast(D)->getPrimaryContext();
-for (const PendingVisibleUpdate  : VisibleUpdates)
-  Lookups[DC].Table.add(
-  Update.Mod, Update.Data,
-  reader::ASTDeclContextNameLookupTrait(*this, *Update.Mod));
-DC->setHasExternalVisibleStorage(true);
-  }
-
   // The declaration may have been modified by files later in the chain.
   // If this is the case, read the record containing the updates from each file
   // and pass it to ASTDeclReader to make the modifications.
@@ -3485,6 +3471,20 @@ void ASTReader::loadDeclUpdateRecords(se
   }
 }
   }
+
+  // Load the pending visible updates for this decl context, if it has any.
+  auto I = PendingVisibleUpdates.find(ID);
+  if (I != PendingVisibleUpdates.end()) {
+auto VisibleUpdates = std::move(I->second);
+PendingVisibleUpdates.erase(I);
+
+auto *DC = cast(D)->getPrimaryContext();
+for (const PendingVisibleUpdate  : VisibleUpdates)
+  Lookups[DC].Table.add(
+  Update.Mod, Update.Data,
+  reader::ASTDeclContextNameLookupTrait(*this, *Update.Mod));
+DC->setHasExternalVisibleStorage(true);
+  }
 }
 
 void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) {
@@ -3757,7 +3757,7 @@ void ASTDeclReader::UpdateDecl(Decl *D,
 
 case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: {
   auto *RD = cast(D);
-  auto *OldDD = RD->DefinitionData.getNotUpdated();
+  auto *OldDD = RD->getCanonicalDecl()->DefinitionData.getNotUpdated();
   bool HadRealDefinition =
   OldDD && (OldDD->Definition != RD ||
 !Reader.PendingFakeDefinitionData.count(OldDD));

Added: cfe/trunk/test/Modules/Inputs/PR25501/Vector.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR25501/Vector.h?rev=265848=auto
==
--- cfe/trunk/test/Modules/Inputs/PR25501/Vector.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR25501/Vector.h Fri Apr  8 15:53:26 2016
@@ -0,0 +1,5 @@
+template  struct _Vector_base {};
+struct vector {
+  vector() {}
+  vector(_Vector_base);
+};

Added: cfe/trunk/test/Modules/Inputs/PR25501/a0.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR25501/a0.h?rev=265848=auto
==
--- cfe/trunk/test/Modules/Inputs/PR25501/a0.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR25501/a0.h Fri Apr  8 15:53:26 2016
@@ -0,0 +1 @@
+#include "Vector.h"

Added: cfe/trunk/test/Modules/Inputs/PR25501/a1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR25501/a1.h?rev=265848=auto
==
--- cfe/trunk/test/Modules/Inputs/PR25501/a1.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR25501/a1.h Fri Apr  8 15:53:26 2016
@@ -0,0 +1 @@
+#include "Vector.h"

Added: cfe/trunk/test/Modules/Inputs/PR25501/a2.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR25501/a2.h?rev=265848=auto
==
--- cfe/trunk/test/Modules/Inputs/PR25501/a2.h (added)
+++ 

Re: [PATCH] D18808: Use the NoDebug emission kind to identify compile units that no debug info should be created from.

2016-04-08 Thread David Blaikie via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good, thanks! Sorry for the delays/mthanks for the chat on IRC (summary: 
no worse than what we have today, more explicit, maybe we can find an 
alternative and/or more compact representation some other day)


http://reviews.llvm.org/D18808



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


r265844 - Add doxygen comments to emmintrin.h's intrinsics. Only around 25% of the intrinsics in this file are documented now. The patches for the rest of the intrisics in this file will be send out l

2016-04-08 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Fri Apr  8 15:45:48 2016
New Revision: 265844

URL: http://llvm.org/viewvc/llvm-project?rev=265844=rev
Log:
Add doxygen comments to emmintrin.h's intrinsics. Only around 25% of the 
intrinsics in this file are documented now. The patches for the rest of the 
intrisics in this file will be send out later.

The doxygen comments are automatically generated based on Sony's intrinsics 
document.

I got an OK from Eric Christopher to commit doxygen comments without prior code 
review upstream. This patch was internally reviewed by Paul Robinson.



Modified:
cfe/trunk/lib/Headers/emmintrin.h

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=265844=265843=265844=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Fri Apr  8 15:45:48 2016
@@ -734,108 +734,348 @@ _mm_mulhi_epu16(__m128i __a, __m128i __b
   return (__m128i)__builtin_ia32_pmulhuw128((__v8hi)__a, (__v8hi)__b);
 }
 
+/// \brief Multiplies the corresponding elements of two [8 x short] vectors and
+///returns a vector containing the low-order 16 bits of each 32-bit product
+///in the corresponding element.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPMULLW / PMULLW instruction.
+///
+/// \param __a
+///A 128-bit integer vector containing one of the source operands.
+/// \param __b
+///A 128-bit integer vector containing one of the source operands.
+/// \returns A 128-bit integer vector containing the products of both operands.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_mullo_epi16(__m128i __a, __m128i __b)
 {
   return (__m128i)((__v8hi)__a * (__v8hi)__b);
 }
 
+/// \brief Multiplies 32-bit unsigned integer values contained in the lower 
bits
+///of the two 64-bit integer vectors and returns the 64-bit unsigned
+///product.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c PMULUDQ instruction.
+///
+/// \param __a
+///A 64-bit integer containing one of the source operands.
+/// \param __b
+///A 64-bit integer containing one of the source operands.
+/// \returns A 64-bit integer vector containing the product of both operands.
 static __inline__ __m64 __DEFAULT_FN_ATTRS
 _mm_mul_su32(__m64 __a, __m64 __b)
 {
   return __builtin_ia32_pmuludq((__v2si)__a, (__v2si)__b);
 }
 
+/// \brief Multiplies 32-bit unsigned integer values contained in the lower
+///bits of the corresponding elements of two [2 x i64] vectors, and returns
+///the 64-bit products in the corresponding elements of a [2 x i64] vector.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPMULUDQ / PMULUDQ instruction.
+///
+/// \param __a
+///A [2 x i64] vector containing one of the source operands.
+/// \param __b
+///A [2 x i64] vector containing one of the source operands.
+/// \returns A [2 x i64] vector containing the product of both operands.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_mul_epu32(__m128i __a, __m128i __b)
 {
   return __builtin_ia32_pmuludq128((__v4si)__a, (__v4si)__b);
 }
 
+/// \brief Computes the absolute differences of corresponding 8-bit integer
+///values in two 128-bit vectors. Sums the first 8 absolute differences, 
and
+///separately sums the second 8 absolute differences. Packss these two
+///unsigned 16-bit integer sums into the upper and lower elements of a
+///[2 x i64] vector.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSADBW / PSADBW instruction.
+///
+/// \param __a
+///A 128-bit integer vector containing one of the source operands.
+/// \param __b
+///A 128-bit integer vector containing one of the source operands.
+/// \returns A [2 x i64] vector containing the sums of the sets of absolute
+///differences between both operands.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_sad_epu8(__m128i __a, __m128i __b)
 {
   return __builtin_ia32_psadbw128((__v16qi)__a, (__v16qi)__b);
 }
 
+/// \brief Subtracts the corresponding 8-bit integer values in the operands.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSUBB / PSUBB instruction.
+///
+/// \param __a
+///A 128-bit integer vector containing the minuends.
+/// \param __b
+///A 128-bit integer vector containing the subtrahends.
+/// \returns A 128-bit integer vector containing the differences of the values
+///in the operands.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_sub_epi8(__m128i __a, __m128i __b)
 {
   return (__m128i)((__v16qi)__a - (__v16qi)__b);
 }
 
+/// \brief Subtracts the corresponding 16-bit integer values in the operands.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPSUBW / PSUBW instruction.
+///
+/// \param __a
+///A 128-bit integer vector containing the minuends.
+/// \param __b
+///A 128-bit integer vector 

Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2016-04-08 Thread Eric Christopher via cfe-commits
echristo added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:2371
@@ +2370,3 @@
+
+Not all targets support this attribute.  ELF targets support this attribute 
when using binutils v2.20.1 or higher and glibc v2.11.1 or higher.  Non-ELF 
targets currently do not support this attribute.
+  }];

probinson wrote:
> echristo wrote:
> > probinson wrote:
> > > joerg wrote:
> > > > probinson wrote:
> > > > > echristo wrote:
> > > > > > rjmccall wrote:
> > > > > > > echristo wrote:
> > > > > > > > Probably better to say linux fwiw and not ELF.
> > > > > > > The validation code in Sema is checking for an ELF target.  If 
> > > > > > > the restriction is more precise than that, then we should make a 
> > > > > > > TargetInfo callback.  Do the BSDs and other ELF targets not use 
> > > > > > > binutils/glibc?
> > > > > > We should make a TargetInfo callback. BSDs and other ELF targets 
> > > > > > aren't guaranteed to use binutils/glibc (some of them have even 
> > > > > > switched to llvm already) - and I don't know what the state of 
> > > > > > ifunc support on those architectures is.
> > > > > Hear hear. PS4 is ELF but we don't use glibc.
> > > > The attribute is not Linux specific, so ELF is a reasonable first 
> > > > approximation. Most BSDs have some ifunc support at least. I'm not in 
> > > > favor of doing any checks beyond ELF -- even on Linux the availability 
> > > > of working ifunc support depends on other factors like whether the 
> > > > binary is dynamically linked.
> > > What's the failure mode if the target doesn't actually support it?
> > The failure mode is an unknown relocation if your linker doesn't support 
> > it. If your linker supports it but your libc doesn't that'll be an unknown 
> > dynamic relocation at program start up.
> > 
> > In retrospect I think we can leave it just as an ELF check here and go. 
> > There are similar features in Mach-O that we might want this to use at some 
> > point as well so we can leave it as general as possible and rely on 
> > downstream tools to provide more errors?
> > 
> > I honestly don't have a strong opinion here given the current vaguely broad 
> > platform support and future possibilities.
> Yeah, we can live with that.
Cool. So in summary: "Ignore this entire thread" :)


http://reviews.llvm.org/D15524



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


Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2016-04-08 Thread Paul Robinson via cfe-commits
probinson added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:2371
@@ +2370,3 @@
+
+Not all targets support this attribute.  ELF targets support this attribute 
when using binutils v2.20.1 or higher and glibc v2.11.1 or higher.  Non-ELF 
targets currently do not support this attribute.
+  }];

echristo wrote:
> probinson wrote:
> > joerg wrote:
> > > probinson wrote:
> > > > echristo wrote:
> > > > > rjmccall wrote:
> > > > > > echristo wrote:
> > > > > > > Probably better to say linux fwiw and not ELF.
> > > > > > The validation code in Sema is checking for an ELF target.  If the 
> > > > > > restriction is more precise than that, then we should make a 
> > > > > > TargetInfo callback.  Do the BSDs and other ELF targets not use 
> > > > > > binutils/glibc?
> > > > > We should make a TargetInfo callback. BSDs and other ELF targets 
> > > > > aren't guaranteed to use binutils/glibc (some of them have even 
> > > > > switched to llvm already) - and I don't know what the state of ifunc 
> > > > > support on those architectures is.
> > > > Hear hear. PS4 is ELF but we don't use glibc.
> > > The attribute is not Linux specific, so ELF is a reasonable first 
> > > approximation. Most BSDs have some ifunc support at least. I'm not in 
> > > favor of doing any checks beyond ELF -- even on Linux the availability of 
> > > working ifunc support depends on other factors like whether the binary is 
> > > dynamically linked.
> > What's the failure mode if the target doesn't actually support it?
> The failure mode is an unknown relocation if your linker doesn't support it. 
> If your linker supports it but your libc doesn't that'll be an unknown 
> dynamic relocation at program start up.
> 
> In retrospect I think we can leave it just as an ELF check here and go. There 
> are similar features in Mach-O that we might want this to use at some point 
> as well so we can leave it as general as possible and rely on downstream 
> tools to provide more errors?
> 
> I honestly don't have a strong opinion here given the current vaguely broad 
> platform support and future possibilities.
Yeah, we can live with that.


http://reviews.llvm.org/D15524



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


r265839 - [analyzer] Teach trackNullOrUndefValue about calls to property accessors.

2016-04-08 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Apr  8 14:59:16 2016
New Revision: 265839

URL: http://llvm.org/viewvc/llvm-project?rev=265839=rev
Log:
[analyzer] Teach trackNullOrUndefValue about calls to property accessors.

Teach trackNullOrUndefValue() how to look through PseudoObjectExprs to find
the underlying method call for property getters. This makes over-suppression
of 'return nil' in getters consistent with the similar over-suppression for
method and function calls.

rdar://problem/24437252

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/inlining/false-positive-suppression.m

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=265839=265838=265839=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Fri Apr  8 
14:59:16 2016
@@ -908,6 +908,12 @@ static const Expr *peelOffOuterExpr(cons
 return peelOffOuterExpr(EWC->getSubExpr(), N);
   if (const OpaqueValueExpr *OVE = dyn_cast(Ex))
 return peelOffOuterExpr(OVE->getSourceExpr(), N);
+  if (auto *POE = dyn_cast(Ex)) {
+auto *PropRef = dyn_cast(POE->getSyntacticForm());
+if (PropRef && PropRef->isMessagingGetter()) {
+  return peelOffOuterExpr(POE->getSemanticExpr(1), N);
+}
+  }
 
   // Peel off the ternary operator.
   if (const ConditionalOperator *CO = dyn_cast(Ex)) {

Modified: cfe/trunk/test/Analysis/inlining/false-positive-suppression.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/false-positive-suppression.m?rev=265839=265838=265839=diff
==
--- cfe/trunk/test/Analysis/inlining/false-positive-suppression.m (original)
+++ cfe/trunk/test/Analysis/inlining/false-positive-suppression.m Fri Apr  8 
14:59:16 2016
@@ -36,3 +36,39 @@ void testNilReceiver(int coin) {
   else
 testNilReceiverHelperB([[x getObject] getPtr]);
 }
+
+// FALSE NEGATIVES (over-suppression)
+
+__attribute__((objc_root_class))
+@interface SomeClass
+-(int *)methodReturningNull;
+
+@property(readonly) int *propertyReturningNull;
+
+@end
+
+@implementation SomeClass
+-(int *)methodReturningNull {
+  return 0;
+}
+
+-(int *)propertyReturningNull {
+  return 0;
+}
+@end
+
+void testMethodReturningNull(SomeClass *sc) {
+  int *result = [sc methodReturningNull];
+  *result = 1;
+#ifndef SUPPRESSED
+  // expected-warning@-2 {{Dereference of null pointer}}
+#endif
+}
+
+void testPropertyReturningNull(SomeClass *sc) {
+  int *result = sc.propertyReturningNull;
+  *result = 1;
+#ifndef SUPPRESSED
+  // expected-warning@-2 {{Dereference of null pointer}}
+#endif
+}


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


Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2016-04-08 Thread Eric Christopher via cfe-commits
echristo added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:2371
@@ +2370,3 @@
+
+Not all targets support this attribute.  ELF targets support this attribute 
when using binutils v2.20.1 or higher and glibc v2.11.1 or higher.  Non-ELF 
targets currently do not support this attribute.
+  }];

probinson wrote:
> joerg wrote:
> > probinson wrote:
> > > echristo wrote:
> > > > rjmccall wrote:
> > > > > echristo wrote:
> > > > > > Probably better to say linux fwiw and not ELF.
> > > > > The validation code in Sema is checking for an ELF target.  If the 
> > > > > restriction is more precise than that, then we should make a 
> > > > > TargetInfo callback.  Do the BSDs and other ELF targets not use 
> > > > > binutils/glibc?
> > > > We should make a TargetInfo callback. BSDs and other ELF targets aren't 
> > > > guaranteed to use binutils/glibc (some of them have even switched to 
> > > > llvm already) - and I don't know what the state of ifunc support on 
> > > > those architectures is.
> > > Hear hear. PS4 is ELF but we don't use glibc.
> > The attribute is not Linux specific, so ELF is a reasonable first 
> > approximation. Most BSDs have some ifunc support at least. I'm not in favor 
> > of doing any checks beyond ELF -- even on Linux the availability of working 
> > ifunc support depends on other factors like whether the binary is 
> > dynamically linked.
> What's the failure mode if the target doesn't actually support it?
The failure mode is an unknown relocation if your linker doesn't support it. If 
your linker supports it but your libc doesn't that'll be an unknown dynamic 
relocation at program start up.

In retrospect I think we can leave it just as an ELF check here and go. There 
are similar features in Mach-O that we might want this to use at some point as 
well so we can leave it as general as possible and rely on downstream tools to 
provide more errors?

I honestly don't have a strong opinion here given the current vaguely broad 
platform support and future possibilities.


http://reviews.llvm.org/D15524



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


r265838 - [modules] Handle merged fields in designated initializers.

2016-04-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Apr  8 14:57:40 2016
New Revision: 265838

URL: http://llvm.org/viewvc/llvm-project?rev=265838=rev
Log:
[modules] Handle merged fields in designated initializers.

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h
cfe/trunk/test/Modules/merge-decl-context.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=265838=265837=265838=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Fri Apr  8 14:57:40 2016
@@ -2227,8 +2227,10 @@ InitListChecker::CheckDesignatedInitiali
 for (auto *FI : RT->getDecl()->fields()) {
   if (FI->isUnnamedBitfield())
 continue;
-  if (KnownField == FI)
+  if (declaresSameEntity(KnownField, FI)) {
+KnownField = FI;
 break;
+  }
   ++FieldIndex;
 }
 
@@ -2241,11 +2243,11 @@ InitListChecker::CheckDesignatedInitiali
   FieldIndex = 0;
   if (!VerifyOnly) {
 FieldDecl *CurrentField = StructuredList->getInitializedFieldInUnion();
-if (CurrentField && CurrentField != *Field) {
+if (CurrentField && !declaresSameEntity(CurrentField, *Field)) {
   assert(StructuredList->getNumInits() == 1
  && "A union should never have more than one initializer!");
 
-  // we're about to throw away an initializer, emit warning
+  // We're about to throw away an initializer, emit warning.
   SemaRef.Diag(D->getFieldLoc(),
diag::warn_initializer_overrides)
 << D->getSourceRange();

Modified: cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h?rev=265838=265837=265838=diff
==
--- cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h (original)
+++ cfe/trunk/test/Modules/Inputs/merge-decl-context/a.h Fri Apr  8 14:57:40 
2016
@@ -21,4 +21,8 @@ inline A ff(int i) {
   return fff();
 }
 
+struct Aggregate {
+  int member;
+};
+
 #endif

Modified: cfe/trunk/test/Modules/merge-decl-context.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-decl-context.cpp?rev=265838=265837=265838=diff
==
--- cfe/trunk/test/Modules/merge-decl-context.cpp (original)
+++ cfe/trunk/test/Modules/merge-decl-context.cpp Fri Apr  8 14:57:40 2016
@@ -18,7 +18,13 @@
 // RUN: 
-fmodule-map-file=%S/Inputs/merge-decl-context/merge-decl-context.modulemap 
-I%S/Inputs \
 // RUN: -emit-llvm -o %t/test.o %s
 
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t \
+// RUN: 
-fmodule-map-file=%S/Inputs/merge-decl-context/merge-decl-context.modulemap 
-I%S/Inputs \
+// RUN: -emit-llvm -o %t/test.o -DNO_TEXTUAL_INCLUSION %s
+
+#ifndef NO_TEXTUAL_INCLUSION
 #include "Inputs/merge-decl-context/a.h"
+#endif
 #include "Inputs/merge-decl-context/b.h"
 #include "Inputs/merge-decl-context/c.h"
 #include "Inputs/merge-decl-context/d.h"
@@ -26,3 +32,5 @@
 void t() {
   ff(42);
 }
+
+static_assert(Aggregate{.member = 1}.member == 1, "");


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


Re: [PATCH] D17933: Set MaxAtomicInlineWidth properly for i386, i486, and x86-64 cpus without cmpxchg16b.

2016-04-08 Thread James Y Knight via cfe-commits
jyknight added a comment.

ping.


http://reviews.llvm.org/D17933



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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-04-08 Thread Alex Rosenberg via cfe-commits
alexr added a subscriber: alexr.
alexr added a comment.

There are multiple features in this patch that should be considered separately. 
Please split the patch.

That said, I don't think we want to add a fundamental new preprocessor feature 
like __FILE_BASENAME__ without at least getting some early buy-in from the WG14 
and WG21 committees. I suspect they’d not want to add to the preprocessor at 
all.

The flag concept seems much more tractable. Please split it into two flags, one 
to force __FILE__ to only be the basename, and one that handles the prefix 
stripping. That is, a magic value of __ALL_DIR__ seems like the wrong choice 
here.


http://reviews.llvm.org/D17741



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


Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2016-04-08 Thread Eric Christopher via cfe-commits
On Fri, Apr 8, 2016, 10:45 AM Paul Robinson <
paul_robin...@playstation.sony.com> wrote:

> probinson added inline comments.
>
> 
> Comment at: include/clang/Basic/AttrDocs.td:2371
> @@ +2370,3 @@
> +
> +Not all targets support this attribute.  ELF targets support this
> attribute when using binutils v2.20.1 or higher and glibc v2.11.1 or
> higher.  Non-ELF targets currently do not support this attribute.
> +  }];
> 
> joerg wrote:
> > probinson wrote:
> > > echristo wrote:
> > > > rjmccall wrote:
> > > > > echristo wrote:
> > > > > > Probably better to say linux fwiw and not ELF.
> > > > > The validation code in Sema is checking for an ELF target.  If the
> restriction is more precise than that, then we should make a TargetInfo
> callback.  Do the BSDs and other ELF targets not use binutils/glibc?
> > > > We should make a TargetInfo callback. BSDs and other ELF targets
> aren't guaranteed to use binutils/glibc (some of them have even switched to
> llvm already) - and I don't know what the state of ifunc support on those
> architectures is.
> > > Hear hear. PS4 is ELF but we don't use glibc.
> > The attribute is not Linux specific, so ELF is a reasonable first
> approximation. Most BSDs have some ifunc support at least. I'm not in favor
> of doing any checks beyond ELF -- even on Linux the availability of working
> ifunc support depends on other factors like whether the binary is
> dynamically linked.
> What's the failure mode if the target doesn't actually support it?
>

Unknown relocation likely.



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


Re: [PATCH] D18843: Always have clang pass -pie-level and -pic-level values to the code generator

2016-04-08 Thread Wei Mi via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL265816: Always have clang pass -pie-level and -pic-level 
values to the code generator. (authored by wmi).

Changed prior to commit:
  http://reviews.llvm.org/D18843?vs=52945=53038#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18843

Files:
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2106,6 +2106,7 @@
   InputArgList Args =
   Opts->ParseArgs(llvm::makeArrayRef(ArgBegin, ArgEnd), MissingArgIndex,
   MissingArgCount, IncludedFlagsBitmask);
+  LangOptions  = *Res.getLangOpts();
 
   // Check for missing argument error.
   if (MissingArgCount) {
@@ -2124,7 +2125,7 @@
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
   Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, );
-  ParseCommentArgs(Res.getLangOpts()->CommentOpts, Args);
+  ParseCommentArgs(LangOpts.CommentOpts, Args);
   ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
   // FIXME: We shouldn't have to pass the DashX option around here
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags);
@@ -2137,22 +2138,26 @@
 // PassManager in BackendUtil.cpp. They need to be initializd no matter
 // what the input type is.
 if (Args.hasArg(OPT_fobjc_arc))
-  Res.getLangOpts()->ObjCAutoRefCount = 1;
+  LangOpts.ObjCAutoRefCount = 1;
+// PIClevel and PIELevel are needed during code generation and this should 
be
+// set regardless of the input type.
+LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+LangOpts.PIELevel = getLastArgIntValue(Args, OPT_pie_level, 0, Diags);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
-Diags, Res.getLangOpts()->Sanitize);
+Diags, LangOpts.Sanitize);
   } else {
 // Other LangOpts are only initialzed when the input is not AST or LLVM IR.
-ParseLangArgs(*Res.getLangOpts(), Args, DashX, Res.getTargetOpts(), Diags);
+ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(), Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
-  Res.getLangOpts()->ObjCExceptions = 1;
+  LangOpts.ObjCExceptions = 1;
   }
 
   // FIXME: Override value name discarding when asan or msan is used because 
the
   // backend passes depend on the name of the alloca in order to print out
   // names.
   Res.getCodeGenOpts().DiscardValueNames &=
-  !Res.getLangOpts()->Sanitize.has(SanitizerKind::Address) &&
-  !Res.getLangOpts()->Sanitize.has(SanitizerKind::Memory);
+  !LangOpts.Sanitize.has(SanitizerKind::Address) &&
+  !LangOpts.Sanitize.has(SanitizerKind::Memory);
 
   // FIXME: ParsePreprocessorArgs uses the FileManager to read the contents of
   // PCH file and find the original header name. Remove the need to do that in


Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2106,6 +2106,7 @@
   InputArgList Args =
   Opts->ParseArgs(llvm::makeArrayRef(ArgBegin, ArgEnd), MissingArgIndex,
   MissingArgCount, IncludedFlagsBitmask);
+  LangOptions  = *Res.getLangOpts();
 
   // Check for missing argument error.
   if (MissingArgCount) {
@@ -2124,7 +2125,7 @@
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
   Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, );
-  ParseCommentArgs(Res.getLangOpts()->CommentOpts, Args);
+  ParseCommentArgs(LangOpts.CommentOpts, Args);
   ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
   // FIXME: We shouldn't have to pass the DashX option around here
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags);
@@ -2137,22 +2138,26 @@
 // PassManager in BackendUtil.cpp. They need to be initializd no matter
 // what the input type is.
 if (Args.hasArg(OPT_fobjc_arc))
-  Res.getLangOpts()->ObjCAutoRefCount = 1;
+  LangOpts.ObjCAutoRefCount = 1;
+// PIClevel and PIELevel are needed during code generation and this should be
+// set regardless of the input type.
+LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+LangOpts.PIELevel = getLastArgIntValue(Args, OPT_pie_level, 0, Diags);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
-Diags, Res.getLangOpts()->Sanitize);
+Diags, LangOpts.Sanitize);
   } else {
 // Other LangOpts are only 

r265816 - Always have clang pass -pie-level and -pic-level values to the code generator.

2016-04-08 Thread Wei Mi via cfe-commits
Author: wmi
Date: Fri Apr  8 12:42:32 2016
New Revision: 265816

URL: http://llvm.org/viewvc/llvm-project?rev=265816=rev
Log:
Always have clang pass -pie-level and -pic-level values to the code generator.

Patch by tmsriram!

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

Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=265816=265815=265816=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Apr  8 12:42:32 2016
@@ -2106,6 +2106,7 @@ bool CompilerInvocation::CreateFromArgs(
   InputArgList Args =
   Opts->ParseArgs(llvm::makeArrayRef(ArgBegin, ArgEnd), MissingArgIndex,
   MissingArgCount, IncludedFlagsBitmask);
+  LangOptions  = *Res.getLangOpts();
 
   // Check for missing argument error.
   if (MissingArgCount) {
@@ -2124,7 +2125,7 @@ bool CompilerInvocation::CreateFromArgs(
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
   Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, );
-  ParseCommentArgs(Res.getLangOpts()->CommentOpts, Args);
+  ParseCommentArgs(LangOpts.CommentOpts, Args);
   ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
   // FIXME: We shouldn't have to pass the DashX option around here
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags);
@@ -2137,22 +2138,26 @@ bool CompilerInvocation::CreateFromArgs(
 // PassManager in BackendUtil.cpp. They need to be initializd no matter
 // what the input type is.
 if (Args.hasArg(OPT_fobjc_arc))
-  Res.getLangOpts()->ObjCAutoRefCount = 1;
+  LangOpts.ObjCAutoRefCount = 1;
+// PIClevel and PIELevel are needed during code generation and this should 
be
+// set regardless of the input type.
+LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+LangOpts.PIELevel = getLastArgIntValue(Args, OPT_pie_level, 0, Diags);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
-Diags, Res.getLangOpts()->Sanitize);
+Diags, LangOpts.Sanitize);
   } else {
 // Other LangOpts are only initialzed when the input is not AST or LLVM IR.
-ParseLangArgs(*Res.getLangOpts(), Args, DashX, Res.getTargetOpts(), Diags);
+ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(), Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
-  Res.getLangOpts()->ObjCExceptions = 1;
+  LangOpts.ObjCExceptions = 1;
   }
 
   // FIXME: Override value name discarding when asan or msan is used because 
the
   // backend passes depend on the name of the alloca in order to print out
   // names.
   Res.getCodeGenOpts().DiscardValueNames &=
-  !Res.getLangOpts()->Sanitize.has(SanitizerKind::Address) &&
-  !Res.getLangOpts()->Sanitize.has(SanitizerKind::Memory);
+  !LangOpts.Sanitize.has(SanitizerKind::Address) &&
+  !LangOpts.Sanitize.has(SanitizerKind::Memory);
 
   // FIXME: ParsePreprocessorArgs uses the FileManager to read the contents of
   // PCH file and find the original header name. Remove the need to do that in


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


Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2016-04-08 Thread Paul Robinson via cfe-commits
probinson added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:2371
@@ +2370,3 @@
+
+Not all targets support this attribute.  ELF targets support this attribute 
when using binutils v2.20.1 or higher and glibc v2.11.1 or higher.  Non-ELF 
targets currently do not support this attribute.
+  }];

joerg wrote:
> probinson wrote:
> > echristo wrote:
> > > rjmccall wrote:
> > > > echristo wrote:
> > > > > Probably better to say linux fwiw and not ELF.
> > > > The validation code in Sema is checking for an ELF target.  If the 
> > > > restriction is more precise than that, then we should make a TargetInfo 
> > > > callback.  Do the BSDs and other ELF targets not use binutils/glibc?
> > > We should make a TargetInfo callback. BSDs and other ELF targets aren't 
> > > guaranteed to use binutils/glibc (some of them have even switched to llvm 
> > > already) - and I don't know what the state of ifunc support on those 
> > > architectures is.
> > Hear hear. PS4 is ELF but we don't use glibc.
> The attribute is not Linux specific, so ELF is a reasonable first 
> approximation. Most BSDs have some ifunc support at least. I'm not in favor 
> of doing any checks beyond ELF -- even on Linux the availability of working 
> ifunc support depends on other factors like whether the binary is dynamically 
> linked.
What's the failure mode if the target doesn't actually support it?


http://reviews.llvm.org/D15524



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


[clang-tools-extra] r265813 - [Release Notes] Sort checks alphabetically.

2016-04-08 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Fri Apr  8 12:21:27 2016
New Revision: 265813

URL: http://llvm.org/viewvc/llvm-project?rev=265813=rev
Log:
[Release Notes] Sort checks alphabetically.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=265813=265812=265813=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Fri Apr  8 12:21:27 2016
@@ -74,6 +74,12 @@ identified.  The improvements since the
 
   Flags ``for`` loops where the induction expression has a floating-point type.
 
+- New `cppcoreguidelines-interfaces-global-init
+  
`_
 check
+
+  Flags initializers of globals that access extern objects, and therefore can
+  lead to order-of-initialization problems.
+
 - New `cppcoreguidelines-pro-type-member-init
   
`_
 check
 
@@ -164,13 +170,6 @@ identified.  The improvements since the
 
   Finds static function and variable definitions in anonymous namespace.
 
-- New `cppcoreguidelines-interfaces-global-init
-  
`_
 check
-
-  Flags initializers of globals that access extern objects, and therefore can
-  lead to order-of-initialization problems.
-
-
 Fixed bugs:
 
 - Crash when running on compile database with relative source files paths.


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


Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-04-08 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: test/SemaCXX/MicrosoftExtensions.cpp:89
@@ -84,1 +88,3 @@
+void foo_unaligned(int arg) {}
+void foo_unaligned(__unaligned int *arg) {}
 

Surely we can come up with some tougher overloading test cases. I noticed MSVC 
generates a warning when converting from '__unaligned T*' to 'T*' with this 
code:
```
extern "C" int puts(const char *);
void f(__unaligned int *p) {
  puts("unaligned");
}
void f(int *p) {
  puts("aligned");
}
void g(int *p) {
  puts("g");
}
int main() {
  int *p = 0;
  __unaligned int *q = 0;
  f(p);
  f(q);
  g(p);
  g(q); // C4090
}
```


http://reviews.llvm.org/D18596



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


r265807 - Move EABIVersion from CodeGenOptions to TargetOptions

2016-04-08 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Apr  8 11:52:05 2016
New Revision: 265807

URL: http://llvm.org/viewvc/llvm-project?rev=265807=rev
Log:
Move EABIVersion from CodeGenOptions to TargetOptions

It is possible to argue that the EABIVersion field is similar in spirit to the
ABI field in TargetOptions.  It represents the embedded ABI that the target
follows.  This will allow us to thread this information into the target
information construction.

Modified:
cfe/trunk/include/clang/Basic/TargetOptions.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/TargetOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetOptions.h?rev=265807=265806=265807=diff
==
--- cfe/trunk/include/clang/Basic/TargetOptions.h (original)
+++ cfe/trunk/include/clang/Basic/TargetOptions.h Fri Apr  8 11:52:05 2016
@@ -36,6 +36,9 @@ public:
   /// If given, the name of the target ABI to use.
   std::string ABI;
 
+  /// The EABI version to use
+  std::string EABIVersion;
+
   /// If given, the version string of the linker in use.
   std::string LinkerVersion;
 
@@ -45,7 +48,7 @@ public:
   /// The list of target specific features to enable or disable -- this should
   /// be a list of strings starting with by '+' or '-'.
   std::vector Features;
-  
+
   std::vector Reciprocals;
 };
 

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.h?rev=265807=265806=265807=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.h Fri Apr  8 11:52:05 2016
@@ -159,9 +159,6 @@ public:
   /// importing.
   std::string ThinLTOIndexFile;
 
-  /// The EABI version to use
-  std::string EABIVersion;
-
   /// A list of file names passed with -fcuda-include-gpubinary options to
   /// forward to CUDA runtime back-end for incorporating them into host-side
   /// object file.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=265807=265806=265807=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Apr  8 11:52:05 2016
@@ -552,7 +552,7 @@ TargetMachine *EmitAssemblyHelper::Creat
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
 
   // Set EABI version.
-  Options.EABIVersion = llvm::StringSwitch(CodeGenOpts.EABIVersion)
+  Options.EABIVersion = llvm::StringSwitch(TargetOpts.EABIVersion)
 .Case("4", llvm::EABI::EABI4)
 .Case("5", llvm::EABI::EABI5)
 .Case("gnu", llvm::EABI::GNU)

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=265807=265806=265807=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Apr  8 11:52:05 2016
@@ -545,20 +545,6 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
-  if (Arg *A = Args.getLastArg(OPT_meabi)) {
-StringRef Value = A->getValue();
-llvm::EABI EABIVersion = llvm::StringSwitch(Value)
- .Case("default", llvm::EABI::Default)
- .Case("4", llvm::EABI::EABI4)
- .Case("5", llvm::EABI::EABI5)
- .Case("gnu", llvm::EABI::GNU)
- .Default(llvm::EABI::Unknown);
-if (EABIVersion == llvm::EABI::Unknown)
-  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
-<< Value;
-else
-  Opts.EABIVersion = Value;
-  }
   Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable);
   Opts.LimitFloatPrecision = Args.getLastArgValue(OPT_mlimit_float_precision);
   Opts.NoInfsFPMath = (Args.hasArg(OPT_menable_no_infinities) ||
@@ -2078,9 +2064,24 @@ static void ParsePreprocessorOutputArgs(
   Opts.UseLineDirectives = Args.hasArg(OPT_fuse_line_directives);
 }
 
-static void ParseTargetArgs(TargetOptions , ArgList ) {
+static void ParseTargetArgs(TargetOptions , ArgList ,
+DiagnosticsEngine ) {
   using namespace options;
   Opts.ABI = Args.getLastArgValue(OPT_target_abi);
+  if (Arg *A 

Re: [PATCH] D18657: Propagate missing empty exception spec from function declared in system header

2016-04-08 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla added a comment.

Friendly ping, please take a look.

Thank you,
Denis Zobnin


http://reviews.llvm.org/D18657



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


Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-04-08 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 53022.
andreybokhanko added a comment.

This patch implements "__unaligned" as a qualifier (as per David Majnemer's 
request).

Most of the changes are miscellaneous small stuff one has to add when adding a 
new qualifier.

Other notable things are:

- One bit is stolen from "AddressSpace" to store __unaligned. This resulted in 
changes in OpenCL code and tests, that implicitly assumed that AddressSpace 
size is 24 bits.
- Sema checks added. It verifies that __unaligned can be used with 
non-pointers, for overloading and that it doesn't get recognized without 
-fms-compatibility option.
- Proper mangling (along with tests) for __unaligned added. Note that 
non-pointer __unaligned args don't affect mangling.

Andrey


http://reviews.llvm.org/D18596

Files:
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/Attr.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/AST/MicrosoftMangle.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -609,7 +609,6 @@
 case tok::kw___ptr64:
 case tok::kw___w64:
 case tok::kw___ptr32:
-case tok::kw___unaligned:
 case tok::kw___sptr:
 case tok::kw___uptr: {
   IdentifierInfo *AttrName = Tok.getIdentifierInfo();
@@ -3087,6 +3086,11 @@
   break;
 }
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
+
 case tok::kw___sptr:
 case tok::kw___uptr:
 case tok::kw___ptr64:
@@ -3097,7 +3101,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
 
@@ -4800,6 +4803,10 @@
   ParseOpenCLQualifiers(DS.getAttributes());
   break;
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
 case tok::kw___uptr:
   // GNU libc headers in C mode use '__uptr' as an identifer which conflicts
   // with the MS modifier keyword.
@@ -4817,7 +4824,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
@@ -5040,7 +5046,8 @@
 DS.getConstSpecLoc(),
 DS.getVolatileSpecLoc(),
 DS.getRestrictSpecLoc(),
-DS.getAtomicSpecLoc()),
+DS.getAtomicSpecLoc(),
+DS.getUnalignedSpecLoc()),
 DS.getAttributes(),
 SourceLocation());
 else
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -833,7 +833,7 @@
   // '(' abstract-declarator ')'
   if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,
   tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,
-  tok::kw___vectorcall, tok::kw___unaligned))
+  tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1444,6 +1444,9 @@
   (PointeeType.isNull() || !PointeeType->isFunctionType()))
 Out << 'E';
 
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
+
   if (HasRestrict)
 Out << 'I';
 }
@@ -1577,6 +1580,8 @@
 }
 break;
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';
   mangleQualifiers(Quals, false);
Index: lib/Sema/SemaType.cpp
===
--- 

Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2016-04-08 Thread Joerg Sonnenberger via cfe-commits
joerg added a subscriber: joerg.


Comment at: include/clang/Basic/AttrDocs.td:2066
@@ -2065,3 +2065,3 @@
   let Content = [{
 Clang supports the GNU style ``__attribute__((interrupt))`` attribute on
 x86/x86-64 targets.The compiler generates function entry and exit sequences

I'd really prefer such checks to be more strict, meaning:


  # It can return a `void *` pointer, no further signature checks are done
  # It can be a function pointer. In that case, it must match the signature of 
the function declaration the attribute is on.


Comment at: include/clang/Basic/AttrDocs.td:2371
@@ +2370,3 @@
+
+Not all targets support this attribute.  ELF targets support this attribute 
when using binutils v2.20.1 or higher and glibc v2.11.1 or higher.  Non-ELF 
targets currently do not support this attribute.
+  }];

probinson wrote:
> echristo wrote:
> > rjmccall wrote:
> > > echristo wrote:
> > > > Probably better to say linux fwiw and not ELF.
> > > The validation code in Sema is checking for an ELF target.  If the 
> > > restriction is more precise than that, then we should make a TargetInfo 
> > > callback.  Do the BSDs and other ELF targets not use binutils/glibc?
> > We should make a TargetInfo callback. BSDs and other ELF targets aren't 
> > guaranteed to use binutils/glibc (some of them have even switched to llvm 
> > already) - and I don't know what the state of ifunc support on those 
> > architectures is.
> Hear hear. PS4 is ELF but we don't use glibc.
The attribute is not Linux specific, so ELF is a reasonable first 
approximation. Most BSDs have some ifunc support at least. I'm not in favor of 
doing any checks beyond ELF -- even on Linux the availability of working ifunc 
support depends on other factors like whether the binary is dynamically linked.


http://reviews.llvm.org/D15524



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


Re: [PATCH] D17821: [OpenCL] Complete image types support

2016-04-08 Thread Alexey Bader via cfe-commits
bader added a comment.

In http://reviews.llvm.org/D17821#394708, @bader wrote:

> In http://reviews.llvm.org/D17821#394620, @Anastasia wrote:
>
> > Yes, I think it's better to go in a separate commit, not to complicate this 
> > one too much. Also since there are not many comment here, I think we should 
> > try to commit it ASAP otherwise rebasing would be an issue.
>
>
> I can commit it tomorrow if there are no other comments.


Committed @265783


Repository:
  rL LLVM

http://reviews.llvm.org/D17821



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


Re: [PATCH] D17821: [OpenCL] Complete image types support

2016-04-08 Thread Alexey Bader via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL265783: [OpenCL] Complete image types support. (authored by 
bader).

Changed prior to commit:
  http://reviews.llvm.org/D17821?vs=51303=53021#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17821

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/BuiltinTypes.def
  cfe/trunk/include/clang/AST/OpenCLImageTypes.def
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/include/clang/Basic/Specifiers.h
  cfe/trunk/include/clang/Basic/TokenKinds.def
  cfe/trunk/include/clang/Sema/DeclSpec.h
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/lib/AST/NSAPI.cpp
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/lib/AST/TypeLoc.cpp
  cfe/trunk/lib/Analysis/PrintfFormatString.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
  cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/Index/USRGeneration.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Parse/ParseTentative.cpp
  cfe/trunk/lib/Sema/DeclSpec.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/lib/Serialization/ASTCommon.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/test/CodeGenOpenCL/images.cl
  cfe/trunk/test/CodeGenOpenCL/opencl_types.cl
  cfe/trunk/test/SemaOpenCL/images.cl
  cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
  cfe/trunk/test/SemaOpenCL/invalid-image.cl
  cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl
  cfe/trunk/tools/libclang/CIndex.cpp

Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2536,18 +2536,9 @@
 case BuiltinType::UInt128:
   return true;
 
-case BuiltinType::OCLImage1d:
-case BuiltinType::OCLImage1dArray:
-case BuiltinType::OCLImage1dBuffer:
-case BuiltinType::OCLImage2d:
-case BuiltinType::OCLImage2dArray:
-case BuiltinType::OCLImage2dDepth:
-case BuiltinType::OCLImage2dArrayDepth:
-case BuiltinType::OCLImage2dMSAA:
-case BuiltinType::OCLImage2dArrayMSAA:
-case BuiltinType::OCLImage2dMSAADepth:
-case BuiltinType::OCLImage2dArrayMSAADepth:
-case BuiltinType::OCLImage3d:
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+case BuiltinType::Id:
+#include "clang/AST/OpenCLImageTypes.def"
 case BuiltinType::OCLSampler:
 case BuiltinType::OCLEvent:
 case BuiltinType::OCLClkEvent:
Index: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
@@ -464,18 +464,9 @@
   ResultType = llvm::IntegerType::get(getLLVMContext(), 128);
   break;
 
-case BuiltinType::OCLImage1d:
-case BuiltinType::OCLImage1dArray:
-case BuiltinType::OCLImage1dBuffer:
-case BuiltinType::OCLImage2d:
-case BuiltinType::OCLImage2dArray:
-case BuiltinType::OCLImage2dDepth:
-case BuiltinType::OCLImage2dArrayDepth:
-case BuiltinType::OCLImage2dMSAA:
-case BuiltinType::OCLImage2dArrayMSAA:
-case BuiltinType::OCLImage2dMSAADepth:
-case BuiltinType::OCLImage2dArrayMSAADepth:
-case BuiltinType::OCLImage3d:
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+case BuiltinType::Id:
+#include "clang/AST/OpenCLImageTypes.def"
 case BuiltinType::OCLSampler:
 case BuiltinType::OCLEvent:
 case BuiltinType::OCLClkEvent:
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -463,39 +463,11 @@
 return SelTy;
   }
 
-  case BuiltinType::OCLImage1d:
-return getOrCreateStructPtrType("opencl_image1d_t", OCLImage1dDITy);
-  case BuiltinType::OCLImage1dArray:
-return getOrCreateStructPtrType("opencl_image1d_array_t",
-OCLImage1dArrayDITy);
-  case BuiltinType::OCLImage1dBuffer:
-return getOrCreateStructPtrType("opencl_image1d_buffer_t",
-OCLImage1dBufferDITy);
-  case BuiltinType::OCLImage2d:
-return getOrCreateStructPtrType("opencl_image2d_t", OCLImage2dDITy);
-  case BuiltinType::OCLImage2dArray:
-return getOrCreateStructPtrType("opencl_image2d_array_t",
-OCLImage2dArrayDITy);
-  case BuiltinType::OCLImage2dDepth:
-return 

r265782 - Silencing a 32-bit shift implicit conversion warning from MSVC; NFC.

2016-04-08 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Apr  8 07:21:58 2016
New Revision: 265782

URL: http://llvm.org/viewvc/llvm-project?rev=265782=rev
Log:
Silencing a 32-bit shift implicit conversion warning from MSVC; NFC.

Modified:
cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp

Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=265782=265781=265782=diff
==
--- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original)
+++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Fri Apr  8 07:21:58 2016
@@ -603,7 +603,7 @@ CharUnits swiftcall::getNaturalAlignment
   // rounded up to a power of 2.
   auto size = (unsigned long long) getTypeStoreSize(CGM, type).getQuantity();
   if (!isPowerOf2(size)) {
-size = 1U << (llvm::findLastSet(size, llvm::ZB_Undefined) + 1);
+size = 1ULL << (llvm::findLastSet(size, llvm::ZB_Undefined) + 1);
   }
   assert(size >= CGM.getDataLayout().getABITypeAlignment(type));
   return CharUnits::fromQuantity(size);


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


Re: [PATCH] D18649: [clang-tidy] cppcoreguidelines-interfaces-global-init

2016-04-08 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL265774: [clang-tidy] 
cppcoreguidelines-interfaces-global-init (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D18649?vs=53001=53010#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18649

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/InterfacesGlobalInitCheck.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-interfaces-global-init.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-interfaces-global-init.cpp

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
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "../misc/AssignOperatorSignatureCheck.h"
+#include "InterfacesGlobalInitCheck.h"
 #include "ProBoundsArrayToPointerDecayCheck.h"
 #include "ProBoundsConstantArrayIndexCheck.h"
 #include "ProBoundsPointerArithmeticCheck.h"
@@ -30,6 +31,8 @@
 class CppCoreGuidelinesModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"cppcoreguidelines-interfaces-global-init");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
 CheckFactories.registerCheck(
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
+  InterfacesGlobalInitCheck.cpp
   ProBoundsArrayToPointerDecayCheck.cpp
   ProBoundsConstantArrayIndexCheck.cpp
   ProBoundsPointerArithmeticCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.h
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.h
@@ -0,0 +1,35 @@
+//===--- InterfacesGlobalInitCheck.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_INTERFACES_GLOBAL_INIT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_INTERFACES_GLOBAL_INIT_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+/// Flags possible initialization order issues of static variables.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-interfaces-global-init.html
+class InterfacesGlobalInitCheck : public ClangTidyCheck {
+public:
+  InterfacesGlobalInitCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace cppcoreguidelines
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_INTERFACES_GLOBAL_INIT_H
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp
@@ -0,0 +1,59 @@
+//===--- InterfacesGlobalInitCheck.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 "InterfacesGlobalInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include 

[clang-tools-extra] r265774 - [clang-tidy] cppcoreguidelines-interfaces-global-init

2016-04-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Apr  8 04:51:06 2016
New Revision: 265774

URL: http://llvm.org/viewvc/llvm-project?rev=265774=rev
Log:
[clang-tidy] cppcoreguidelines-interfaces-global-init

Summary:
This check flags initializers of globals that access extern objects, and 
therefore can lead to order-of-initialization problems (this recommandation is 
part of CPP core guidelines).
Note that this only checks half of the guideline for now (it does not enforce 
using constexpr functions).

Reviewers: aaron.ballman, alexfh

Subscribers: aaron.ballman, etienneb, Eugene.Zelenko, cfe-commits

Patch by Clement Courbet!

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

Added:

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

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

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-interfaces-global-init.rst

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-interfaces-global-init.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/ReleaseNotes.rst
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=265774=265773=265774=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Fri Apr 
 8 04:51:06 2016
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCppCoreGuidelinesModule
   CppCoreGuidelinesTidyModule.cpp
+  InterfacesGlobalInitCheck.cpp
   ProBoundsArrayToPointerDecayCheck.cpp
   ProBoundsConstantArrayIndexCheck.cpp
   ProBoundsPointerArithmeticCheck.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=265774=265773=265774=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Fri Apr  8 04:51:06 2016
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "../misc/AssignOperatorSignatureCheck.h"
+#include "InterfacesGlobalInitCheck.h"
 #include "ProBoundsArrayToPointerDecayCheck.h"
 #include "ProBoundsConstantArrayIndexCheck.h"
 #include "ProBoundsPointerArithmeticCheck.h"
@@ -30,6 +31,8 @@ namespace cppcoreguidelines {
 class CppCoreGuidelinesModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
+CheckFactories.registerCheck(
+"cppcoreguidelines-interfaces-global-init");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp?rev=265774=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp
 Fri Apr  8 04:51:06 2016
@@ -0,0 +1,59 @@
+//===--- InterfacesGlobalInitCheck.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 "InterfacesGlobalInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+void InterfacesGlobalInitCheck::registerMatchers(MatchFinder *Finder) {
+  const auto IsGlobal =
+  allOf(hasGlobalStorage(),
+hasDeclContext(anyOf(translationUnitDecl(), // Global scope.
+ namespaceDecl(),   // Namespace scope.
+ recordDecl())),// Class scope.
+unless(isConstexpr()));
+
+  const auto ReferencesUndefinedGlobalVar = declRefExpr(hasDeclaration(
+  varDecl(IsGlobal, 

Re: [PATCH] D18649: [clang-tidy] cppcoreguidelines-interfaces-global-init

2016-04-08 Thread Clement Courbet via cfe-commits
courbet added a comment.

That'd be great. Thanks all for the review.


http://reviews.llvm.org/D18649



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


Re: [PATCH] D18649: [clang-tidy] cppcoreguidelines-interfaces-global-init

2016-04-08 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 53001.
courbet added a comment.

Rebase on HEAD for submission.


http://reviews.llvm.org/D18649

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp
  clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-interfaces-global-init.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-interfaces-global-init.cpp

Index: test/clang-tidy/cppcoreguidelines-interfaces-global-init.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-interfaces-global-init.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-interfaces-global-init %t
+
+constexpr int makesInt() { return 3; }
+constexpr int takesInt(int i) { return i + 1; }
+constexpr int takesIntPtr(int *i) { return *i; }
+
+extern int ExternGlobal;
+static int GlobalScopeBadInit1 = ExternGlobal;
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+static int GlobalScopeBadInit2 = takesInt(ExternGlobal);
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+static int GlobalScopeBadInit3 = takesIntPtr();
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+static int GlobalScopeBadInit4 = 3 * (ExternGlobal + 2);
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+
+namespace ns {
+static int NamespaceScope = makesInt();
+static int NamespaceScopeBadInit = takesInt(ExternGlobal);
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+
+struct A {
+  static int ClassScope;
+  static int ClassScopeBadInit;
+};
+
+int A::ClassScopeBadInit = takesInt(ExternGlobal);
+// CHECK-MESSAGES: [[@LINE-1]]:8: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+
+static int FromClassBadInit = takesInt(A::ClassScope);
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ClassScope'
+} // namespace ns
+
+// "const int B::I;" is fine, it just ODR-defines B::I. See [9.4.3] Static
+// members [class.static]. However the ODR-definitions are not in the right
+// order (C::I after C::J, see [3.6.2.3]).
+class B1 {
+  static const int I = 0;
+  static const int J = I;
+};
+const int B1::J;
+// CHECK-MESSAGES: [[@LINE-1]]:15: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'I'
+const int B1::I;
+
+void f() {
+  // This is fine, it's executed after dynamic initialization occurs.
+  static int G = takesInt(ExternGlobal);
+}
+
+// Declaration then definition then usage is fine.
+extern int ExternGlobal2;
+extern int ExternGlobal2;
+int ExternGlobal2 = 123;
+static int GlobalScopeGoodInit1 = ExternGlobal2;
+
+
+// Defined global variables are fine:
+static int GlobalScope = makesInt();
+static int GlobalScopeGoodInit2 = takesInt(GlobalScope);
+static int GlobalScope2 = takesInt(ns::NamespaceScope);
+// Enums are fine.
+enum Enum { kEnumValue = 1 };
+static int GlobalScopeFromEnum = takesInt(kEnumValue);
+
+// Leave constexprs alone.
+extern constexpr int GlobalScopeConstexpr = makesInt();
+static constexpr int GlobalScopeConstexprOk =
+takesInt(GlobalScopeConstexpr);
+
+// This is a pretty common instance: People are usually not using constexpr, but
+// this is what they should write:
+static constexpr const char kValue[] = "value";
+constexpr int Fingerprint(const char *value) { return 0; }
+static int kFingerprint = Fingerprint(kValue);
+
+// This is fine because the ODR-definitions are in the right order (C::J after
+// C::I).
+class B2 {
+  static const int I = 0;
+  static const int J = I;
+};
+const int B2::I;
+const int B2::J;
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -16,6 +16,7 @@
cert-fio38-c (redirects to misc-non-copyable-objects) 
cert-flp30-c
cert-oop11-cpp (redirects to misc-move-constructor-init) 
+   cppcoreguidelines-interfaces-global-init
cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-bounds-constant-array-index
cppcoreguidelines-pro-bounds-pointer-arithmetic
Index: 

Re: [PATCH] D18584: Complete support for C++ Core Guidelines Type.6: Always initialize a member variable.

2016-04-08 Thread Michael Miller via cfe-commits
michael_miller marked 4 inline comments as done.
michael_miller added a comment.

In http://reviews.llvm.org/D18584#395208, @alexfh wrote:

> Looks good from my side. Please wait for the Aaron's approval.
>
> Thank you for working on this!


No problem! Thanks for taking the time to review and give feedback. clang-tidy 
is such a great tool. It's my honor and pleasure to be able to contribute and 
give back even a little!



Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:25
@@ -24,3 +24,3 @@
 
-namespace {
 

aaron.ballman wrote:
> Please do not remove the unnamed namespace; it is preferable to using static 
> functions.
Ok, I can put the anonymous namespace around everything and remove the static 
specifiers. I moved it down lower to enclose the local class definition because 
it wasn't previously. I would normally wrap the whole thing but the LLVM coding 
standards seem to say the opposite of what I'm used to doing with regard to 
static functions vs anonymous namespaces:
http://llvm.org/docs/CodingStandards.html#anonymous-namespaces


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:51
@@ +50,3 @@
+  return true;
+}
+

I was wondering about that too but didn't really know how to proceed. I did 
come across SemaExprCXX.cpp while looking to see how 
std::is_trivially_default_constructible was implemented. Being unfamiliar with 
that part of the codebase, though, I didn't dig too far into how to either 
share that code or hook into it.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:243
@@ +242,3 @@
+// initializer.
+static const NamedDecl *getInitializerDecl(const CXXCtorInitializer *Init) {
+  if (Init->isMemberInitializer())

aaron.ballman wrote:
> Since this function is only used once, I think it should be lowered into its 
> use as a ternary conditional.
I've gone ahead and done this but I think it's less readable afterwards. The 
reason it's problematic is because the return types from the two subexpressions 
aren't the same so it can't be used as a ternary conditional without a cast.


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:486
@@ +485,3 @@
+
+  // Do not propose fixes in macros since we cannot place them correctly.
+  if (Ctor->getLocStart().isMacroID())

aaron.ballman wrote:
> I think this code belongs in `fixInitializerList` then, doesn't it?
Sure. I think one reason I didn't was because of line 426 which is structured 
similarly. Stylistically, I slightly prefer to test the condition explicitly 
rather than have an early return but it's perfectly fine either way.


Comment at: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp:334
@@ +333,2 @@
+  // CHECK-FIXES: int X{};
+};

aaron.ballman wrote:
> I'd like to see how we handle the following test:
> ```
> struct S {
>   S(int i);
> };
> struct T {
>   T(float f);
> };
> 
> union U {
>   S s;
>   T t;
> };
> ```
For a number of reasons, it doesn't hit any warnings:
  # We don't do anything to record types without any members.
  # U doesn't have a user-provided constructor. We only initialize members if 
there's a user-provided constructor of some sort.
  # If we declared an instance of U as a local variable, we would have to 
explicitly initialize it. The default constructor is implicitly deleted because 
of S and T.








http://reviews.llvm.org/D18584



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


Re: [PATCH] D18649: [clang-tidy] cppcoreguidelines-interfaces-global-init

2016-04-08 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

(if you do, please rebase the patch on top of HEAD)


http://reviews.llvm.org/D18649



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


Re: [PATCH] D18649: [clang-tidy] cppcoreguidelines-interfaces-global-init

2016-04-08 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good! Thank you for the new check!

Do you need me to submit the patch for you?


http://reviews.llvm.org/D18649



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


Re: [PATCH] D18584: Complete support for C++ Core Guidelines Type.6: Always initialize a member variable.

2016-04-08 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

Looks good from my side. Please wait for the Aaron's approval.

Thank you for working on this!


http://reviews.llvm.org/D18584



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


Re: [PATCH] D18649: [clang-tidy] cppcoreguidelines-interfaces-global-init

2016-04-08 Thread Clement Courbet via cfe-commits
courbet added inline comments.


Comment at: test/clang-tidy/cppcoreguidelines-interfaces-global-init.cpp:7
@@ +6,3 @@
+
+extern int ExternGlobal;
+static int GlobalScopeBadInit1 = ExternGlobal;

alexfh wrote:
> What happens if you add:
> 
>   extern int ExternGlobal;
>   extern int ExternGlobal;
>   int ExternGlobal = 123;
> 
> ?
It does not trigger (as expected). I've added a test.


http://reviews.llvm.org/D18649



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


Re: [PATCH] D18649: [clang-tidy] cppcoreguidelines-interfaces-global-init

2016-04-08 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 52999.
courbet added a comment.

Add unit test for multiple declaration then definition.


http://reviews.llvm.org/D18649

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp
  clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-interfaces-global-init.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-interfaces-global-init.cpp

Index: test/clang-tidy/cppcoreguidelines-interfaces-global-init.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-interfaces-global-init.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-interfaces-global-init %t
+
+constexpr int makesInt() { return 3; }
+constexpr int takesInt(int i) { return i + 1; }
+constexpr int takesIntPtr(int *i) { return *i; }
+
+extern int ExternGlobal;
+static int GlobalScopeBadInit1 = ExternGlobal;
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+static int GlobalScopeBadInit2 = takesInt(ExternGlobal);
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+static int GlobalScopeBadInit3 = takesIntPtr();
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+static int GlobalScopeBadInit4 = 3 * (ExternGlobal + 2);
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+
+namespace ns {
+static int NamespaceScope = makesInt();
+static int NamespaceScopeBadInit = takesInt(ExternGlobal);
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+
+struct A {
+  static int ClassScope;
+  static int ClassScopeBadInit;
+};
+
+int A::ClassScopeBadInit = takesInt(ExternGlobal);
+// CHECK-MESSAGES: [[@LINE-1]]:8: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ExternGlobal'
+
+static int FromClassBadInit = takesInt(A::ClassScope);
+// CHECK-MESSAGES: [[@LINE-1]]:12: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'ClassScope'
+} // namespace ns
+
+// "const int B::I;" is fine, it just ODR-defines B::I. See [9.4.3] Static
+// members [class.static]. However the ODR-definitions are not in the right
+// order (C::I after C::J, see [3.6.2.3]).
+class B1 {
+  static const int I = 0;
+  static const int J = I;
+};
+const int B1::J;
+// CHECK-MESSAGES: [[@LINE-1]]:15: warning: initializing non-local variable with non-const expression depending on uninitialized non-local variable 'I'
+const int B1::I;
+
+void f() {
+  // This is fine, it's executed after dynamic initialization occurs.
+  static int G = takesInt(ExternGlobal);
+}
+
+// Declaration then definition then usage is fine.
+extern int ExternGlobal2;
+extern int ExternGlobal2;
+int ExternGlobal2 = 123;
+static int GlobalScopeGoodInit1 = ExternGlobal2;
+
+
+// Defined global variables are fine:
+static int GlobalScope = makesInt();
+static int GlobalScopeGoodInit2 = takesInt(GlobalScope);
+static int GlobalScope2 = takesInt(ns::NamespaceScope);
+// Enums are fine.
+enum Enum { kEnumValue = 1 };
+static int GlobalScopeFromEnum = takesInt(kEnumValue);
+
+// Leave constexprs alone.
+extern constexpr int GlobalScopeConstexpr = makesInt();
+static constexpr int GlobalScopeConstexprOk =
+takesInt(GlobalScopeConstexpr);
+
+// This is a pretty common instance: People are usually not using constexpr, but
+// this is what they should write:
+static constexpr const char kValue[] = "value";
+constexpr int Fingerprint(const char *value) { return 0; }
+static int kFingerprint = Fingerprint(kValue);
+
+// This is fine because the ODR-definitions are in the right order (C::J after
+// C::I).
+class B2 {
+  static const int I = 0;
+  static const int J = I;
+};
+const int B2::I;
+const int B2::J;
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -16,6 +16,7 @@
cert-fio38-c (redirects to misc-non-copyable-objects) 
cert-flp30-c
cert-oop11-cpp (redirects to misc-move-constructor-init) 
+   cppcoreguidelines-interfaces-global-init
cppcoreguidelines-pro-bounds-array-to-pointer-decay
cppcoreguidelines-pro-bounds-constant-array-index

Re: [PATCH] D18136: boost-use-to-string check

2016-04-08 Thread Marek Kurdej via cfe-commits
curdeius added a subscriber: curdeius.
curdeius added a comment.

Minor remark.



Comment at: docs/clang-tidy/checks/list.rst:7
@@ -6,2 +6,3 @@
 .. toctree::   
+   boost-use-to-string
cert-dcl03-c (redirects to misc-static-assert) 

toctree directive needs the next line to be blank


http://reviews.llvm.org/D18136



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