[PATCH] D24933: Enable configuration files in clang

2016-10-04 Thread Michał Górny via cfe-commits
mgorny added inline comments.


> driver.cpp:314
> +
> +static llvm::cl::SearchResult findConfigFileFromProgramName(
> +llvm::SmallVectorImpl &ConfigName, StringRef ProgramName) {

Please document what this function does, exactly. I see you've documented it in 
call site but a doc here would be helpful as well.

> driver.cpp:376
> +  // implicitly. First try deduce configuration from executable. For 
> instance,
> +  // file 'armv7l-clang' applies config file 'armv7l.cfg'.
> +  if (SRes == llvm::cl::SearchResult::NotSpecified) {

Are you sure about the name? I would rather see `TARGET-clang.cfg` than a name 
that doesn't explicitly mention that the file is for clang.

https://reviews.llvm.org/D24933



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


[PATCH] D24909: fix for not copying fp denormal and trapping options.

2016-10-04 Thread Sjoerd Meijer via cfe-commits
SjoerdMeijer abandoned this revision.
SjoerdMeijer added a comment.

Ok, thanks for the feedback and looking into this. I will abandon this change.
To still answer your question, there is nothing more to it than emitting an 
AArch64 build attribute symbol (for library selection).  This done based on 
function attributes and options. But I've now noticed that this (downstream) 
logic needs updating. Thanks again.


https://reviews.llvm.org/D24909



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


[PATCH] D24278: [analyzer] Extend bug reports with extra notes.

2016-10-04 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283092: [analyzer] Extend bug reports with extra notes 
(authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D24278?vs=72519&id=73406#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24278

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -266,6 +266,9 @@
   /// \sa shouldWidenLoops
   Optional WidenLoops;
 
+  /// \sa shouldDisplayNotesAsEvents
+  Optional DisplayNotesAsEvents;
+
   /// A helper function that retrieves option for a given full-qualified
   /// checker name.
   /// Options for checkers can be specified via 'analyzer-config' command-line
@@ -534,6 +537,14 @@
   /// This is controlled by the 'widen-loops' config option.
   bool shouldWidenLoops();
 
+  /// Returns true if the bug reporter should transparently treat extra note
+  /// diagnostic pieces as event diagnostic pieces. Useful when the diagnostic
+  /// consumer doesn't support the extra note pieces.
+  ///
+  /// This is controlled by the 'notes-as-events' option, which defaults
+  /// to false when unset.
+  bool shouldDisplayNotesAsEvents();
+
 public:
   AnalyzerOptions() :
 AnalysisStoreOpt(RegionStoreModel),
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
@@ -336,7 +336,7 @@
 
 class PathDiagnosticPiece : public RefCountedBaseVPTR {
 public:
-  enum Kind { ControlFlow, Event, Macro, Call };
+  enum Kind { ControlFlow, Event, Macro, Call, Note };
   enum DisplayHint { Above, Below };
 
 private:
@@ -452,7 +452,8 @@
   void Profile(llvm::FoldingSetNodeID &ID) const override;
 
   static bool classof(const PathDiagnosticPiece *P) {
-return P->getKind() == Event || P->getKind() == Macro;
+return P->getKind() == Event || P->getKind() == Macro ||
+   P->getKind() == Note;
   }
 };
 
@@ -710,6 +711,23 @@
   void Profile(llvm::FoldingSetNodeID &ID) const override;
 };
 
+class PathDiagnosticNotePiece: public PathDiagnosticSpotPiece {
+public:
+  PathDiagnosticNotePiece(const PathDiagnosticLocation &Pos, StringRef S,
+   bool AddPosRange = true)
+  : PathDiagnosticSpotPiece(Pos, S, Note, AddPosRange) {}
+
+  ~PathDiagnosticNotePiece() override;
+
+  static inline bool classof(const PathDiagnosticPiece *P) {
+return P->getKind() == Note;
+  }
+
+  void dump() const override;
+
+  void Profile(llvm::FoldingSetNodeID &ID) const override;
+};
+
 /// PathDiagnostic - PathDiagnostic objects represent a single path-sensitive
 ///  diagnostic.  It represents an ordered-collection of PathDiagnosticPieces,
 ///  each which represent the pieces of the path.
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -66,6 +66,8 @@
   typedef SmallVector, 8> VisitorList;
   typedef VisitorList::iterator visitor_iterator;
   typedef SmallVector ExtraTextList;
+  typedef SmallVector, 4>
+  NoteList;
 
 protected:
   friend class BugReporter;
@@ -82,7 +84,8 @@
   const ExplodedNode *ErrorNode;
   SmallVector Ranges;
   ExtraTextList ExtraText;
-  
+  NoteList Notes;
+
   typedef llvm::DenseSet Symbols;
   typedef llvm::DenseSet Regions;
 
@@ -177,6 +180,18 @@
   const BugType& getBugType() const { return BT; }
   BugType& getBugType() { return BT; }
 
+  /// \brief True when the report has an execution path associated with it.
+  ///
+  /// A report is said to be path-sensitive if it was thrown against a
+  /// particular exploded node in the path-sensitive analysis graph.
+  /// Path-sensitive reports have their intermediate path diagnostics
+  /// auto-generated, perhaps with the help of checker-defined visitors,
+  /// and may contain extra notes.
+  /// Path-insensitive reports consist

[PATCH] D25123: [OpenCL] Fix bug in __builtin_astype causing invalid LLVM cast instructions

2016-10-04 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283114: [OpenCL] Fix bug in __builtin_astype causing invalid 
LLVM cast instructions (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D25123?vs=73125&id=73412#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25123

Files:
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/test/CodeGenOpenCL/as_type.cl

Index: cfe/trunk/test/CodeGenOpenCL/as_type.cl
===
--- cfe/trunk/test/CodeGenOpenCL/as_type.cl
+++ cfe/trunk/test/CodeGenOpenCL/as_type.cl
@@ -66,3 +66,42 @@
 int3 f8(char16 x) {
   return __builtin_astype(x, int3);
 }
+
+//CHECK: define spir_func i32 addrspace(1)* @addr_cast(i32* readnone %[[x:.*]])
+//CHECK: %[[cast:.*]] = addrspacecast i32* %[[x]] to i32 addrspace(1)*
+//CHECK: ret i32 addrspace(1)* %[[cast]]
+global int* addr_cast(int *x) {
+  return __builtin_astype(x, global int*);
+}
+
+//CHECK: define spir_func i32 addrspace(1)* @int_to_ptr(i32 %[[x:.*]])
+//CHECK: %[[cast:.*]] = inttoptr i32 %[[x]] to i32 addrspace(1)*
+//CHECK: ret i32 addrspace(1)* %[[cast]]
+global int* int_to_ptr(int x) {
+  return __builtin_astype(x, global int*);
+}
+
+//CHECK: define spir_func i32 @ptr_to_int(i32* %[[x:.*]])
+//CHECK: %[[cast:.*]] = ptrtoint i32* %[[x]] to i32
+//CHECK: ret i32 %[[cast]]
+int ptr_to_int(int *x) {
+  return __builtin_astype(x, int);
+}
+
+//CHECK: define spir_func <3 x i8> @ptr_to_char3(i32* %[[x:.*]])
+//CHECK: %[[cast1:.*]] = ptrtoint i32* %[[x]] to i32
+//CHECK: %[[cast2:.*]] = bitcast i32 %[[cast1]] to <4 x i8>
+//CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[cast2]], <4 x i8> undef, <3 x i32> 
+//CHECK: ret <3 x i8> %[[astype]]
+char3 ptr_to_char3(int *x) {
+  return  __builtin_astype(x, char3);
+}
+
+//CHECK: define spir_func i32* @char3_to_ptr(<3 x i8> %[[x:.*]])
+//CHECK: %[[astype:.*]] = shufflevector <3 x i8> %[[x]], <3 x i8> undef, <4 x i32> 
+//CHECK: %[[cast1:.*]] = bitcast <4 x i8> %[[astype]] to i32
+//CHECK: %[[cast2:.*]] = inttoptr i32 %[[cast1]] to i32*
+//CHECK: ret i32* %[[cast2]]
+int* char3_to_ptr(char3 x) {
+  return __builtin_astype(x, int*);
+}
Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -3407,6 +3407,52 @@
   return Builder.CreateShuffleVector(Src, UnV, Mask);
 }
 
+// Create cast instructions for converting LLVM value \p Src to LLVM type \p
+// DstTy. \p Src has the same size as \p DstTy. Both are single value types
+// but could be scalar or vectors of different lengths, and either can be
+// pointer.
+// There are 4 cases:
+// 1. non-pointer -> non-pointer  : needs 1 bitcast
+// 2. pointer -> pointer  : needs 1 bitcast or addrspacecast
+// 3. pointer -> non-pointer
+//   a) pointer -> intptr_t   : needs 1 ptrtoint
+//   b) pointer -> non-intptr_t   : needs 1 ptrtoint then 1 bitcast
+// 4. non-pointer -> pointer
+//   a) intptr_t -> pointer   : needs 1 inttoptr
+//   b) non-intptr_t -> pointer   : needs 1 bitcast then 1 inttoptr
+// Note: for cases 3b and 4b two casts are required since LLVM casts do not
+// allow casting directly between pointer types and non-integer non-pointer
+// types.
+static Value *createCastsForTypeOfSameSize(CGBuilderTy &Builder,
+   const llvm::DataLayout &DL,
+   Value *Src, llvm::Type *DstTy,
+   StringRef Name = "") {
+  auto SrcTy = Src->getType();
+
+  // Case 1.
+  if (!SrcTy->isPointerTy() && !DstTy->isPointerTy())
+return Builder.CreateBitCast(Src, DstTy, Name);
+
+  // Case 2.
+  if (SrcTy->isPointerTy() && DstTy->isPointerTy())
+return Builder.CreatePointerBitCastOrAddrSpaceCast(Src, DstTy, Name);
+
+  // Case 3.
+  if (SrcTy->isPointerTy() && !DstTy->isPointerTy()) {
+// Case 3b.
+if (!DstTy->isIntegerTy())
+  Src = Builder.CreatePtrToInt(Src, DL.getIntPtrType(SrcTy));
+// Cases 3a and 3b.
+return Builder.CreateBitOrPointerCast(Src, DstTy, Name);
+  }
+
+  // Case 4b.
+  if (!SrcTy->isIntegerTy())
+Src = Builder.CreateBitCast(Src, DL.getIntPtrType(DstTy));
+  // Cases 4a and 4b.
+  return Builder.CreateIntToPtr(Src, DstTy, Name);
+}
+
 Value *ScalarExprEmitter::VisitAsTypeExpr(AsTypeExpr *E) {
   Value *Src  = CGF.EmitScalarExpr(E->getSrcExpr());
   llvm::Type *DstTy = ConvertType(E->getType());
@@ -3421,7 +3467,8 @@
   // vector to get a vec4, then a bitcast if the target type is different.
   if (NumElementsSrc == 3 && NumElementsDst != 3) {
 Src = ConvertVec3AndVec4(Builder, CGF, Src, 4);
-Src = Builder.CreateBitCast(Src, DstTy);
+Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
+   DstTy);
 Src->setName("astype");
 return Src;
   }
@@

[PATCH] D24907: NFC: separate file for fp denormal regression tests

2016-10-04 Thread Sjoerd Meijer via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283109: This adds a separate file for the fp denormal 
regression tests. NFC. (authored by SjoerdMeijer).

Changed prior to commit:
  https://reviews.llvm.org/D24907?vs=72457&id=73411#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24907

Files:
  cfe/trunk/test/Driver/fast-math.c


Index: cfe/trunk/test/Driver/fast-math.c
===
--- cfe/trunk/test/Driver/fast-math.c
+++ cfe/trunk/test/Driver/fast-math.c
@@ -234,13 +234,4 @@
 //
 // RUN: %clang -### -ftrapping-math -fno-trapping-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-TRAPPING-MATH %s
-// RUN: %clang -### -fdenormal-fp-math=ieee -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-IEEE %s
-// RUN: %clang -### -fdenormal-fp-math=preserve-sign -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-PS %s
-// RUN: %clang -### -fdenormal-fp-math=positive-zero -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-PZ %s
 // CHECK-NO-TRAPPING-MATH: "-fno-trapping-math"
-// CHECK-FP-DENORMAL-IEEE: "-fdenormal-fp-math=ieee"
-// CHECK-FP-DENORMAL-PS: "-fdenormal-fp-math=preserve-sign"
-// CHECK-FP-DENORMAL-PZ: "-fdenormal-fp-math=positive-zero"


Index: cfe/trunk/test/Driver/fast-math.c
===
--- cfe/trunk/test/Driver/fast-math.c
+++ cfe/trunk/test/Driver/fast-math.c
@@ -234,13 +234,4 @@
 //
 // RUN: %clang -### -ftrapping-math -fno-trapping-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-TRAPPING-MATH %s
-// RUN: %clang -### -fdenormal-fp-math=ieee -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-IEEE %s
-// RUN: %clang -### -fdenormal-fp-math=preserve-sign -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-PS %s
-// RUN: %clang -### -fdenormal-fp-math=positive-zero -c %s 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-FP-DENORMAL-PZ %s
 // CHECK-NO-TRAPPING-MATH: "-fno-trapping-math"
-// CHECK-FP-DENORMAL-IEEE: "-fdenormal-fp-math=ieee"
-// CHECK-FP-DENORMAL-PS: "-fdenormal-fp-math=preserve-sign"
-// CHECK-FP-DENORMAL-PZ: "-fdenormal-fp-math=positive-zero"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-10-04 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283094: [analyzer] Improve CloneChecker diagnostics 
(authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D24916?vs=72991&id=73408#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24916

Files:
  cfe/trunk/include/clang/Analysis/CloneDetection.h
  cfe/trunk/lib/Analysis/CloneDetection.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  cfe/trunk/test/Analysis/copypaste/blocks.cpp
  cfe/trunk/test/Analysis/copypaste/function-try-block.cpp
  cfe/trunk/test/Analysis/copypaste/functions.cpp
  cfe/trunk/test/Analysis/copypaste/macro-complexity.cpp
  cfe/trunk/test/Analysis/copypaste/macros.cpp
  cfe/trunk/test/Analysis/copypaste/objc-methods.m
  cfe/trunk/test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp
  cfe/trunk/test/Analysis/copypaste/plist-diagnostics.cpp
  cfe/trunk/test/Analysis/copypaste/sub-sequences.cpp
  cfe/trunk/test/Analysis/copypaste/suspicious-clones.cpp
  cfe/trunk/test/Analysis/copypaste/text-diagnostics.cpp

Index: cfe/trunk/lib/Analysis/CloneDetection.cpp
===
--- cfe/trunk/lib/Analysis/CloneDetection.cpp
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp
@@ -82,6 +82,10 @@
 
 SourceLocation StmtSequence::getEndLoc() const { return back()->getLocEnd(); }
 
+SourceRange StmtSequence::getSourceRange() const {
+  return SourceRange(getStartLoc(), getEndLoc());
+}
+
 namespace {
 
 /// \brief Analyzes the pattern of the referenced variables in a statement.
@@ -91,11 +95,11 @@
   struct VariableOccurence {
 /// The index of the associated VarDecl in the Variables vector.
 size_t KindID;
-/// The source range in the code where the variable was referenced.
-SourceRange Range;
+/// The statement in the code where the variable was referenced.
+const Stmt *Mention;
 
-VariableOccurence(size_t KindID, SourceRange Range)
-: KindID(KindID), Range(Range) {}
+VariableOccurence(size_t KindID, const Stmt *Mention)
+: KindID(KindID), Mention(Mention) {}
   };
 
   /// All occurences of referenced variables in the order of appearance.
@@ -107,19 +111,19 @@
   /// \brief Adds a new variable referenced to this pattern.
   /// \param VarDecl The declaration of the variable that is referenced.
   /// \param Range The SourceRange where this variable is referenced.
-  void addVariableOccurence(const VarDecl *VarDecl, SourceRange Range) {
+  void addVariableOccurence(const VarDecl *VarDecl, const Stmt *Mention) {
 // First check if we already reference this variable
 for (size_t KindIndex = 0; KindIndex < Variables.size(); ++KindIndex) {
   if (Variables[KindIndex] == VarDecl) {
 // If yes, add a new occurence that points to the existing entry in
 // the Variables vector.
-Occurences.emplace_back(KindIndex, Range);
+Occurences.emplace_back(KindIndex, Mention);
 return;
   }
 }
 // If this variable wasn't already referenced, add it to the list of
 // referenced variables and add a occurence that points to this new entry.
-Occurences.emplace_back(Variables.size(), Range);
+Occurences.emplace_back(Variables.size(), Mention);
 Variables.push_back(VarDecl);
   }
 
@@ -134,7 +138,7 @@
 // Check if S is a reference to a variable. If yes, add it to the pattern.
 if (auto D = dyn_cast(S)) {
   if (auto VD = dyn_cast(D->getDecl()->getCanonicalDecl()))
-addVariableOccurence(VD, D->getSourceRange());
+addVariableOccurence(VD, D);
 }
 
 // Recursively check all children of the given statement.
@@ -208,7 +212,7 @@
   // Store information about the first clone.
   FirstMismatch->FirstCloneInfo =
   CloneDetector::SuspiciousClonePair::SuspiciousCloneInfo(
-  Variables[ThisOccurence.KindID], ThisOccurence.Range,
+  Variables[ThisOccurence.KindID], ThisOccurence.Mention,
   FirstSuggestion);
 
   // Same as above but with the other clone. We do this for both clones as
@@ -221,7 +225,7 @@
   // Store information about the second clone.
   FirstMismatch->SecondCloneInfo =
   CloneDetector::SuspiciousClonePair::SuspiciousCloneInfo(
-  Variables[ThisOccurence.KindID], OtherOccurence.Range,
+  Other.Variables[OtherOccurence.KindID], OtherOccurence.Mention,
   SecondSuggestion);
 
   // SuspiciousClonePair guarantees that the first clone always has a
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -16,8 +16,10 @@
 #include "ClangSACheckers.h"
 #include "clang/Analysis/CloneDetection.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/StaticAnalyzer/Core/BugReporter

[PATCH] D25131: Fix PR 28885: Fix AST Printer output for inheriting constructor using declarations

2016-10-04 Thread Alex Lorenz via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283102: Fix PR 28885: Fix AST Printer output for the 
inherited constructor using (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D25131?vs=73145&id=73410#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25131

Files:
  cfe/trunk/lib/AST/DeclPrinter.cpp
  cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp


Index: cfe/trunk/lib/AST/DeclPrinter.cpp
===
--- cfe/trunk/lib/AST/DeclPrinter.cpp
+++ cfe/trunk/lib/AST/DeclPrinter.cpp
@@ -1346,6 +1346,17 @@
   if (D->hasTypename())
 Out << "typename ";
   D->getQualifier()->print(Out, Policy);
+
+  // Use the correct record name when the using declaration is used for
+  // inheriting constructors.
+  for (const auto *Shadow : D->shadows()) {
+if (const auto *ConstructorShadow =
+dyn_cast(Shadow)) {
+  assert(Shadow->getDeclContext() == ConstructorShadow->getDeclContext());
+  Out << *ConstructorShadow->getNominatedBaseClass();
+  return;
+}
+  }
   Out << *D;
 }
 
Index: cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
===
--- cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
+++ cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
@@ -43,6 +43,14 @@
 // CHECK: const char *PR23120 = operator""_suffix();
 const char *PR23120 = U"𐐷"_suffix;
 
+// PR28885
+struct A {
+  A();
+};
+struct B : A {
+  using A::A; // CHECK:  using A::A;
+};// CHECK-NEXT: };
+
 // CHECK: ;
 ;
 // CHECK-NOT: ;


Index: cfe/trunk/lib/AST/DeclPrinter.cpp
===
--- cfe/trunk/lib/AST/DeclPrinter.cpp
+++ cfe/trunk/lib/AST/DeclPrinter.cpp
@@ -1346,6 +1346,17 @@
   if (D->hasTypename())
 Out << "typename ";
   D->getQualifier()->print(Out, Policy);
+
+  // Use the correct record name when the using declaration is used for
+  // inheriting constructors.
+  for (const auto *Shadow : D->shadows()) {
+if (const auto *ConstructorShadow =
+dyn_cast(Shadow)) {
+  assert(Shadow->getDeclContext() == ConstructorShadow->getDeclContext());
+  Out << *ConstructorShadow->getNominatedBaseClass();
+  return;
+}
+  }
   Out << *D;
 }
 
Index: cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
===
--- cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
+++ cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
@@ -43,6 +43,14 @@
 // CHECK: const char *PR23120 = operator""_suffix();
 const char *PR23120 = U"𐐷"_suffix;
 
+// PR28885
+struct A {
+  A();
+};
+struct B : A {
+  using A::A; // CHECK:  using A::A;
+};// CHECK-NEXT: };
+
 // CHECK: ;
 ;
 // CHECK-NOT: ;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24915: [analyzer] Extend bug reports with extra notes - ObjCDeallocChecker

2016-10-04 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283093: [analyzer] Add extra notes to ObjCDeallocChecker 
(authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D24915?vs=72520&id=73407#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24915

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  cfe/trunk/test/Analysis/DeallocMissingRelease.m
  cfe/trunk/test/Analysis/PR2978.m
  cfe/trunk/test/Analysis/properties.m

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
@@ -107,6 +107,9 @@
   std::unique_ptr ExtraReleaseBugType;
   std::unique_ptr MistakenDeallocBugType;
 
+  static constexpr const char *MsgDeclared = "Property is declared here";
+  static constexpr const char *MsgSynthesized = "Property is synthesized here";
+
 public:
   ObjCDeallocChecker();
 
@@ -128,6 +131,9 @@
   void checkEndFunction(CheckerContext &Ctx) const;
 
 private:
+  void addNoteForDecl(std::unique_ptr &BR, StringRef Msg,
+   const Decl *D) const;
+
   void diagnoseMissingReleases(CheckerContext &C) const;
 
   bool diagnoseExtraRelease(SymbolRef ReleasedValue, const ObjCMethodCall &M,
@@ -489,6 +495,18 @@
   return State;
 }
 
+/// Add an extra note piece describing a declaration that is important
+/// for understanding the bug report.
+void ObjCDeallocChecker::addNoteForDecl(std::unique_ptr &BR,
+ StringRef Msg,
+ const Decl *D) const {
+  ASTContext &ACtx = D->getASTContext();
+  SourceManager &SM = ACtx.getSourceManager();
+  PathDiagnosticLocation Pos = PathDiagnosticLocation::createBegin(D, SM);
+  if (Pos.isValid() && Pos.asLocation().isValid())
+BR->addNote(Msg, Pos, D->getSourceRange());
+}
+
 /// Report any unreleased instance variables for the current instance being
 /// dealloced.
 void ObjCDeallocChecker::diagnoseMissingReleases(CheckerContext &C) const {
@@ -586,6 +604,9 @@
 std::unique_ptr BR(
 new BugReport(*MissingReleaseBugType, OS.str(), ErrNode));
 
+addNoteForDecl(BR, MsgDeclared, PropDecl);
+addNoteForDecl(BR, MsgSynthesized, PropImpl);
+
 C.emitReport(std::move(BR));
   }
 
@@ -689,11 +710,12 @@
  );
 
   const ObjCImplDecl *Container = getContainingObjCImpl(C.getLocationContext());
-  OS << "The '" << *PropImpl->getPropertyIvarDecl()
- << "' ivar in '" << *Container;
+  const ObjCIvarDecl *IvarDecl = PropImpl->getPropertyIvarDecl();
+  OS << "The '" << *IvarDecl << "' ivar in '" << *Container;
 
+  bool ReleasedByCIFilterDealloc = isReleasedByCIFilterDealloc(PropImpl);
 
-  if (isReleasedByCIFilterDealloc(PropImpl)) {
+  if (ReleasedByCIFilterDealloc) {
 OS << "' will be released by '-[CIFilter dealloc]' but also released here";
   } else {
 OS << "' was synthesized for ";
@@ -710,6 +732,10 @@
   new BugReport(*ExtraReleaseBugType, OS.str(), ErrNode));
   BR->addRange(M.getOriginExpr()->getSourceRange());
 
+  addNoteForDecl(BR, MsgDeclared, PropDecl);
+  if (!ReleasedByCIFilterDealloc)
+addNoteForDecl(BR, MsgSynthesized, PropImpl);
+
   C.emitReport(std::move(BR));
 
   return true;
Index: cfe/trunk/test/Analysis/PR2978.m
===
--- cfe/trunk/test/Analysis/PR2978.m
+++ cfe/trunk/test/Analysis/PR2978.m
@@ -29,22 +29,22 @@
   id _nonPropertyIvar;
 }
 @property(retain) id X;
-@property(retain) id Y;
-@property(assign) id Z;
+@property(retain) id Y; // expected-note{{Property is declared here}}
+@property(assign) id Z; // expected-note{{Property is declared here}}
 @property(assign) id K;
 @property(weak) id L;
 @property(readonly) id N;
 @property(retain) id M;
 @property(weak) id P;
-@property(weak) id Q;
+@property(weak) id Q; // expected-note{{Property is declared here}}
 @property(retain) id R;
-@property(weak, readonly) id S;
+@property(weak, readonly) id S; // expected-note{{Property is declared here}}
 
 @property(assign, readonly) id T; // Shadowed in class extension
 @property(assign) id U;
 
 @property(retain) id V;
-@property(retain) id W;
+@property(retain) id W; // expected-note{{Property is declared here}}
 -(id) O;
 -(void) setO: (id) arg;
 @end
@@ -56,16 +56,16 @@
 
 @implementation MyClass
 @synthesize X = _X;
-@synthesize Y = _Y;
-@synthesize Z = _Z;
+@synthesize Y = _Y; // expected-note{{Property is synthesized here}}
+@synthesize Z = _Z; // expected-note{{Property is synthesized here}}
 @synthesize K = _K;
 @synthesize L = _L;
 @synthesize N = _N;
 @synthesize M = _M;
-@synthesize Q = _Q;
+@synthesize Q = _Q; // expected-note{{Property is synthesized here}}
 @synthesize R = _R;
 @synthesize V = _V;
-@synthesize W = _W;
+@synthesize W = _W; // expected-note{{Property is s

[PATCH] D24571: [CUDA] Disallow overloading destructors.

2016-10-04 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283120: [CUDA] Disallow overloading destructors. (authored 
by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D24571?vs=71379&id=73413#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24571

Files:
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/CodeGenCUDA/function-overload.cu
  cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu
  cfe/trunk/test/SemaCUDA/function-overload.cu
  cfe/trunk/test/SemaCUDA/no-destructor-overload.cu

Index: cfe/trunk/test/CodeGenCUDA/function-overload.cu
===
--- cfe/trunk/test/CodeGenCUDA/function-overload.cu
+++ cfe/trunk/test/CodeGenCUDA/function-overload.cu
@@ -16,8 +16,6 @@
 struct s_cd_dh {
   __host__ s_cd_dh() { x = 11; }
   __device__ s_cd_dh() { x = 12; }
-  __host__ ~s_cd_dh() { x = 21; }
-  __device__ ~s_cd_dh() { x = 22; }
 };
 
 struct s_cd_hd {
@@ -38,7 +36,6 @@
   // CHECK-BOTH: call void @_ZN7s_cd_hdC1Ev
 
   // CHECK-BOTH: call void @_ZN7s_cd_hdD1Ev(
-  // CHECK-BOTH: call void @_ZN7s_cd_dhD1Ev(
 }
 // CHECK-BOTH: ret void
 
@@ -56,8 +53,3 @@
 // CHECK-BOTH: define linkonce_odr void @_ZN7s_cd_hdD2Ev(
 // CHECK-BOTH: store i32 32,
 // CHECK-BOTH: ret void
-
-// CHECK-BOTH: define linkonce_odr void @_ZN7s_cd_dhD2Ev(
-// CHECK-HOST:   store i32 21,
-// CHECK-DEVICE: store i32 22,
-// CHECK-BOTH: ret void
Index: cfe/trunk/test/SemaCUDA/no-destructor-overload.cu
===
--- cfe/trunk/test/SemaCUDA/no-destructor-overload.cu
+++ cfe/trunk/test/SemaCUDA/no-destructor-overload.cu
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+// We don't allow destructors to be overloaded.  Making this work would be a
+// giant change to clang, and the use cases seem quite limited.
+
+struct A {
+  ~A() {} // expected-note {{previous declaration is here}}
+  __device__ ~A() {} // expected-error {{destructor cannot be redeclared}}
+};
+
+struct B {
+  __host__ ~B() {} // expected-note {{previous declaration is here}}
+  __host__ __device__ ~B() {} // expected-error {{destructor cannot be redeclared}}
+};
+
+struct C {
+  __host__ __device__ ~C() {} // expected-note {{previous declaration is here}}
+  __host__ ~C() {} // expected-error {{destructor cannot be redeclared}}
+};
+
+struct D {
+  __device__ ~D() {} // expected-note {{previous declaration is here}}
+  __host__ __device__ ~D() {} // expected-error {{destructor cannot be redeclared}}
+};
+
+struct E {
+  __host__ __device__ ~E() {} // expected-note {{previous declaration is here}}
+  __device__ ~E() {} // expected-error {{destructor cannot be redeclared}}
+};
+
Index: cfe/trunk/test/SemaCUDA/function-overload.cu
===
--- cfe/trunk/test/SemaCUDA/function-overload.cu
+++ cfe/trunk/test/SemaCUDA/function-overload.cu
@@ -210,44 +210,11 @@
   __host__ ~d_h() {} // expected-error {{destructor cannot be redeclared}}
 };
 
-// H/D overloading is OK
-struct d_dh {
-  __device__ ~d_dh() {}
-  __host__ ~d_dh() {}
-};
-
 // HD is OK
 struct d_hd {
   __host__ __device__ ~d_hd() {}
 };
 
-// Mixing H/D and HD is not allowed.
-struct d_dhhd {
-  __device__ ~d_dhhd() {}
-  __host__ ~d_dhhd() {} // expected-note {{previous declaration is here}}
-  __host__ __device__ ~d_dhhd() {} // expected-error {{destructor cannot be redeclared}}
-};
-
-struct d_hhd {
-  __host__ ~d_hhd() {} // expected-note {{previous declaration is here}}
-  __host__ __device__ ~d_hhd() {} // expected-error {{destructor cannot be redeclared}}
-};
-
-struct d_hdh {
-  __host__ __device__ ~d_hdh() {} // expected-note {{previous declaration is here}}
-  __host__ ~d_hdh() {} // expected-error {{destructor cannot be redeclared}}
-};
-
-struct d_dhd {
-  __device__ ~d_dhd() {} // expected-note {{previous declaration is here}}
-  __host__ __device__ ~d_dhd() {} // expected-error {{destructor cannot be redeclared}}
-};
-
-struct d_hdd {
-  __host__ __device__ ~d_hdd() {} // expected-note {{previous declaration is here}}
-  __device__ ~d_hdd() {} // expected-error {{destructor cannot be redeclared}}
-};
-
 // Test overloading of member functions
 struct m_h {
   void operator delete(void *ptr); // expected-note {{previous declaration is here}}
Index: cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu
===
--- cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu
+++ cfe/trunk/test/SemaCUDA/call-overloaded-destructor.cu
@@ -1,17 +0,0 @@
-// expected-no-diagnostics
-
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
-
-#include "Inputs/cuda.h"
-
-struct S {
-  __host__ ~S() {}
-  __device__ ~S()

[PATCH] D25207: Added more comments to tooling::Replacements.

2016-10-04 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283135: Added more comments to tooling::Replacements. 
(authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D25207?vs=73322&id=73414#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25207

Files:
  cfe/trunk/include/clang/Tooling/Core/Replacement.h


Index: cfe/trunk/include/clang/Tooling/Core/Replacement.h
===
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h
@@ -176,6 +176,8 @@
   ///   - are insertions at the same offset and applying them in either order
   /// has the same effect, i.e. X + Y = Y + X when inserting X and Y
   /// respectively.
+  ///   - are identical replacements, i.e. applying the same replacement twice
+  /// is equivalent to applying it once.
   /// Examples:
   /// 1. Replacement A(0, 0, "a") and B(0, 0, "aa") are order-independent since
   ///applying them in either order gives replacement (0, 0, "aaa").
@@ -186,6 +188,8 @@
   ///since applying them in either order gives (0, 2, "123").
   /// 3. Replacement A(0, 3, "123") and B(2, 3, "321") are order-independent
   ///since either order gives (0, 5, "12321").
+  /// 4. Replacement A(0, 3, "ab") and B(0, 3, "ab") are order-independent 
since
+  ///applying the same replacement twice is equivalent to applying it once.
   /// Replacements with offset UINT_MAX are special - we do not detect 
conflicts
   /// for such replacements since users may add them intentionally as a special
   /// category of replacements.


Index: cfe/trunk/include/clang/Tooling/Core/Replacement.h
===
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h
@@ -176,6 +176,8 @@
   ///   - are insertions at the same offset and applying them in either order
   /// has the same effect, i.e. X + Y = Y + X when inserting X and Y
   /// respectively.
+  ///   - are identical replacements, i.e. applying the same replacement twice
+  /// is equivalent to applying it once.
   /// Examples:
   /// 1. Replacement A(0, 0, "a") and B(0, 0, "aa") are order-independent since
   ///applying them in either order gives replacement (0, 0, "aaa").
@@ -186,6 +188,8 @@
   ///since applying them in either order gives (0, 2, "123").
   /// 3. Replacement A(0, 3, "123") and B(2, 3, "321") are order-independent
   ///since either order gives (0, 5, "12321").
+  /// 4. Replacement A(0, 3, "ab") and B(0, 3, "ab") are order-independent since
+  ///applying the same replacement twice is equivalent to applying it once.
   /// Replacements with offset UINT_MAX are special - we do not detect conflicts
   /// for such replacements since users may add them intentionally as a special
   /// category of replacements.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25226: [change-namespace] Fix a misplaced case when there is no trailing newline character at the end of the file.

2016-10-04 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D25226

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -447,6 +447,27 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NoMisplaceAtEOF) {
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A;\n"
+ "class B {};\n"
+ "}"
+ "}";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "class A;\n"
+ "}\n"
+ "}\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "\n"
+ "class B {};\n"
+ "} // namespace y\n"
+ "} // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -106,8 +106,10 @@
   // FIXME: this is a bit hacky to get ReadToEndOfLine work.
   Lex.setParsingPreprocessorDirective(true);
   Lex.ReadToEndOfLine(&Line);
-  // FIXME: should not +1 at EOF.
-  return Loc.getLocWithOffset(Line.size() + 1);
+  auto End = Loc.getLocWithOffset(Line.size());
+  if (SM.getLocForEndOfFile(LocInfo.first) == End)
+return End;
+  return End.getLocWithOffset(1);
 }
 
 // Returns `R` with new range that refers to code after `Replaces` being


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -447,6 +447,27 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NoMisplaceAtEOF) {
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A;\n"
+ "class B {};\n"
+ "}"
+ "}";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "class A;\n"
+ "}\n"
+ "}\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "\n"
+ "class B {};\n"
+ "} // namespace y\n"
+ "} // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -106,8 +106,10 @@
   // FIXME: this is a bit hacky to get ReadToEndOfLine work.
   Lex.setParsingPreprocessorDirective(true);
   Lex.ReadToEndOfLine(&Line);
-  // FIXME: should not +1 at EOF.
-  return Loc.getLocWithOffset(Line.size() + 1);
+  auto End = Loc.getLocWithOffset(Line.size());
+  if (SM.getLocForEndOfFile(LocInfo.first) == End)
+return End;
+  return End.getLocWithOffset(1);
 }
 
 // Returns `R` with new range that refers to code after `Replaces` being
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25227: [clang-move] Move comments which are associated with the moved class.

2016-10-04 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D25227

Files:
  clang-move/ClangMove.cpp
  clang-move/tool/ClangMoveMain.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -29,16 +29,19 @@
 const char TestCCName[] = "foo.cc";
 
 const char TestHeader[] = "namespace a {\n"
-  "class C1;\n"
+  "class C1; // test\n"
   "namespace b {\n"
+  "// This is a Foo class\n"
+  "// which is used in\n"
+  "// test.\n"
   "class Foo {\n"
   "public:\n"
   "  void f();\n"
   "\n"
   "private:\n"
   "  C1 *c1;\n"
   "  static int b;\n"
-  "};\n"
+  "}; // abc\n"
   "\n"
   "class Foo2 {\n"
   "public:\n"
@@ -51,19 +54,29 @@
   "namespace a {\n"
   "namespace b {\n"
   "namespace {\n"
+  "// comment1.\n"
   "void f1() {}\n"
+  "/// comment2.\n"
   "int kConstInt1 = 0;\n"
   "} // namespace\n"
   "\n"
+  "/* comment 3*/\n"
   "static int kConstInt2 = 1;\n"
   "\n"
+  "/** comment4\n"
+  "*/\n"
   "static int help() {\n"
   "  int a = 0;\n"
   "  return a;\n"
   "}\n"
   "\n"
+  "// comment5\n"
+  "// comment5\n"
   "void Foo::f() { f1(); }\n"
   "\n"
+  "/\n"
+  "// comment //\n"
+  "/\n"
   "int Foo::b = 2;\n"
   "int Foo2::f() {\n"
   "  f1();\n"
@@ -73,7 +86,7 @@
   "} // namespace a\n";
 
 const char ExpectedTestHeader[] = "namespace a {\n"
-  "class C1;\n"
+  "class C1; // test\n"
   "namespace b {\n"
   "\n"
   "class Foo2 {\n"
@@ -87,12 +100,17 @@
   "namespace a {\n"
   "namespace b {\n"
   "namespace {\n"
+  "// comment1.\n"
   "void f1() {}\n"
+  "/// comment2.\n"
   "int kConstInt1 = 0;\n"
   "} // namespace\n"
   "\n"
+  "/* comment 3*/\n"
   "static int kConstInt2 = 1;\n"
   "\n"
+  "/** comment4\n"
+  "*/\n"
   "static int help() {\n"
   "  int a = 0;\n"
   "  return a;\n"
@@ -106,31 +124,44 @@
   "} // namespace a\n";
 
 const char ExpectedNewHeader[] = "namespace a {\n"
- "class C1;\n"
+ "class C1; // test\n"
  "namespace b {\n"
+ "// This is a Foo class\n"
+ "// which is used in\n"
+ "// test.\n"
  "class Foo {\n"
  "public:\n"
  "  void f();\n"
  "\n"
  "private:\n"
  "  C1 *c1;\n"
  "  static int b;\n"
- "};\n"
+ "}; // abc\n"
  "} // namespace b\n"
  "} // namespace a\n";
 
 const char ExpectedNewCC[] = "namespace a {\n"
  "namespace b {\n"
  "namespace {\n"
+ "// comment1.\n"
  "void f1() {}\n"
+ "/// comment2.\n"
  "int kConstInt1 = 0;\n"

r283193 - [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-04 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Tue Oct  4 03:22:47 2016
New Revision: 283193

URL: http://llvm.org/viewvc/llvm-project?rev=283193&view=rev
Log:
[XRay] Check in Clang whether XRay supports the target when -fxray-instrument 
is passed

Added the code which explicitly emits an error in Clang in case
`-fxray-instrument` is passed, but XRay is not supported for the
selected target.

Author: rSerge

Reviewers: dberris, rsmith, aaron.ballman, rnk

Subscribers: cfe-commits, iid_iunknown

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

Added:
cfe/trunk/test/Driver/xray-instrument.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=283193&r1=283192&r2=283193&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Oct  4 03:22:47 2016
@@ -4777,7 +4777,20 @@ void Clang::ConstructJob(Compilation &C,
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char *const XRayInstrumentOption = "-fxray-instrument";
+switch (getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default: {
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+}
+}
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {

Added: cfe/trunk/test/Driver/xray-instrument.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/xray-instrument.c?rev=283193&view=auto
==
--- cfe/trunk/test/Driver/xray-instrument.c (added)
+++ cfe/trunk/test/Driver/xray-instrument.c Tue Oct  4 03:22:47 2016
@@ -0,0 +1,3 @@
+// RUN: %clang -v -fxray-instrument -c %s
+// XFAIL: armeb, aarch64, aarch64_be, avr, bpfel, bpfeb, hexagon, mips, 
mipsel, mips64, mips64el, msp430, ppc, ppc64, ppc64le, r600, amdgcn, sparc, 
sparcv9, sparcel, systemz, tce, thumb, thumbeb, x86-, xcore, nvptx, nvptx64, 
le32, le64, amdil, amdil64, hsail, hsail64, spir, spir64, kalimba, shave, 
lanai, wasm32, wasm64, renderscript32, renderscript64
+typedef int a;


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


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-04 Thread Dean Michael Berris via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283193: [XRay] Check in Clang whether XRay supports the 
target when -fxray-instrument… (authored by dberris).

Changed prior to commit:
  https://reviews.llvm.org/D24799?vs=72554&id=73424#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24799

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/xray-instrument.c


Index: cfe/trunk/test/Driver/xray-instrument.c
===
--- cfe/trunk/test/Driver/xray-instrument.c
+++ cfe/trunk/test/Driver/xray-instrument.c
@@ -0,0 +1,3 @@
+// RUN: %clang -v -fxray-instrument -c %s
+// XFAIL: armeb, aarch64, aarch64_be, avr, bpfel, bpfeb, hexagon, mips, 
mipsel, mips64, mips64el, msp430, ppc, ppc64, ppc64le, r600, amdgcn, sparc, 
sparcv9, sparcel, systemz, tce, thumb, thumbeb, x86-, xcore, nvptx, nvptx64, 
le32, le64, amdil, amdil64, hsail, hsail64, spir, spir64, kalimba, shave, 
lanai, wasm32, wasm64, renderscript32, renderscript64
+typedef int a;
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4777,7 +4777,20 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char *const XRayInstrumentOption = "-fxray-instrument";
+switch (getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default: {
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+}
+}
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {


Index: cfe/trunk/test/Driver/xray-instrument.c
===
--- cfe/trunk/test/Driver/xray-instrument.c
+++ cfe/trunk/test/Driver/xray-instrument.c
@@ -0,0 +1,3 @@
+// RUN: %clang -v -fxray-instrument -c %s
+// XFAIL: armeb, aarch64, aarch64_be, avr, bpfel, bpfeb, hexagon, mips, mipsel, mips64, mips64el, msp430, ppc, ppc64, ppc64le, r600, amdgcn, sparc, sparcv9, sparcel, systemz, tce, thumb, thumbeb, x86-, xcore, nvptx, nvptx64, le32, le64, amdil, amdil64, hsail, hsail64, spir, spir64, kalimba, shave, lanai, wasm32, wasm64, renderscript32, renderscript64
+typedef int a;
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -4777,7 +4777,20 @@
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-CmdArgs.push_back("-fxray-instrument");
+const char *const XRayInstrumentOption = "-fxray-instrument";
+switch (getToolChain().getArch()) {
+case llvm::Triple::arm:
+case llvm::Triple::x86_64:
+  break;
+default: {
+  std::string Feature(XRayInstrumentOption);
+  Feature += " on ";
+  Feature += Triple.getArchName().data();
+  D.Diag(diag::err_drv_clang_unsupported) << Feature;
+  break;
+}
+}
+CmdArgs.push_back(XRayInstrumentOption);
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24922: [clang-move] Make it support both relative and absolute file path arguments.

2016-10-04 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 73426.
hokein marked 3 inline comments as done.
hokein added a comment.
Herald added subscribers: mgorny, beanz.

Add clang-move tool in test/CMakeLists.


https://reviews.llvm.org/D24922

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/tool/ClangMoveMain.cpp
  test/CMakeLists.txt
  test/clang-move/Inputs/database_template.json
  test/clang-move/Inputs/test.cpp
  test/clang-move/Inputs/test.h
  test/clang-move/move-class.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -156,9 +156,12 @@
   CreateFiles(Spec.OldCC, TestCC);
 
   std::map FileToReplacements;
-  ClangMoveTool MoveTool(Spec, FileToReplacements);
+  llvm::SmallString<128> InitialDirectory;
+  std::error_code EC = llvm::sys::fs::current_path(InitialDirectory);
+  assert(!EC);
+  (void)EC;
   auto Factory = llvm::make_unique(
-  Spec, FileToReplacements);
+  Spec, FileToReplacements, InitialDirectory.str());
 
   tooling::runToolOnCodeWithArgs(
   Factory->create(), TestCC, {"-std=c++11"}, TestCCName, "clang-move",
Index: test/clang-move/move-class.cpp
===
--- /dev/null
+++ test/clang-move/move-class.cpp
@@ -0,0 +1,39 @@
+// RUN: mkdir -p %T/clang-move/build
+// RUN: sed 's|$test_dir|%/T/clang-move|g' %S/Inputs/database_template.json > %T/clang-move/compile_commands.json
+// RUN: cp %S/Inputs/test*  %T/clang-move/
+// RUN: touch test2.h
+// RUN: cd %T/clang-move
+// RUN: clang-move -name="a::Foo" -new_cc=%T/clang-move/new_test.cpp -new_header=%T/clang-move/new_test.h -old_cc=../clang-move/test.cpp -old_header=../clang-move/test.h %T/clang-move/test.cpp
+// RUN: FileCheck -input-file=%T/clang-move/new_test.cpp -check-prefix=CHECK-NEW-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/new_test.h -check-prefix=CHECK-NEW-TEST-H %s
+// RUN: FileCheck -input-file=%T/clang-move/test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/test.h -check-prefix=CHECK-OLD-TEST-H %s
+//
+// RUN: cp %S/Inputs/test*  %T/clang-move/
+// RUN: cd %T/clang-move
+// RUN: clang-move -name="a::Foo" -new_cc=%T/clang-move/new_test.cpp -new_header=%T/clang-move/new_test.h -old_cc=%T/clang-move/test.cpp -old_header=%T/clang-move/test.h %T/clang-move/test.cpp
+// RUN: FileCheck -input-file=%T/clang-move/new_test.cpp -check-prefix=CHECK-NEW-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/new_test.h -check-prefix=CHECK-NEW-TEST-H %s
+// RUN: FileCheck -input-file=%T/clang-move/test.cpp -check-prefix=CHECK-OLD-TEST-CPP %s
+// RUN: FileCheck -input-file=%T/clang-move/test.h -check-prefix=CHECK-OLD-TEST-H %s
+//
+// CHECK-NEW-TEST-H: namespace a {
+// CHECK-NEW-TEST-H: class Foo {
+// CHECK-NEW-TEST-H: public:
+// CHECK-NEW-TEST-H:   int f();
+// CHECK-NEW-TEST-H: };
+// CHECK-NEW-TEST-H: } // namespace a
+//
+// CHECK-NEW-TEST-CPP: #include "{{.*}}new_test.h"
+// CHECK-NEW-TEST-CPP: #include "test2.h"
+// CHECK-NEW-TEST-CPP: namespace a {
+// CHECK-NEW-TEST-CPP: int Foo::f() { return 0; }
+// CHECK-NEW-TEST-CPP: } // namespace a
+//
+// CHECK-OLD-TEST-H: namespace a {
+// CHECK-OLD-TEST-H: } // namespace a
+//
+// CHECK-OLD-TEST-CPP: #include "test.h"
+// CHECK-OLD-TEST-CPP: #include "test2.h"
+// CHECK-OLD-TEST-CPP: namespace a {
+// CHECK-OLD-TEST-CPP: } // namespace a
Index: test/clang-move/Inputs/test.h
===
--- /dev/null
+++ test/clang-move/Inputs/test.h
@@ -0,0 +1,6 @@
+namespace a {
+class Foo {
+public:
+  int f();
+};
+} // namespace a
Index: test/clang-move/Inputs/test.cpp
===
--- /dev/null
+++ test/clang-move/Inputs/test.cpp
@@ -0,0 +1,8 @@
+#include "test.h"
+#include "test2.h"
+
+namespace a {
+int Foo::f() {
+  return 0;
+}
+} // namespace a
Index: test/clang-move/Inputs/database_template.json
===
--- /dev/null
+++ test/clang-move/Inputs/database_template.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "$test_dir/build",
+  "command": "clang++ -o test.o $test_dir/test.cpp",
+  "file": "$test_dir/test.cpp"
+}
+]
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -44,6 +44,7 @@
   clang-apply-replacements
   clang-change-namespace
   clang-include-fixer
+  clang-move
   clang-query
   clang-rename
   clang-reorder-fields
Index: clang-move/tool/ClangMoveMain.cpp
===
--- clang-move/tool/ClangMoveMain.cpp
+++ clang-move/tool/ClangMoveMain.cpp
@@ -17,13 +17,15 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Process.h"
 #include "llvm/S

r283195 - Revert r283106, "Wdocumentation fix"

2016-10-04 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Oct  4 03:32:33 2016
New Revision: 283195

URL: http://llvm.org/viewvc/llvm-project?rev=283195&view=rev
Log:
Revert r283106, "Wdocumentation fix"

It should depend on r283094 and r283182.

Modified:
cfe/trunk/lib/Analysis/CloneDetection.cpp

Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=283195&r1=283194&r2=283195&view=diff
==
--- cfe/trunk/lib/Analysis/CloneDetection.cpp (original)
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp Tue Oct  4 03:32:33 2016
@@ -106,7 +106,7 @@ class VariablePattern {
 
   /// \brief Adds a new variable referenced to this pattern.
   /// \param VarDecl The declaration of the variable that is referenced.
-  /// \param Mention The statement in the code where the variable was 
referenced.
+  /// \param Range The SourceRange where this variable is referenced.
   void addVariableOccurence(const VarDecl *VarDecl, SourceRange Range) {
 // First check if we already reference this variable
 for (size_t KindIndex = 0; KindIndex < Variables.size(); ++KindIndex) {


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


[PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-10-04 Thread NAKAMURA Takumi via cfe-commits
chapuni added inline comments.


> CloneDetection.cpp:113
>/// \param VarDecl The declaration of the variable that is referenced.
>/// \param Range The SourceRange where this variable is referenced.
> +  void addVariableOccurence(const VarDecl *VarDecl, const Stmt *Mention) {

You should update \param here. See also r283106.

Repository:
  rL LLVM

https://reviews.llvm.org/D24916



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


[PATCH] D25226: [change-namespace] Fix a misplaced case when there is no trailing newline character at the end of the file.

2016-10-04 Thread Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Thanks for the fix! :)



> ChangeNamespace.cpp:110-112
> +  if (SM.getLocForEndOfFile(LocInfo.first) == End)
> +return End;
> +  return End.getLocWithOffset(1);

return (SM.getLocForEndOfFile(LocInfo.first) == End) ? End : 
End.getLocWithOffset(1);

https://reviews.llvm.org/D25226



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


[PATCH] D25065: [change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.

2016-10-04 Thread Eric Liu via cfe-commits
ioeric added a comment.

Ping


https://reviews.llvm.org/D25065



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


r283199 - Revert "[XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed"

2016-10-04 Thread Dean Michael Berris via cfe-commits
Author: dberris
Date: Tue Oct  4 03:54:51 2016
New Revision: 283199

URL: http://llvm.org/viewvc/llvm-project?rev=283199&view=rev
Log:
Revert "[XRay] Check in Clang whether XRay supports the target when 
-fxray-instrument is passed"

This reverts 283193 -- broke the build.

Removed:
cfe/trunk/test/Driver/xray-instrument.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=283199&r1=283198&r2=283199&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Oct  4 03:54:51 2016
@@ -4777,20 +4777,7 @@ void Clang::ConstructJob(Compilation &C,
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
options::OPT_fnoxray_instrument, false)) {
-const char *const XRayInstrumentOption = "-fxray-instrument";
-switch (getToolChain().getArch()) {
-case llvm::Triple::arm:
-case llvm::Triple::x86_64:
-  break;
-default: {
-  std::string Feature(XRayInstrumentOption);
-  Feature += " on ";
-  Feature += Triple.getArchName().data();
-  D.Diag(diag::err_drv_clang_unsupported) << Feature;
-  break;
-}
-}
-CmdArgs.push_back(XRayInstrumentOption);
+CmdArgs.push_back("-fxray-instrument");
 if (const Arg *A =
 Args.getLastArg(options::OPT_fxray_instruction_threshold_,
 options::OPT_fxray_instruction_threshold_EQ)) {

Removed: cfe/trunk/test/Driver/xray-instrument.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/xray-instrument.c?rev=283198&view=auto
==
--- cfe/trunk/test/Driver/xray-instrument.c (original)
+++ cfe/trunk/test/Driver/xray-instrument.c (removed)
@@ -1,3 +0,0 @@
-// RUN: %clang -v -fxray-instrument -c %s
-// XFAIL: armeb, aarch64, aarch64_be, avr, bpfel, bpfeb, hexagon, mips, 
mipsel, mips64, mips64el, msp430, ppc, ppc64, ppc64le, r600, amdgcn, sparc, 
sparcv9, sparcel, systemz, tce, thumb, thumbeb, x86-, xcore, nvptx, nvptx64, 
le32, le64, amdil, amdil64, hsail, hsail64, spir, spir64, kalimba, shave, 
lanai, wasm32, wasm64, renderscript32, renderscript64
-typedef int a;


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


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-04 Thread Dean Michael Berris via cfe-commits
dberris reopened this revision.
dberris added a comment.
This revision is now accepted and ready to land.

This broke the build on i686.

   TEST 'Clang :: Driver/xray-instrument.c' FAILED 

  Script:
  --
  C:/bb-win/ninja-clang-i686-msc19-R/build/./bin/clang.EXE  -v 
-fxray-instrument -c 
C:\bb-win\ninja-clang-i686-msc19-R\llvm-project\clang\test\Driver\xray-instrument.c
  --
  Exit Code: 1
  
  Command Output (stdout):
  --
  $ "C:/bb-win/ninja-clang-i686-msc19-R/build/./bin/clang.EXE" "-v" 
"-fxray-instrument" "-c" 
"C:\bb-win\ninja-clang-i686-msc19-R\llvm-project\clang\test\Driver\xray-instrument.c"
  # command stderr:
  clang version 4.0.0 
  
  Target: i686-pc-windows-msvc
  
  Thread model: posix
  
  InstalledDir: C:\bb-win\ninja-clang-i686-msc19-R\build\bin
  
  clang.EXE: error: the clang compiler does not support '-fxray-instrument on 
i686-pc-windows-msvc19.0.23506'
  
  
  error: command failed with exit status: 1

Reverted in https://reviews.llvm.org/rL283199.


Repository:
  rL LLVM

https://reviews.llvm.org/D24799



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


[PATCH] D24799: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

2016-10-04 Thread Dean Michael Berris via cfe-commits
dberris requested changes to this revision.
dberris added a subscriber: rengolin.
dberris added a comment.
This revision now requires changes to proceed.

I'm not sure whether the exhaustive list scales though... is there a better way 
of doing this? Maybe @rengolin has better ideas here?


Repository:
  rL LLVM

https://reviews.llvm.org/D24799



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


[clang-tools-extra] r283202 - [clang-move] Make it support both relative and absolute file path arguments.

2016-10-04 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Oct  4 04:05:31 2016
New Revision: 283202

URL: http://llvm.org/viewvc/llvm-project?rev=283202&view=rev
Log:
[clang-move] Make it support both relative and absolute file path arguments.

Reviewers: ioeric

Subscribers: beanz, mgorny, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clang-move/
clang-tools-extra/trunk/test/clang-move/Inputs/
clang-tools-extra/trunk/test/clang-move/Inputs/database_template.json
clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
clang-tools-extra/trunk/test/clang-move/Inputs/test.h
clang-tools-extra/trunk/test/clang-move/move-class.cpp
Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/clang-move/ClangMove.h
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
clang-tools-extra/trunk/test/CMakeLists.txt
clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=283202&r1=283201&r2=283202&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Tue Oct  4 04:05:31 2016
@@ -16,6 +16,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::ast_matchers;
 
@@ -23,6 +24,52 @@ namespace clang {
 namespace move {
 namespace {
 
+// Make the Path absolute using the CurrentDir if the Path is not an absolute
+// path. An empty Path will result in an empty string.
+std::string MakeAbsolutePath(StringRef CurrentDir, StringRef Path) {
+  if (Path.empty())
+return "";
+  llvm::SmallString<128> InitialDirectory(CurrentDir);
+  llvm::SmallString<128> AbsolutePath(Path);
+  if (std::error_code EC =
+  llvm::sys::fs::make_absolute(InitialDirectory, AbsolutePath))
+llvm::errs() << "Warning: could not make absolute file: '" <<  EC.message()
+ << '\n';
+  llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
+  return AbsolutePath.str();
+}
+
+// Make the Path absolute using the current working directory of the given
+// SourceManager if the Path is not an absolute path.
+//
+// The Path can be a path relative to the build directory, or retrieved from
+// the SourceManager.
+std::string MakeAbsolutePath(const SourceManager& SM, StringRef Path) {
+  llvm::SmallString<128> AbsolutePath(Path);
+  if (std::error_code EC =
+   SM.getFileManager().getVirtualFileSystem()->makeAbsolute(AbsolutePath))
+llvm::errs() << "Warning: could not make absolute file: '" <<  EC.message()
+ << '\n';
+  llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
+  return AbsolutePath.str();
+}
+
+// Matches AST nodes that are expanded within the given AbsoluteFilePath.
+AST_POLYMORPHIC_MATCHER_P(isExpansionInFile,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc),
+  std::string, AbsoluteFilePath) {
+  auto &SourceManager = Finder->getASTContext().getSourceManager();
+  auto ExpansionLoc = SourceManager.getExpansionLoc(Node.getLocStart());
+  if (ExpansionLoc.isInvalid())
+return false;
+  auto FileEntry =
+  SourceManager.getFileEntryForID(SourceManager.getFileID(ExpansionLoc));
+  if (!FileEntry)
+return false;
+  return MakeAbsolutePath(SourceManager, FileEntry->getName()) ==
+ AbsoluteFilePath;
+}
+
 class FindAllIncludes : public clang::PPCallbacks {
 public:
   explicit FindAllIncludes(SourceManager *SM, ClangMoveTool *const MoveTool)
@@ -33,10 +80,11 @@ public:
   StringRef FileName, bool IsAngled,
   clang::CharSourceRange /*FilenameRange*/,
   const clang::FileEntry * /*File*/,
-  StringRef /*SearchPath*/, StringRef /*RelativePath*/,
+  StringRef SearchPath, StringRef /*RelativePath*/,
   const clang::Module * /*Imported*/) override {
 if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc)))
-  MoveTool->addIncludes(FileName, IsAngled, FileEntry->getName());
+  MoveTool->addIncludes(FileName, IsAngled, SearchPath,
+FileEntry->getName(), SM);
   }
 
 private:
@@ -65,16 +113,19 @@ void addOrMergeReplacement(const clang::
   }
 }
 
-bool IsInHeaderFile(const clang::SourceManager &SM, const clang::Decl *D,
-llvm::StringRef HeaderFile) {
-  if (HeaderFile.empty())
+bool isInHeaderFile(const clang::SourceManager &SM, const clang::Decl *D,
+llvm::StringRef OriginalRunningDirectory,
+llvm::StringRef OldHeader) {
+  

[PATCH] D24922: [clang-move] Make it support both relative and absolute file path arguments.

2016-10-04 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283202: [clang-move] Make it support both relative and 
absolute file path arguments. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D24922?vs=73426&id=73433#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24922

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/clang-move/ClangMove.h
  clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
  clang-tools-extra/trunk/test/CMakeLists.txt
  clang-tools-extra/trunk/test/clang-move/Inputs/database_template.json
  clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
  clang-tools-extra/trunk/test/clang-move/Inputs/test.h
  clang-tools-extra/trunk/test/clang-move/move-class.cpp
  clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Index: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
===
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
@@ -17,13 +17,15 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/YAMLTraits.h"
+#include "llvm/Support/Path.h"
 #include 
 #include 
 
 using namespace clang;
 using namespace llvm;
 
 namespace {
+
 std::error_code CreateNewFile(const llvm::Twine &path) {
   int fd = 0;
   if (std::error_code ec =
@@ -38,17 +40,23 @@
 cl::opt Name("name", cl::desc("The name of class being moved."),
   cl::cat(ClangMoveCategory));
 
-cl::opt OldHeader("old_header", cl::desc("Old header."),
-   cl::cat(ClangMoveCategory));
+cl::opt
+OldHeader("old_header",
+  cl::desc("The relative/absolute file path of old header."),
+  cl::cat(ClangMoveCategory));
 
-cl::opt OldCC("old_cc", cl::desc("Old CC file."),
-   cl::cat(ClangMoveCategory));
+cl::opt
+OldCC("old_cc", cl::desc("The relative/absolute file path of old cc."),
+  cl::cat(ClangMoveCategory));
 
-cl::opt NewHeader("new_header", cl::desc("New header."),
-   cl::cat(ClangMoveCategory));
+cl::opt
+NewHeader("new_header",
+  cl::desc("The relative/absolute file path of new header."),
+  cl::cat(ClangMoveCategory));
 
-cl::opt NewCC("new_cc", cl::desc("New CC file."),
-   cl::cat(ClangMoveCategory));
+cl::opt
+NewCC("new_cc", cl::desc("The relative/absolute file path of new cc."),
+  cl::cat(ClangMoveCategory));
 
 cl::opt
 Style("style",
@@ -71,8 +79,15 @@
   Spec.NewHeader = NewHeader;
   Spec.OldCC = OldCC;
   Spec.NewCC = NewCC;
+
+  llvm::SmallString<128> InitialDirectory;
+  if (std::error_code EC = llvm::sys::fs::current_path(InitialDirectory))
+llvm::report_fatal_error("Cannot detect current path: " +
+ Twine(EC.message()));
+
   auto Factory = llvm::make_unique(
-  Spec, Tool.getReplacements());
+  Spec, Tool.getReplacements(), InitialDirectory.str());
+
   int CodeStatus = Tool.run(Factory.get());
   if (CodeStatus)
 return CodeStatus;
Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp
===
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp
@@ -16,13 +16,60 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::ast_matchers;
 
 namespace clang {
 namespace move {
 namespace {
 
+// Make the Path absolute using the CurrentDir if the Path is not an absolute
+// path. An empty Path will result in an empty string.
+std::string MakeAbsolutePath(StringRef CurrentDir, StringRef Path) {
+  if (Path.empty())
+return "";
+  llvm::SmallString<128> InitialDirectory(CurrentDir);
+  llvm::SmallString<128> AbsolutePath(Path);
+  if (std::error_code EC =
+  llvm::sys::fs::make_absolute(InitialDirectory, AbsolutePath))
+llvm::errs() << "Warning: could not make absolute file: '" <<  EC.message()
+ << '\n';
+  llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
+  return AbsolutePath.str();
+}
+
+// Make the Path absolute using the current working directory of the given
+// SourceManager if the Path is not an absolute path.
+//
+// The Path can be a path relative to the build directory, or retrieved from
+// the SourceManager.
+std::string MakeAbsolutePath(const SourceManager& SM, StringRef Path) {
+  llvm::SmallString<128> AbsolutePath(Path);
+  if (std::error_code EC =
+   SM.getFileManager().getVirtualFileSystem()->makeAbsolute(AbsolutePath))
+llvm::errs() << "Warning: could not make absolute file: '" <<  EC.message()
+ << '\n';
+  llvm::sys::path::remove_dots(A

Re: [llvm-dev] Upgrading phabricator

2016-10-04 Thread Eric Liu via cfe-commits
This is not due to the upgrade. There was long delay before Phabricator
receives a commit, but the delay seems to be gone now. Let me know if you
are still experiencing the delay.

- Eric

On Mon, Oct 3, 2016 at 4:25 PM Michał Górny  wrote:

> On Mon, 3 Oct 2016 13:47:08 +
> Sjoerd Meijer via cfe-commits  wrote:
>
> > I just committed to Clang and noticed that the corresponding Phabricator
> ticket does not get automatically closed (I have "Differential Revision:"
> in my commit message and believe I didn't make a typo).
> > Is it just me, or is this is broken after the upgrade? For committing to
> LLVM this still seems to work.
>
> Just to clarify, it seems that Phabricator stopped processing
> (receiving?) new commits one or two days ago. However, it used to work
> after the upgrade, so that's probably unrelated.
>
> --
> Best regards,
> Michał Górny
> 
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24082: [CMake] Fix libc++abi arm build w/o libunwind.

2016-10-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

LGTM too.

@EricWF or @mclow.lists need to approve.


https://reviews.llvm.org/D24082



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


[PATCH] D25204: Register Calling Convention, Clang changes

2016-10-04 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Eric, please, prepare a full context review!



> ItaniumMangle.cpp:1417-1421
> +  if (isRegCall) {
> +Out << II->getLength() + sizeof("__regcall3__") - 1<< "__regcall3__";
> +  } else {
> +Out << II->getLength();
> +  }

Single-line substatements must not be enclosed into braces

> ItaniumMangle.cpp:1418
> +  if (isRegCall) {
> +Out << II->getLength() + sizeof("__regcall3__") - 1<< "__regcall3__";
> +  } else {

Line is not clang-formatted

> Mangle.cpp:70
>const llvm::Triple &Triple = TI.getTriple();
> +
>if (!Triple.isOSWindows() ||

Seems to me this change is not required

> MicrosoftMangle.cpp:440
>mangleName(D);
> -  if (const FunctionDecl *FD = dyn_cast(D))
> +  if (const FunctionDecl *FD = dyn_cast(D)) 
>  mangleFunctionEncoding(FD, Context.shouldMangleDeclName(FD));

No changes here, restore original line

Repository:
  rL LLVM

https://reviews.llvm.org/D25204



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


[clang-tools-extra] r283205 - Fix windows builtbot error.

2016-10-04 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Oct  4 04:49:20 2016
New Revision: 283205

URL: http://llvm.org/viewvc/llvm-project?rev=283205&view=rev
Log:
Fix windows builtbot error.

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=283205&r1=283204&r2=283205&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Tue Oct  4 04:49:20 2016
@@ -36,6 +36,7 @@ std::string MakeAbsolutePath(StringRef C
 llvm::errs() << "Warning: could not make absolute file: '" <<  EC.message()
  << '\n';
   llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
+  llvm::sys::path::native(AbsolutePath);
   return AbsolutePath.str();
 }
 
@@ -51,6 +52,7 @@ std::string MakeAbsolutePath(const Sourc
 llvm::errs() << "Warning: could not make absolute file: '" <<  EC.message()
  << '\n';
   llvm::sys::path::remove_dots(AbsolutePath, /*remove_dot_dot=*/true);
+  llvm::sys::path::native(AbsolutePath);
   return AbsolutePath.str();
 }
 


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


r283206 - Minor cleanups in clang-format.el.

2016-10-04 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Oct  4 04:53:04 2016
New Revision: 283206

URL: http://llvm.org/viewvc/llvm-project?rev=283206&view=rev
Log:
Minor cleanups in clang-format.el.

- Enable lexical binding
- Formatting
- Enable file name completion for the clang-format-executable variable
- Add a missing docstring
- When available, use bufferpos-to-filepos and filepos-to-bufferpos. These 
functions given more precise mapping than byte-to-position and position-bytes.
- Rename arguments of clang-format-region to match the docstring
- Instead of binding local variables to nil and then assigning them, bind them 
directly to their values
- Make use of the fact that insert-file-contents returns the number of 
characters it inserted
- Use cl-destructuring-bind to make the code a bit shorter
- Use standard iteration (dolist) instead of mapc with a lambda, which is more 
common and shorter
- Remove a message that was most likely only present for debugging purposes

Patch by Philipp Stephani.

Modified:
cfe/trunk/tools/clang-format/clang-format.el

Modified: cfe/trunk/tools/clang-format/clang-format.el
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.el?rev=283206&r1=283205&r2=283206&view=diff
==
--- cfe/trunk/tools/clang-format/clang-format.el (original)
+++ cfe/trunk/tools/clang-format/clang-format.el Tue Oct  4 04:53:04 2016
@@ -1,4 +1,4 @@
-;;; clang-format.el --- Format code using clang-format
+;;; clang-format.el --- Format code using clang-format  -*- lexical-binding: 
t; -*-
 
 ;; Keywords: tools, c
 ;; Package-Requires: ((cl-lib "0.3"))
@@ -15,7 +15,7 @@
 ;;   M-x package-install clang-format
 ;;
 ;; when ("melpa" . "http://melpa.org/packages/";) is included in
-;; `package-archives'. Alternatively, ensure the directory of this
+;; `package-archives'.  Alternatively, ensure the directory of this
 ;; file is in your `load-path' and add
 ;;
 ;;   (require 'clang-format)
@@ -42,7 +42,7 @@
 
 A string containing the name or the full path of the executable."
   :group 'clang-format
-  :type 'string
+  :type '(file :must-match t)
   :risky t)
 
 (defcustom clang-format-style "file"
@@ -93,15 +93,32 @@ of the buffer."
 (list replacements cursor (string= incomplete-format "true"
 
 (defun clang-format--replace (offset length &optional text)
-  (let ((start (byte-to-position (1+ offset)))
-(end (byte-to-position (+ 1 offset length
+  "Replace the region defined by OFFSET and LENGTH with TEXT.
+OFFSET and LENGTH are measured in bytes, not characters.  OFFSET
+is a zero-based file offset."
+  (let ((start (clang-format--filepos-to-bufferpos offset 'exact))
+(end (clang-format--filepos-to-bufferpos (+ offset length) 'exact)))
 (goto-char start)
 (delete-region start end)
 (when text
   (insert text
 
+;; ‘bufferpos-to-filepos’ and ‘filepos-to-bufferpos’ are new in Emacs 
25.1.
+;; Provide fallbacks for older versions.
+(defalias 'clang-format--bufferpos-to-filepos
+  (if (fboundp 'bufferpos-to-filepos)
+  'bufferpos-to-filepos
+(lambda (position &optional _quality _coding-system)
+  (1- (position-bytes position)
+
+(defalias 'clang-format--filepos-to-bufferpos
+  (if (fboundp 'filepos-to-bufferpos)
+  'filepos-to-bufferpos
+(lambda (byte &optional _quality _coding-system)
+  (byte-to-position (1+ byte)
+
 ;;;###autoload
-(defun clang-format-region (char-start char-end &optional style)
+(defun clang-format-region (start end &optional style)
   "Use clang-format to format the code between START and END according to 
STYLE.
 If called interactively uses the region or the current statement if there
 is no active region.  If no style is given uses `clang-format-style'."
@@ -113,51 +130,41 @@ is no active region.  If no style is giv
   (unless style
 (setq style clang-format-style))
 
-  (let ((start (1- (position-bytes char-start)))
-(end (1- (position-bytes char-end)))
-(cursor (1- (position-bytes (point
+  (let ((file-start (clang-format--bufferpos-to-filepos start 'approximate))
+(file-end (clang-format--bufferpos-to-filepos end 'approximate))
+(cursor (clang-format--bufferpos-to-filepos (point) 'exact))
 (temp-buffer (generate-new-buffer " *clang-format-temp*"))
 (temp-file (make-temp-file "clang-format")))
 (unwind-protect
-(let (status stderr operations)
-  (setq status
-(call-process-region
- nil nil clang-format-executable
- nil `(,temp-buffer ,temp-file) nil
-
- "-output-replacements-xml"
- "-assume-filename" (or (buffer-file-name) "")
- "-style" style
- "-offset" (number-to-string start)
- "-length" (number-to-string (- end start))
- "-cursor" (number-to-string cursor)))
-  (setq stderr
-  

[PATCH] D24997: [ClangTidy] Add UsingInserter and NamespaceAliaser

2016-10-04 Thread Haojian Wu via cfe-commits
hokein added a comment.

Looks almost fine, a few code-style comments.



> ASTUtils.h:11
> +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
> +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
> +#include "clang/AST/AST.h"

A blank line between define guard and include.

> ASTUtils.h:17
> +namespace utils {
> +const FunctionDecl *getSurroundingFunction(ASTContext &Context,
> +   const Stmt &Statement);

Could you add a few documentation describing this interface?

> ASTUtils.h:21
> +} // namespace tidy
> +} // namespace clang
> +#endif

A blank line below.

> NamespaceAliaser.cpp:8
> +//
> +//===--===//
> +#include "NamespaceAliaser.h"

A blank line.

> NamespaceAliaser.cpp:14
> +#include "clang/ASTMatchers/ASTMatchers.h"
> +#include "clang/Lex/Lexer.h"
> +namespace clang {

A blank line below.

> NamespaceAliaser.cpp:41
> +
> +  // TODO(bangert): Doesn't consider the order of declarations.
> +  // If we accidentially pick an alias defined later in the function,

FIXME.

> NamespaceAliaser.cpp:44
> +  // the output won't compile.
> +  // TODO(bangert): Also doesn't consider file or class-scope aliases.
> +

FIXME.

> NamespaceAliaser.cpp:85
> +   StringRef Namespace) const {
> +  auto *Function = getSurroundingFunction(Context, Statement);
> +  auto FunctionAliases = AddedAliases.find(Function);

I'd prefer to declare it `const auto *`.

> NamespaceAliaser.h:8
> +//
> +//===--===//
> +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_NAMESPACEALIASER_H

A blank line.

> NamespaceAliaser.h:21
> +namespace tidy {
> +namespace utils {
> +// This class creates function-level namespace aliases.

A blank line below.

> NamespaceAliaser.h:28
> +  // Statement. Picks the first available name from \p Abbreviations.
> +  // Returns ``llvm::None`` if an alias already exists or these is an error.
> +  llvm::Optional

s/these/there?

> NamespaceAliaser.h:41
> +  const SourceManager &SourceMgr;
> +  std::map> AddedAliases;
> +};

Use `llvm::DenseMap` instead.

> UsingInserter.cpp:49
> +
> +  // TODO(bangert): This declaration could be masked. Investigate if
> +  // there is a way to avoid using Sema.

Use `FIXME` instead of `TODO(bangert).`

> UsingInserter.h:23
> +
> +// UsingInserter adds function-level using declarations.
> +class UsingInserter {

Could you elaborate a bit more?

> UsingInserter.h:41
> +  const SourceManager &SourceMgr;
> +  std::set> AddedUsing;
> +};

It'd be clearer to use a typedef for `std::pair` here.

https://reviews.llvm.org/D24997



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


r283207 - Do not find friend function definitions inside non-instantiated class.

2016-10-04 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Tue Oct  4 05:11:43 2016
New Revision: 283207

URL: http://llvm.org/viewvc/llvm-project?rev=283207&view=rev
Log:
Do not find friend function definitions inside non-instantiated class.

Previously if a file-level function was defined inside befriending
template class, it always was treated as defined. For instance, the code like:
```
  int func(int x);
  template class C1 {
friend int func(int x) { return x; }
  };
  template class C2 {
friend int func(int x) { return x; }
  };
```
could not be compiled due to function redefinition, although not of the 
templates
is instantiated. Moreover, the body of friend function can contain use of 
template
parameters, attempt to get definition of such function outside any instantiation
causes compiler abnormal termination.

Other compilers (gcc, icc) follow viewpoint that the body of the function 
defined
in friend declaration becomes available when corresponding class is 
instantiated.
This patch implements this viewpoint in clang.

Definitions introduced by friend declarations in template classes are not added
to the redeclaration chain of corresponding function. Only when the template is
instantiated, instantiation of the function definition is placed to the chain.

The fix was made in collaboration with Richard Smith.

This change fixes PR8035, PR17923, PR22307 and PR25848.

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

Added:
cfe/trunk/test/SemaCXX/PR25848.cpp
cfe/trunk/test/SemaCXX/friend2.cpp
cfe/trunk/test/SemaCXX/function-redecl-2.cpp
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=283207&r1=283206&r2=283207&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct  4 05:11:43 2016
@@ -1760,6 +1760,7 @@ public:
   bool CheckFunctionDeclaration(Scope *S,
 FunctionDecl *NewFD, LookupResult &Previous,
 bool IsExplicitSpecialization);
+  bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
   void CheckMain(FunctionDecl *FD, const DeclSpec &D);
   void CheckMSVCRTEntryPoint(FunctionDecl *FD);
   Decl *ActOnParamDeclarator(Scope *S, Declarator &D);

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=283207&r1=283206&r2=283207&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct  4 05:11:43 2016
@@ -8664,6 +8664,32 @@ Sema::ActOnFunctionDeclarator(Scope *S,
   return NewFD;
 }
 
+/// \brief Checks if the new declaration declared in dependent context must be
+/// put in the same redeclaration chain as the specified declaration.
+///
+/// \param D Declaration that is checked.
+/// \param PrevDecl Previous declaration found with proper lookup method for 
the
+/// same declaration name.
+/// \returns True if D must be added to the redeclaration chain which PrevDecl
+///  belongs to.
+///
+bool Sema::shouldLinkDependentDeclWithPrevious(Decl *D, Decl *PrevDecl) {
+  // Any declarations should be put into redeclaration chains except for
+  // friend declaration in a dependent context that names a function in
+  // namespace scope.
+  //
+  // This allows to compile code like:
+  //
+  //   void func();
+  //   template class C1 { friend void func() { } };
+  //   template class C2 { friend void func() { } };
+  //
+  // This code snippet is a valid code unless both templates are instantiated.
+  return !(D->getLexicalDeclContext()->isDependentContext() &&
+   D->getDeclContext()->isFileContext() &&
+   D->getFriendObjectKind() != Decl::FOK_None);
+}
+
 /// \brief Perform semantic checking of a new function declaration.
 ///
 /// Performs semantic analysis of the new function declaration
@@ -8847,11 +8873,14 @@ bool Sema::CheckFunctionDeclaration(Scop
   }
 
 } else {
-  // This needs to happen first so that 'inline' propagates.
-  NewFD->setPreviousDeclaration(cast(OldDecl));
-
-  if (isa(NewFD))
-NewFD->setAccess(OldDecl->getAccess());
+  if (shouldLinkDependentDeclWithPrevious(NewFD, OldDecl)) {
+// This needs to happen first so that 'inline' propagates.
+NewFD->setPreviousDeclaration(cast(OldDecl));
+if (isa(NewFD))
+  NewFD->setAccess(OldDecl->getAccess());
+  } else {
+Redeclaration = false;
+  }
 }
   }
 

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=283207&r1=283206&r2=283207&view=diff
=

[PATCH] D16989: Change interpretation of function definition in friend declaration of template class.

2016-10-04 Thread Serge Pavlov via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283207: Do not find friend function definitions inside 
non-instantiated class. (authored by sepavloff).

Changed prior to commit:
  https://reviews.llvm.org/D16989?vs=70134&id=73440#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D16989

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/SemaCXX/PR25848.cpp
  cfe/trunk/test/SemaCXX/friend2.cpp
  cfe/trunk/test/SemaCXX/function-redecl-2.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -1760,6 +1760,7 @@
   bool CheckFunctionDeclaration(Scope *S,
 FunctionDecl *NewFD, LookupResult &Previous,
 bool IsExplicitSpecialization);
+  bool shouldLinkDependentDeclWithPrevious(Decl *D, Decl *OldDecl);
   void CheckMain(FunctionDecl *FD, const DeclSpec &D);
   void CheckMSVCRTEntryPoint(FunctionDecl *FD);
   Decl *ActOnParamDeclarator(Scope *S, Declarator &D);
Index: cfe/trunk/test/SemaCXX/PR25848.cpp
===
--- cfe/trunk/test/SemaCXX/PR25848.cpp
+++ cfe/trunk/test/SemaCXX/PR25848.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A;
+
+inline int g();  // expected-warning{{inline function 'g' is not defined}}
+
+template
+struct R {
+  friend int g() {
+return M;
+  }
+};
+
+void m() {
+  g();  // expected-note{{used here}}
+}
Index: cfe/trunk/test/SemaCXX/function-redecl-2.cpp
===
--- cfe/trunk/test/SemaCXX/function-redecl-2.cpp
+++ cfe/trunk/test/SemaCXX/function-redecl-2.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+namespace redecl_in_templ {
+template void redecl_in_templ() {
+  extern void func_1();  // expected-note  {{previous declaration is here}}
+  extern int  func_1();  // expected-error {{functions that differ only in their return type cannot be overloaded}}
+}
+
+void g();
+constexpr void (*p)() = g;
+
+template struct X {};
+template<> struct X { typedef int type; };
+
+template void f() {
+  extern void g();
+  X<&g == p>::type n;
+}
+}
Index: cfe/trunk/test/SemaCXX/friend2.cpp
===
--- cfe/trunk/test/SemaCXX/friend2.cpp
+++ cfe/trunk/test/SemaCXX/friend2.cpp
@@ -0,0 +1,172 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+// If a friend function is defined in several non-template classes,
+// it is an error.
+
+void func1(int);
+struct C1a {
+  friend void func1(int) {}  // expected-note{{previous definition is here}}
+};
+struct C1b {
+  friend void func1(int) {}  // expected-error{{redefinition of 'func1'}}
+};
+
+
+// If a friend function is defined in both non-template and template
+// classes it is an error only if the template is instantiated.
+
+void func2(int);
+struct C2a {
+  friend void func2(int) {}
+};
+template struct C2b {
+  friend void func2(int) {}
+};
+
+void func3(int);
+struct C3a {
+  friend void func3(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C3b {
+  friend void func3(int) {}  // expected-error{{redefinition of 'func3'}}
+};
+C3b c3;  // expected-note{{in instantiation of template class 'C3b' requested here}}
+
+
+// If a friend function is defined in several template classes it is an error
+// only if several templates are instantiated.
+
+void func4(int);
+template struct C4a {
+  friend void func4(int) {}
+};
+template struct C4b {
+  friend void func4(int) {}
+};
+
+
+void func5(int);
+template struct C5a {
+  friend void func5(int) {}
+};
+template struct C5b {
+  friend void func5(int) {}
+};
+C5a c5a;
+
+void func6(int);
+template struct C6a {
+  friend void func6(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C6b {
+  friend void func6(int) {}  // expected-error{{redefinition of 'func6'}}
+};
+C6a c6a;
+C6b c6b;  // expected-note{{in instantiation of template class 'C6b' requested here}}
+
+void func7(int);
+template struct C7 {
+  friend void func7(int) {}  // expected-error{{redefinition of 'func7'}}
+ // expected-note@-1{{previous definition is here}}
+};
+C7 c7a;
+C7 c7b;  // expected-note{{in instantiation of template class 'C7' requested here}}
+
+
+// Even if clases are not instantiated and hence friend functions defined in them are not
+// available, their declarations can be checked.
+
+void func8(int);  // expected-note{{previous declaration is here}}
+template struct C8a {
+  friend long func8(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void func9(int);  // expected-note{{previous declaration is here}}
+template

[PATCH] D23712: [OpenCL] Override supported OpenCL extensions with -cl-ext option

2016-10-04 Thread Andrew Savonichev via cfe-commits
asavonic updated this revision to Diff 73443.
asavonic added a comment.

- Describe OpenCLOptions::set() function
- Move -cl-ext option to cc1
- Reword -cl-ext option help
- Move -cl-ext handling out of target-specific code
- Add two more test cases regarding -cl-ext option


https://reviews.llvm.org/D23712

Files:
  include/clang/Basic/OpenCLOptions.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  include/clang/Driver/CC1Options.td
  lib/Basic/Targets.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/SemaOpenCL/extensions.cl

Index: test/SemaOpenCL/extensions.cl
===
--- test/SemaOpenCL/extensions.cl
+++ test/SemaOpenCL/extensions.cl
@@ -2,7 +2,26 @@
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
 
 // Test with a target not supporting fp64.
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
+
+// Test with some extensions enabled or disabled by cmd-line args
+//
+// Target does not support fp64 and fp16 - override it
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+cl_khr_fp64,+cl_khr_fp16
+//
+// Disable or enable all extensions
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16
+//
+// Concatenating
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64  -DNOFP16
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64,+cl_khr_fp64  -DNOFP16
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64 -cl-ext=+cl_khr_fp16 -cl-ext=-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -cl-ext=+cl_khr_fp64,-cl_khr_fp64,+cl_khr_fp16 -DNOFP64
+
+
 
 void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
   double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
@@ -14,6 +33,11 @@
 // expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp64' - ignoring}}
 #endif
 
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+#ifdef NOFP16
+// expected-warning@-2{{unsupported OpenCL extension 'cl_khr_fp16' - ignoring}}
+#endif
+
 void f2(void) {
   double d;
 #ifdef NOFP64
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2349,6 +2349,7 @@
   // Use the default target triple if unspecified.
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
+  Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
 }
 
 bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8676,6 +8676,7 @@
 return nullptr;
 
   Target->setSupportedOpenCLOpts();
+  Target->setOpenCLExtensionOpts();
 
   if (!Target->validateTarget(Diags))
 return nullptr;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -685,6 +685,13 @@
   HelpText<"include a detailed record of preprocessing actions">;
 
 //===--===//
+// OpenCL Options
+//===--===//
+
+def cl_ext_EQ : CommaJoined<["-"], "cl-ext=">,
+  HelpText<"OpenCL only. Enable or disable OpenCL extensions. The argument is a comma-separated sequence of one or more extension names, each prefixed by '+' or '-'.">;
+
+//===--===//
 // CUDA Options
 //===--===//
 
Index: include/clang/Basic/TargetOptions.h
===
--- include/clang/Basic/TargetOptions.h
+++ include/clang/Basic/TargetOptions.h
@@ -58,6 +58,10 @@
 
   /// Supported OpenCL extensions and optional core features.
   OpenCLOption

[PATCH] D24380: [migrate-tool] Framework for a codebase-dependent migration tool.

2016-10-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 73446.
ioeric added a comment.
Herald added a subscriber: modocache.

- Add SymbolRenameSpec; replace addIncludesToFiles and renameSymbolsInFiles 
with renameSymbolsInAffectedFiles.


https://reviews.llvm.org/D24380

Files:
  CMakeLists.txt
  migrate-tool/AffectedFilesFinder.h
  migrate-tool/BuildManager.h
  migrate-tool/CMakeLists.txt
  migrate-tool/FileSystemManager.h
  migrate-tool/HeaderGenerator.cpp
  migrate-tool/HeaderGenerator.h
  migrate-tool/MigrateTool.cpp
  migrate-tool/MigrateTool.h
  migrate-tool/MigrationEnvironment.h
  migrate-tool/RefactoringManager.h
  unittests/CMakeLists.txt
  unittests/migrate-tool/CMakeLists.txt
  unittests/migrate-tool/DummyMigrateToolTest.cpp
  unittests/migrate-tool/DummyMigrationEnvironment.cpp
  unittests/migrate-tool/DummyMigrationEnvironment.h
  unittests/migrate-tool/HeaderBuildTest.cpp

Index: unittests/migrate-tool/HeaderBuildTest.cpp
===
--- /dev/null
+++ unittests/migrate-tool/HeaderBuildTest.cpp
@@ -0,0 +1,100 @@
+//===-- HeaderGeneratorTest.cpp - HeaderGenerator unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "HeaderGenerator.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace migrate_tool {
+
+TEST(HeaderGenerator, Empty) {
+  HeaderGenerator Hdr("a.h");
+  std::string Expected = "#ifndef A_H\n"
+ "#define A_H\n"
+ "\n"
+ "#endif // A_H";
+  EXPECT_EQ(Expected, Hdr.generateContent());
+}
+
+TEST(HeaderGenerator, SingleAlias) {
+  HeaderGenerator Hdr("a/b/c.h");
+  Hdr.addAlias("na::nb::C", "x::y::Z");
+  std::string Expected = "#ifndef A_B_C_H\n"
+ "#define A_B_C_H\n"
+ "namespace na {\n"
+ "namespace nb {\n"
+ "using C = ::x::y::Z;\n"
+ "} // namespace nb\n"
+ "} // namespace na\n"
+ "#endif // A_B_C_H";
+  EXPECT_EQ(Expected, Hdr.generateContent());
+}
+
+TEST(HeaderGenerator, SingleAliasWithIncludes) {
+  HeaderGenerator Hdr("a/b/c.h");
+  Hdr.addInclude("x/y/z.h");
+  Hdr.addInclude("x/y/zz.h");
+  Hdr.addAlias("na::nb::C", "x::y::Z");
+  std::string Expected = "#ifndef A_B_C_H\n"
+ "#define A_B_C_H\n"
+ "#include \"x/y/z.h\"\n"
+ "#include \"x/y/zz.h\"\n"
+ "namespace na {\n"
+ "namespace nb {\n"
+ "using C = ::x::y::Z;\n"
+ "} // namespace nb\n"
+ "} // namespace na\n"
+ "#endif // A_B_C_H";
+  EXPECT_EQ(Expected, Hdr.generateContent());
+}
+
+TEST(HeaderGenerator, MultipleAliasInOneNamespace) {
+  HeaderGenerator Hdr("a/b/c.h");
+  Hdr.addAlias("na::nb::C", "x::y::Z");
+  Hdr.addAlias("na::nb::D", "x::y::D");
+  Hdr.addAlias("na::nb::Q", "x::y::Q");
+  std::string Expected = "#ifndef A_B_C_H\n"
+ "#define A_B_C_H\n"
+ "namespace na {\n"
+ "namespace nb {\n"
+ "using C = ::x::y::Z;\n"
+ "using D = ::x::y::D;\n"
+ "using Q = ::x::y::Q;\n"
+ "} // namespace nb\n"
+ "} // namespace na\n"
+ "#endif // A_B_C_H";
+  EXPECT_EQ(Expected, Hdr.generateContent());
+}
+
+TEST(HeaderGenerator, AliasesInMultipleNamespace) {
+  HeaderGenerator Hdr("a/b/c.h");
+  Hdr.addAlias("nb::Q", "x::Q");
+  Hdr.addAlias("na::nb::C", "x::y::Z");
+  Hdr.addAlias("na::nc::D", "x::y::D");
+  Hdr.addAlias("na::nb::Q", "x::y::Q");
+  std::string Expected = "#ifndef A_B_C_H\n"
+ "#define A_B_C_H\n"
+ "namespace nb {\n"
+ "using Q = ::x::Q;\n"
+ "} // namespace nb\n"
+ "namespace na {\n"
+ "namespace nb {\n"
+ "using C = ::x::y::Z;\n"
+ "using Q = ::x::y::Q;\n"
+ "} // namespace nb\n"
+ "namespace nc {\n"
+ "using D = ::x::y::D;\n"
+ "} // namespace nc\n"
+ "} // namespace na\n"
+ "#endif // A_B_C_H";
+  EXPECT_EQ(Expected, Hdr.generateContent());
+}
+
+} // namespace migrate_tool
+} // namespace clang
Index: unittests/migrate-tool/DummyMigrationEnvironment.h
==

[clang-tools-extra] r283210 - [change-namespace] Fix a misplaced case when there is no trailing newline character at the end of the file.

2016-10-04 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Oct  4 05:35:53 2016
New Revision: 283210

URL: http://llvm.org/viewvc/llvm-project?rev=283210&view=rev
Log:
[change-namespace] Fix a misplaced case when there is no trailing newline 
character at the end of the file.

Reviewers: ioeric

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=283210&r1=283209&r2=283210&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Tue Oct  4 
05:35:53 2016
@@ -106,8 +106,9 @@ SourceLocation getStartOfNextLine(Source
   // FIXME: this is a bit hacky to get ReadToEndOfLine work.
   Lex.setParsingPreprocessorDirective(true);
   Lex.ReadToEndOfLine(&Line);
-  // FIXME: should not +1 at EOF.
-  return Loc.getLocWithOffset(Line.size() + 1);
+  auto End = Loc.getLocWithOffset(Line.size());
+  return SM.getLocForEndOfFile(LocInfo.first) == End ? End
+ : End.getLocWithOffset(1);
 }
 
 // Returns `R` with new range that refers to code after `Replaces` being

Modified: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp?rev=283210&r1=283209&r2=283210&view=diff
==
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp 
Tue Oct  4 05:35:53 2016
@@ -513,6 +513,27 @@ TEST_F(ChangeNamespaceTest, DoNotFixStat
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NoMisplaceAtEOF) {
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A;\n"
+ "class B {};\n"
+ "}"
+ "}";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "class A;\n"
+ "}\n"
+ "}\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "\n"
+ "class B {};\n"
+ "} // namespace y\n"
+ "} // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang


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


[PATCH] D25226: [change-namespace] Fix a misplaced case when there is no trailing newline character at the end of the file.

2016-10-04 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283210: [change-namespace] Fix a misplaced case when there 
is no trailing newline… (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D25226?vs=73420&id=73447#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25226

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp


Index: 
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -513,6 +513,27 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NoMisplaceAtEOF) {
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A;\n"
+ "class B {};\n"
+ "}"
+ "}";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "class A;\n"
+ "}\n"
+ "}\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "\n"
+ "class B {};\n"
+ "} // namespace y\n"
+ "} // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -106,8 +106,9 @@
   // FIXME: this is a bit hacky to get ReadToEndOfLine work.
   Lex.setParsingPreprocessorDirective(true);
   Lex.ReadToEndOfLine(&Line);
-  // FIXME: should not +1 at EOF.
-  return Loc.getLocWithOffset(Line.size() + 1);
+  auto End = Loc.getLocWithOffset(Line.size());
+  return SM.getLocForEndOfFile(LocInfo.first) == End ? End
+ : End.getLocWithOffset(1);
 }
 
 // Returns `R` with new range that refers to code after `Replaces` being


Index: clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
+++ clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -513,6 +513,27 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, NoMisplaceAtEOF) {
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A;\n"
+ "class B {};\n"
+ "}"
+ "}";
+  std::string Expected = "namespace na {\n"
+ "namespace nb {\n"
+ "class A;\n"
+ "}\n"
+ "}\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "\n"
+ "class B {};\n"
+ "} // namespace y\n"
+ "} // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 } // anonymous namespace
 } // namespace change_namespace
 } // namespace clang
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -106,8 +106,9 @@
   // FIXME: this is a bit hacky to get ReadToEndOfLine work.
   Lex.setParsingPreprocessorDirective(true);
   Lex.ReadToEndOfLine(&Line);
-  // FIXME: should not +1 at EOF.
-  return Loc.getLocWithOffset(Line.size() + 1);
+  auto End = Loc.getLocWithOffset(Line.size());
+  return SM.getLocForEndOfFile(LocInfo.first) == End ? End
+ : End.getLocWithOffset(1);
 }
 
 // Returns `R` with new range that refers to code after `Replaces` being
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r283211 - Fix a documentation warning.

2016-10-04 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Oct  4 05:40:52 2016
New Revision: 283211

URL: http://llvm.org/viewvc/llvm-project?rev=283211&view=rev
Log:
Fix a documentation warning.

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.h

Modified: clang-tools-extra/trunk/clang-move/ClangMove.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.h?rev=283211&r1=283210&r2=283211&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.h (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.h Tue Oct  4 05:40:52 2016
@@ -66,7 +66,7 @@ public:
   /// \param SearchPath The search path which was used to find the 
IncludeHeader
   /// in the file system. It can be a relative path or an absolute path.
   /// \param FileName The name of file where the IncludeHeader comes from.
-  /// \param SourceManager The SourceManager.
+  /// \param SM The SourceManager.
   void addIncludes(llvm::StringRef IncludeHeader,
bool IsAngled,
llvm::StringRef SearchPath,


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


[PATCH] D25227: [clang-move] Move comments which are associated with the moved class.

2016-10-04 Thread Eric Liu via cfe-commits
ioeric added a comment.

This is great!



> ClangMove.cpp:70-74
> +  if (SM->getLocForEndOfFile(LocInfo.first)
> +  == EndLoc)
> +return EndLoc;
> +  // Include the trailing newline character "\n".
> +  return EndLoc.getLocWithOffset(1);

Maybe:

  return (SM->getLocForEndOfFile(LocInfo.first) == EndLoc) ? EndLoc : 
EndLoc.getLocWithOffset(1);

> ClangMove.cpp:343
>for (const auto &MovedDecl : RemovedDecls) {
> -auto EndLoc = getLocForEndOfDecl(MovedDecl.Decl, MovedDecl.SM);
> +auto Range = GetFullRange(MovedDecl.SM, MovedDecl.Decl);
>  clang::tooling::Replacement RemoveReplacement(

Looks like `GetFullRange` is called twice on the same Decl: one for creating 
insertion replacement and one for deletion replacement. This seems to be a 
duplicate.

https://reviews.llvm.org/D25227



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


[PATCH] D24965: [clang-tidy] Fix cppcoreguidelines-pro-type-member-init false negatives

2016-10-04 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 73452.
malcolm.parsons added a comment.

Don't match template instantiations.
Add assert message.
Update macro comment.
Add tests for templates and macros.


https://reviews.llvm.org/D24965

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  clang-tidy/utils/TypeTraits.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -377,3 +377,46 @@
 {
   NegativeInClassInitializedDefaulted s;
 }
+
+struct PositiveVirtualMethod {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these fields: F
+  int F;
+  // CHECK-FIXES: int F{};
+  virtual int f() = 0;
+};
+
+struct PositiveVirtualDestructor {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these fields: F
+  PositiveVirtualDestructor() = default;
+  int F;
+  // CHECK-FIXES: int F{};
+  virtual ~PositiveVirtualDestructor() {}
+};
+
+struct PositiveVirtualBase : public virtual NegativeAggregateType {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these bases: NegativeAggregateType
+  // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: constructor does not initialize these fields: F
+  int F;
+  // CHECK-FIXES: int F{};
+};
+
+template 
+struct NegativeTemplateVirtualDestructor {
+  T Val;
+  virtual ~NegativeTemplateVirtualDestructor() = default;
+};
+
+template struct NegativeTemplateVirtualDestructor;
+
+#define UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(FIELD) \
+  struct UninitializedFieldVirtual##FIELD {  \
+int FIELD;   \
+virtual ~UninitializedFieldVirtual##FIELD() {}   \
+  }; \
+// Ensure FIELD is not initialized since fixes inside of macros are disabled.
+// CHECK-FIXES: int FIELD;
+
+UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(F);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: F
+UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(G);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: G
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -58,6 +58,9 @@
   // constructible.
   if (ClassDecl->hasUserProvidedDefaultConstructor())
 return false;
+  // A polymorphic class is not trivially constructible
+  if (ClassDecl->isPolymorphic())
+return false;
   // A class is trivially constructible if it has a trivial default constructor.
   if (ClassDecl->hasTrivialDefaultConstructor())
 return true;
@@ -73,6 +76,8 @@
   for (const CXXBaseSpecifier &Base : ClassDecl->bases()) {
 if (!isTriviallyDefaultConstructible(Base.getType(), Context))
   return false;
+if (Base.isVirtual())
+  return false;
   }
 
   return true;
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
@@ -46,11 +46,13 @@
   // To fix: Write a data member initializer, or mention it in the member
   // initializer list.
   void checkMissingMemberInitializer(ASTContext &Context,
+ const CXXRecordDecl *ClassDecl,
  const CXXConstructorDecl *Ctor);
 
   // A subtle side effect of Type.6 part 2:
   // Make sure to initialize trivially constructible base classes.
   void checkMissingBaseClassInitializer(const ASTContext &Context,
+const CXXRecordDecl *ClassDecl,
 const CXXConstructorDecl *Ctor);
 
   // Checks Type.6 part 2:
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -269,6 +269,19 @@
IsNonTrivialDefaultConstructor))
   .bind("ctor"),
   this);
+
+  // Match classes with a default constructor that is defaulted or is not in the
+  // AST.
+  Finder->addMatcher(
+  cxxRecordDecl(
+  isDefinition(), unless(isInstantiated()),
+  anyOf(has(cxxConstructorDecl(isDefaultConstructor(), isDefaulted(),
+   unless(isImplicit(,
+unless(has(cxxConstructorDecl(,
+  unless(isTriviallyDefaultConstructible()))
+  .bind("record"),

[PATCH] D22507: Clang-tidy - Enum misuse check

2016-10-04 Thread Peter Szecsi via cfe-commits
szepet updated this revision to Diff 73439.
szepet marked an inline comment as done.
szepet added a comment.
Herald added a subscriber: modocache.

Note message checks added to testfiles.


https://reviews.llvm.org/D22507

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SuspiciousEnumUsageCheck.cpp
  clang-tidy/misc/SuspiciousEnumUsageCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-suspicious-enum-usage.rst
  test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
  test/clang-tidy/misc-suspicious-enum-usage.cpp

Index: test/clang-tidy/misc-suspicious-enum-usage.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-suspicious-enum-usage.cpp
@@ -0,0 +1,90 @@
+// RUN: %check_clang_tidy %s misc-suspicious-enum-usage %t -- -config="{CheckOptions: [{key: misc-suspicious-enum-usage.StrictMode, value: 0}]}" --
+
+enum Empty {
+};
+
+enum A {
+  A = 1,
+  B = 2,
+  C = 4,
+  D = 8,
+  E = 16,
+  F = 32,
+  G = 63
+};
+
+enum X {
+  X = 8,
+  Y = 16,
+  Z = 4
+};
+
+enum {
+  P = 2,
+  Q = 3,
+  R = 4,
+  S = 8,
+  T = 16
+};
+
+enum {
+  H,
+  I,
+  J,
+  K,
+  L
+};
+
+enum Days {
+  Monday,
+  Tuesday,
+  Wednesday,
+  Thursday,
+  Friday,
+  Saturday,
+  Sunday
+};
+
+Days bestDay() {
+  return Friday;
+}
+
+int trigger() {
+  Empty EmptyVal;
+  int emptytest = EmptyVal | B;
+  if (bestDay() | A)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types 
+  if (I | Y)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types
+}
+
+int dont_trigger() {
+  unsigned p;
+  p = Q | P;
+
+  if (A + G == E)
+return 1;
+  else if ((Q | R) == T)
+return 1;
+  else
+int k = T | Q;
+
+  Empty EmptyVal;
+  int emptytest = EmptyVal | B;
+
+  int a = 1, b = 5;
+  int c = a + b;
+  int d = c | H, e = b * a;
+  a = B | C;
+  b = X | Z;
+  
+  if (Tuesday != Monday + 1 ||
+  Friday - Thursday != 1 ||
+  Sunday + Wednesday == (Sunday | Wednesday))
+return 1;
+  if (H + I + L == 42)
+return 1;
+  return 42;
+}
Index: test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-suspicious-enum-usage-strict.cpp
@@ -0,0 +1,94 @@
+// RUN: %check_clang_tidy %s misc-suspicious-enum-usage %t -- -config="{CheckOptions: [{key: misc-suspicious-enum-usage.StrictMode, value: 1}]}" --
+
+enum A {
+  A = 1,
+  B = 2,
+  C = 4,
+  D = 8,
+  E = 16,
+  F = 32,
+  G = 63
+};
+
+enum X {
+  X = 8,
+  Y = 16,
+  Z = 4,
+  ZZ = 3
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask (contains mostly power-of-2 literals), but this literal is not a power-of-2 [misc-suspicious-enum-usage]
+// CHECK-MESSAGES: :68:13: note: used here as a bitmask
+};
+// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: enum type seems like a bitmask (contains mostly power-of-2 literals) but some literal(s) are not a power-of-2
+  // CHECK-MESSAGES: :71:8: note: used here as a bitmask
+enum PP {
+  P = 2,
+  Q = 3,
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: enum type seems like a bitmask (contains mostly power-of-2 literals), but this literal is not a power-of-2
+  // CHECK-MESSAGES: :63:7: note: used here as a bitmask
+  R = 4,
+  S = 8,
+  T = 16,
+  U = 31
+};
+
+enum {
+  H,
+  I,
+  J,
+  K,
+  L
+};
+
+enum Days {
+  Monday,
+  Tuesday,
+  Wednesday,
+  Thursday,
+  Friday,
+  Saturday,
+  Sunday
+};
+
+Days bestDay() {
+  return Friday;
+}
+
+int trigger() {
+  if (bestDay() | A)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:17: warning: enum values are from different enum types
+  if (I | Y)
+return 1;
+  // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: enum values are from different enum types
+  if (P + Q == R)
+return 1;
+  else if ((Q | R) == T)
+return 1;
+  else
+int k = ZZ | Z;
+  unsigned p = R;
+  PP pp = Q;
+  p |= pp;
+  p = A | G;
+  return 0;
+}
+
+int dont_trigger() {
+  int a = 1, b = 5;
+  int c = a + b;
+  int d = c | H, e = b * a;
+  a = B | C;
+  b = X | Z;
+
+  unsigned bitflag;
+  enum A aa = B;
+  bitflag = aa | C;
+
+  if (Tuesday != Monday + 1 ||
+  Friday - Thursday != 1 ||
+  Sunday + Wednesday == (Sunday | Wednesday))
+return 1;
+  if (H + I + L == 42)
+return 1;
+  return 42;
+}
Index: docs/clang-tidy/checks/misc-suspicious-enum-usage.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-suspicious-enum-usage.rst
@@ -0,0 +1,80 @@
+.. title:: clang-tidy - misc-suspicious-enum-usage
+
+misc-suspicious-enum-usage
+==
+
+The checker detects various cases when an enum is probably misused (as a bitmask
+).
+  
+1. When "ADD" or "bitwise OR" is used between two enum which come from different
+   types and these types value ranges are not disjoint.
+
+The following ca

[PATCH] D24361: hasDeclaration(qualType(...)) matcher should unwrap ElaboratedType and TemplateSpecializationType

2016-10-04 Thread Łukasz Anforowicz via cfe-commits
lukasza added a comment.

Richard - what are the next steps for this patch?


https://reviews.llvm.org/D24361



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


[PATCH] D25065: [change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.

2016-10-04 Thread Haojian Wu via cfe-commits
hokein added inline comments.


> ChangeNamespace.cpp:176
> +// \param DeclName A fully qualified name, "::a::b::X" or "a::b::X".
> +// \param NsName A fully qualified name, "::a::b" or "a::b".
>  std::string getShortestQualifiedNameInNamespace(llvm::StringRef DeclName,

Mightbe add a small doc saying `NsName` is a global namespace if it is empty. 
(If I misunderstand the code).

> ChangeNamespace.cpp:187
>while (true) {
> +if (DeclName.consume_front((NsName + "::").str()))
> +  return DeclName.str();

I think the statement doesn't compile here, since `consume_front` return a 
`bool`. It should be `if (DeclName.consume_front((NsName + "::")))`?

Looks like we can also put this judge into the above `while` statement?

https://reviews.llvm.org/D25065



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


[PATCH] D19586: Misleading Indentation check

2016-10-04 Thread Pauer Gergely via cfe-commits
Pajesz requested a review of this revision.
Pajesz added reviewers: dkrupp, xazax.hun, nlewycky, etienne.bergeron, etienneb.
Pajesz marked an inline comment as done.
Pajesz added a comment.

Hello!

Gonna fix the tests ASAP! Any other suggestions, fixes, improvements 
considering the checker?


https://reviews.llvm.org/D19586



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


[PATCH] D25065: [change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.

2016-10-04 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 73459.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Address review comments.


https://reviews.llvm.org/D25065

Files:
  change-namespace/ChangeNamespace.cpp
  unittests/change-namespace/ChangeNamespaceTests.cpp


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -113,6 +113,24 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveIntoAnotherNestedNamespaceWithRef) {
+  NewNamespace = "na::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "class X { A a; };\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "\n"
+ "namespace nc {\n"
+ "class X { A a; };\n"
+ "} // namespace nc\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, SimpleMoveNestedNamespace) {
   NewNamespace = "na::x::y";
   std::string Code = "namespace na {\n"
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -172,21 +172,24 @@
 // Returns the shortest qualified name for declaration `DeclName` in the
 // namespace `NsName`. For example, if `DeclName` is "a::b::X" and `NsName`
 // is "a::c::d", then "b::X" will be returned.
+// \param DeclName A fully qualified name, "::a::b::X" or "a::b::X".
+// \param NsName A fully qualified name, "::a::b" or "a::b". Global namespace
+//will have empty name.
 std::string getShortestQualifiedNameInNamespace(llvm::StringRef DeclName,
 llvm::StringRef NsName) {
-  llvm::SmallVector DeclNameSplitted;
-  DeclName.split(DeclNameSplitted, "::");
-  if (DeclNameSplitted.size() == 1)
-return DeclName;
-  const auto UnqualifiedName = DeclNameSplitted.back();
-  while (true) {
+  DeclName = DeclName.ltrim(':');
+  NsName = NsName.ltrim(':');
+  // If `DeclName` is a global variable, we prepend "::" to it if it is not in
+  // the global namespace.
+  if (DeclName.find(':') == llvm::StringRef::npos)
+return NsName.empty() ? DeclName.str() : ("::" + DeclName).str();
+
+  while (!DeclName.consume_front((NsName + "::").str())) {
 const auto Pos = NsName.find_last_of(':');
 if (Pos == llvm::StringRef::npos)
   return DeclName;
-const auto Prefix = NsName.substr(0, Pos - 1);
-if (DeclName.startswith(Prefix))
-  return (Prefix + "::" + UnqualifiedName).str();
-NsName = Prefix;
+assert(Pos > 0);
+NsName = NsName.substr(0, Pos - 1);
   }
   return DeclName;
 }


Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -113,6 +113,24 @@
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
+TEST_F(ChangeNamespaceTest, MoveIntoAnotherNestedNamespaceWithRef) {
+  NewNamespace = "na::nc";
+  std::string Code = "namespace na {\n"
+ "class A {};\n"
+ "namespace nb {\n"
+ "class X { A a; };\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "class A {};\n"
+ "\n"
+ "namespace nc {\n"
+ "class X { A a; };\n"
+ "} // namespace nc\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
 TEST_F(ChangeNamespaceTest, SimpleMoveNestedNamespace) {
   NewNamespace = "na::x::y";
   std::string Code = "namespace na {\n"
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -172,21 +172,24 @@
 // Returns the shortest qualified name for declaration `DeclName` in the
 // namespace `NsName`. For example, if `DeclName` is "a::b::X" and `NsName`
 // is "a::c::d", then "b::X" will be returned.
+// \param DeclName A fully qualified name, "::a::b::X" or "a::b::X".
+// \param NsName A fully qualified name, "::a::b" or "a::b". Global namespace
+//will have empty name.
 std::string getShortestQualifiedNameInNamespace(llvm::StringRe

[PATCH] D25065: [change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.

2016-10-04 Thread Eric Liu via cfe-commits
ioeric added inline comments.


> hokein wrote in ChangeNamespace.cpp:187
> I think the statement doesn't compile here, since `consume_front` return a 
> `bool`. It should be `if (DeclName.consume_front((NsName + "::")))`?
> 
> Looks like we can also put this judge into the above `while` statement?

Note that `str()` is called on `(NsName + "::")` instead of `consume_front`. 
But you are right, we can put the check into the while loop.

https://reviews.llvm.org/D25065



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


[PATCH] D25227: [clang-move] Move comments which are associated with the moved class.

2016-10-04 Thread Haojian Wu via cfe-commits
hokein added inline comments.


> ioeric wrote in ClangMove.cpp:343
> Looks like `GetFullRange` is called twice on the same Decl: one for creating 
> insertion replacement and one for deletion replacement. This seems to be a 
> duplicate.

Good point. Yeah, currently the `GetFullRange` is called twice. Have added a 
FIXME.

https://reviews.llvm.org/D25227



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


[PATCH] D25227: [clang-move] Move comments which are associated with the moved class.

2016-10-04 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 73463.
hokein marked an inline comment as done.
hokein added a comment.

Address review comments.


https://reviews.llvm.org/D25227

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/tool/ClangMoveMain.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -29,16 +29,19 @@
 const char TestCCName[] = "foo.cc";
 
 const char TestHeader[] = "namespace a {\n"
-  "class C1;\n"
+  "class C1; // test\n"
   "namespace b {\n"
+  "// This is a Foo class\n"
+  "// which is used in\n"
+  "// test.\n"
   "class Foo {\n"
   "public:\n"
   "  void f();\n"
   "\n"
   "private:\n"
   "  C1 *c1;\n"
   "  static int b;\n"
-  "};\n"
+  "}; // abc\n"
   "\n"
   "class Foo2 {\n"
   "public:\n"
@@ -51,19 +54,29 @@
   "namespace a {\n"
   "namespace b {\n"
   "namespace {\n"
+  "// comment1.\n"
   "void f1() {}\n"
+  "/// comment2.\n"
   "int kConstInt1 = 0;\n"
   "} // namespace\n"
   "\n"
+  "/* comment 3*/\n"
   "static int kConstInt2 = 1;\n"
   "\n"
+  "/** comment4\n"
+  "*/\n"
   "static int help() {\n"
   "  int a = 0;\n"
   "  return a;\n"
   "}\n"
   "\n"
+  "// comment5\n"
+  "// comment5\n"
   "void Foo::f() { f1(); }\n"
   "\n"
+  "/\n"
+  "// comment //\n"
+  "/\n"
   "int Foo::b = 2;\n"
   "int Foo2::f() {\n"
   "  f1();\n"
@@ -73,7 +86,7 @@
   "} // namespace a\n";
 
 const char ExpectedTestHeader[] = "namespace a {\n"
-  "class C1;\n"
+  "class C1; // test\n"
   "namespace b {\n"
   "\n"
   "class Foo2 {\n"
@@ -87,12 +100,17 @@
   "namespace a {\n"
   "namespace b {\n"
   "namespace {\n"
+  "// comment1.\n"
   "void f1() {}\n"
+  "/// comment2.\n"
   "int kConstInt1 = 0;\n"
   "} // namespace\n"
   "\n"
+  "/* comment 3*/\n"
   "static int kConstInt2 = 1;\n"
   "\n"
+  "/** comment4\n"
+  "*/\n"
   "static int help() {\n"
   "  int a = 0;\n"
   "  return a;\n"
@@ -106,31 +124,44 @@
   "} // namespace a\n";
 
 const char ExpectedNewHeader[] = "namespace a {\n"
- "class C1;\n"
+ "class C1; // test\n"
  "namespace b {\n"
+ "// This is a Foo class\n"
+ "// which is used in\n"
+ "// test.\n"
  "class Foo {\n"
  "public:\n"
  "  void f();\n"
  "\n"
  "private:\n"
  "  C1 *c1;\n"
  "  static int b;\n"
- "};\n"
+ "}; // abc\n"
  "} // namespace b\n"
  "} // namespace a\n";
 
 const char ExpectedNewCC[] = "namespace a {\n"
  "namespace b {\n"
  "namespace {\n"
+ "// comment1.\n"
  "void f1() {}\n"
+ "/// comment2.

[PATCH] D25213: Fix PR28181: Prevent operator overloading related assertion failure crash that happens in C only

2016-10-04 Thread Alex Lorenz via cfe-commits
arphaman updated this revision to Diff 73460.
arphaman marked an inline comment as done.
arphaman added a comment.

Thanks for the response,

I updated the patch with a approach that you suggested - now 
`Sema::CreateOverloadedBinOp` isn't called in C mode (I have an assertion for 
this in `Sema::CreateOverloadedBinOp`, but I'll commit it separately after).

I also tried moving the CorrectDelayedTyposInExpr code from 
`Sema::CreateBuiltinBinOp` to `Sema::BuildBinOp` as you suggested, but it 
didn't seem to have any effect whatsoever - it didn't seem to change the 
behavior of anything with respect to this bug or llvm's test suite. Therefore, 
I decided to leave it in its original location in this diff. Perhaps I've 
misunderstood your suggestion?


Repository:
  rL LLVM

https://reviews.llvm.org/D25213

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/PR28181.c


Index: test/Sema/PR28181.c
===
--- /dev/null
+++ test/Sema/PR28181.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct spinlock_t {
+  int lock;
+} audit_skb_queue;
+
+void fn1() {
+  audit_skb_queue = (lock); // expected-error {{use of undeclared identifier 
'lock'; did you mean 'long'?}}
+}   // expected-error@-1 {{assigning to 'struct 
spinlock_t' from incompatible type ''}}
+
+void fn2() {
+  audit_skb_queue + (lock); // expected-error {{use of undeclared identifier 
'lock'; did you mean 'long'?}}
+}   // expected-error@-1 {{reference to overloaded 
function could not be resolved; did you mean to call it?}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -11391,7 +11391,7 @@
   return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
 
 // Don't resolve overloads if the other type is overloadable.
-if (pty->getKind() == BuiltinType::Overload) {
+if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload) {
   // We can't actually test that if we still have a placeholder,
   // though.  Fortunately, none of the exceptions we see in that
   // code below are valid when the LHS is an overload set.  Note
@@ -11416,17 +11416,18 @@
 // An overload in the RHS can potentially be resolved by the type
 // being assigned to.
 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
-  if (LHSExpr->isTypeDependent() || RHSExpr->isTypeDependent())
+  if (getLangOpts().CPlusPlus &&
+  (LHSExpr->isTypeDependent() || RHSExpr->isTypeDependent()))
 return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr, RHSExpr);
 
-  if (LHSExpr->getType()->isOverloadableType())
+  if (getLangOpts().CPlusPlus && LHSExpr->getType()->isOverloadableType())
 return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr, RHSExpr);
 
   return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
 }
 
 // Don't resolve overloads if the other type is overloadable.
-if (pty->getKind() == BuiltinType::Overload &&
+if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload &&
 LHSExpr->getType()->isOverloadableType())
   return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr, RHSExpr);
 


Index: test/Sema/PR28181.c
===
--- /dev/null
+++ test/Sema/PR28181.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct spinlock_t {
+  int lock;
+} audit_skb_queue;
+
+void fn1() {
+  audit_skb_queue = (lock); // expected-error {{use of undeclared identifier 'lock'; did you mean 'long'?}}
+}   // expected-error@-1 {{assigning to 'struct spinlock_t' from incompatible type ''}}
+
+void fn2() {
+  audit_skb_queue + (lock); // expected-error {{use of undeclared identifier 'lock'; did you mean 'long'?}}
+}   // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -11391,7 +11391,7 @@
   return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
 
 // Don't resolve overloads if the other type is overloadable.
-if (pty->getKind() == BuiltinType::Overload) {
+if (getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload) {
   // We can't actually test that if we still have a placeholder,
   // though.  Fortunately, none of the exceptions we see in that
   // code below are valid when the LHS is an overload set.  Note
@@ -11416,17 +11416,18 @@
 // An overload in the RHS can potentially be resolved by the type
 // being assigned to.
 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
-  if (LHSExpr->isTypeDependent() || RHS

[PATCH] D22272: ARM: define __ARM_VFPV5__ when present.

2016-10-04 Thread Renato Golin via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

Hi Tim,

This patch seems stale. I think neither me nor Richard have any strong feelings 
against this, so I'll just approve and let you decide on which solution is 
best. I have a mild preference for both.

cheers,
--renato


https://reviews.llvm.org/D22272



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


[PATCH] D25065: [change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.

2016-10-04 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM.



> ioeric wrote in ChangeNamespace.cpp:187
> Note that `str()` is called on `(NsName + "::")` instead of `consume_front`. 
> But you are right, we can put the check into the while loop.

Oh, I see. Sorry for misreading the code.

https://reviews.llvm.org/D25065



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


[PATCH] D24083: [CMake] Fix libc++abi __aeabi_idiv() link error.

2016-10-04 Thread Renato Golin via cfe-commits
rengolin added a comment.

In https://reviews.llvm.org/D24083#534464, @EricWF wrote:

> In https://reviews.llvm.org/D24083#534459, @logan wrote:
>
> > One solution might be adding the `libclang_rt.builtins.${arch}.a` detection 
> > rules[1] to CMakeLists.txt, and manually specify 
> > `-lclang_rt.builtins-${arch}.a` when `LIBCXXABI_USE_COMPILER_RT` is 
> > enabled.  How do you think about this solution?
>
>
> That SGTM. There's a similar workaround in libc++ to link the sanitizer 
> run-times on OS X (found here 
> ).


+1


https://reviews.llvm.org/D24083



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


[PATCH] D24084: [CMake] Cleanup libunwind lookup code.

2016-10-04 Thread Renato Golin via cfe-commits
rengolin added a comment.

@EricWF any comments?


https://reviews.llvm.org/D24084



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


[PATCH] D24998: Add a new optimization option -Og

2016-10-04 Thread Renato Golin via cfe-commits
rengolin added reviewers: echristo, dberlin, keith.walker.arm.
rengolin added a comment.

Hi Sylvestre,

Paul's comments on the bug are still pertinent: `-Og` is not the same as `-O1`.

`-Og` means for "optimised for debuggers" which is short for "preserve the 
debug illusion without bloating the code". This is not at all what `-O1` is, 
even though they're used indistinguishably via `-O1 -g`.

As a stop-gap, I guess having `-Og == -O1` would stop errors from being 
reported, but if we could do a quick assessment on the list to make sure this 
has the expected semantics (and adding a full new option if not), would be the 
best way forward.

I'm adding a few debug folks here, in hope they have a better idea (and would 
add more folks, if necessary). :)

cheers,
--renato


https://reviews.llvm.org/D24998



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


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-04 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 73466.
rogfer01 added a comment.

Change algorithm following @rsmith suggestions by computing the offset of the 
whole access and compare it against the expected alignment, so reduced aligned 
structs inside overaligned structs does not yield a warning.

Also ignore parentheses where necessary, which was effectively preventing 
silencing some false positives.

Includes testcases suggested by @rsmith and @joerg.


https://reviews.llvm.org/D23657

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c

Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -26,6 +26,7 @@
 struct Arguable *get_arguable();
 
 void to_void(void *);
+void to_intptr(intptr_t);
 
 void g0(void) {
   {
@@ -41,43 +42,48 @@
 
 f1((int *)(void *)&arguable.x); // no-warning
 to_void(&arguable.x);   // no-warning
-void *p = &arguable.x;  // no-warning;
+void *p = &arguable.x;  // no-warning
 to_void(p);
+to_intptr((intptr_t)p); // no-warning
   }
   {
 union UnionArguable arguable;
 f2(&arguable.c); // no-warning
 f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 ArguableT arguable;
 f2(&arguable.c0); // no-warning
 f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable.c1); // no-warning
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 struct Arguable *arguable = get_arguable();
 f2(&arguable->c0); // no-warning
 f1(&arguable->x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable->c1); // no-warning
 
-f1((int *)(void *)&arguable->x); // no-warning
-to_void(&arguable->c1);  // no-warning
+f1((int *)(void *)&arguable->x);// no-warning
+to_void(&arguable->c1); // no-warning
+to_intptr((intptr_t)&arguable->c1); // no-warning
   }
   {
 ArguableT *arguable = get_arguable();
 f2(&(arguable->c0)); // no-warning
 f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&(arguable->c1)); // no-warning
 
-f1((int *)(void *)&(arguable->x)); // no-warning
-to_void(&(arguable->c1));  // no-warning
+f1((int *)(void *)&(arguable->x));  // no-warning
+to_void(&(arguable->c1));   // no-warning
+to_intptr((intptr_t)&(arguable->c1));   // no-warning
   }
 }
 
@@ -161,3 +167,65 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+struct S6 {
+int a;
+int _;
+int c;
+char __;
+int d;
+} __attribute__((packed, aligned(16))) s6;
+
+void foo()
+{ 
+f1(&s6.a); // no-warning
+f1(&s6.c); // no-warning
+f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6'}}
+}
+
+struct __attribute__((packed, aligned(1))) MisalignedContainee { double d; };
+struct __attribute__((aligned(8))) AlignedContainer { struct MisalignedContainee b; };
+
+struct AlignedContainer *p;
+double* bar() {
+  return &p->b.d; // no-warning
+}
+
+union OneUnion
+{
+uint32_t a;
+uint32_t b:1;
+};
+
+struct __attribute__((packed)) S7 {
+uint8_t length;
+uint8_t stuff;
+uint8_t padding[2];
+union OneUnion one_union;
+};
+
+union AnotherUnion {
+long data;
+struct S7 s;
+} *au;
+
+union OneUnion* get_OneUnion(void)
+{
+return &au->s.one_union; // no-warning
+}
+
+struct __attribute__((packed)) S8 {
+uint8_t data1;
+uint8_t data2;
+	uint16_t wider_data;
+};
+
+#define LE_READ_2(p)	\
+	((uint16_t)	\
+	 const uint8_t *)(p))[0]  ) |		\
+	  (((const uint8_t *)(p))[1] <<  8)))
+
+uint32_t get_wider_data(struct S8 *s)
+{
+return LE_READ_2(&s->wider_data); // no-warning
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11286,45 +11286,103 @@
 }
 
 void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
-  if (!T->isPointerType())
+  E = E->IgnoreParens();
+  if (!T->isPointerType() && !T->isIntegerType())
 return;
   if (isa(E) &&
   cast(E)->getOpcode() == UO_AddrOf) {
 auto *Op = cast(E)->getSubExpr()->IgnoreParens();
 if (isa(Op)) {
   auto MA = std::find(MisalignedMembers.

[PATCH] D25106: Packed member warning: Use the typedef name for anonymous structures when it is available

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

LGTM, thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D25106



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


r283217 - [ThinLTO] Spell `llvm-ar` correctly.

2016-10-04 Thread Davide Italiano via cfe-commits
Author: davide
Date: Tue Oct  4 08:16:00 2016
New Revision: 283217

URL: http://llvm.org/viewvc/llvm-project?rev=283217&view=rev
Log:
[ThinLTO] Spell `llvm-ar` correctly.

Modified:
cfe/trunk/docs/ThinLTO.rst

Modified: cfe/trunk/docs/ThinLTO.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThinLTO.rst?rev=283217&r1=283216&r2=283217&view=diff
==
--- cfe/trunk/docs/ThinLTO.rst (original)
+++ cfe/trunk/docs/ThinLTO.rst Tue Oct  4 08:16:00 2016
@@ -140,7 +140,7 @@ To bootstrap clang/LLVM with ThinLTO, fo
   * ``-DCMAKE_C_COMPILER=/path/to/host/clang``
   * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang++``
   * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib``
-  * ``-DCMAKE_AR=/path/to/host/llvm-nm``
+  * ``-DCMAKE_AR=/path/to/host/llvm-ar``
 
 #. To use additional linker arguments for controlling the backend
parallelism_ or enabling incremental_ builds of the bootstrap compiler,


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


[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-04 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl added inline comments.


> aaron.ballman wrote in DiagnosticGroups.td:522
> I would not add this as a diagnostic group, but instead use an ad-hoc group 
> on the diagnostic itself. I don't think this is going to see very many 
> diagnostics covered by the same group, but if that turns out to be the case, 
> we can switch then.

Ok, done

> aaron.ballman wrote in DiagnosticSemaKinds.td:2306
> I'm not the best one to answer that question, but we typically avoid adding 
> new off-by-default diagnostics. Since GCC prints this as an error message and 
> this patch is for GCC compatibility, it seems weird to me to add this as an 
> off-by-default warning.

I did similar to GCC - error by default.

https://reviews.llvm.org/D24669



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


[PATCH] D24965: [clang-tidy] Fix cppcoreguidelines-pro-type-member-init false negatives

2016-10-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Generally looks good to me, sorry I missed these tiny nits last time around.



> ProTypeMemberInitCheck.h:49
>void checkMissingMemberInitializer(ASTContext &Context,
> + const CXXRecordDecl *ClassDecl,
>   const CXXConstructorDecl *Ctor);

Since this is not allowed to be a null pointer, would it make more sense to use 
a reference instead (same below)?

> cppcoreguidelines-pro-type-member-init.cpp:409
> +
> +template struct NegativeTemplateVirtualDestructor;
> +

Sorry, I missed one bit to my test (my fault), can you also add `int F;` to 
ensure that it still triggers the diagnostic?

https://reviews.llvm.org/D24965



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


[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-04 Thread Vladimir Yakovlev via cfe-commits
vbyakovlcl removed rL LLVM as the repository for this revision.
vbyakovlcl updated this revision to Diff 73468.

https://reviews.llvm.org/D24669

Files:
  llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
  llvm/tools/clang/lib/Sema/SemaExpr.cpp
  llvm/tools/clang/test/Sema/vecshift.c

Index: llvm/tools/clang/lib/Sema/SemaExpr.cpp
===
--- llvm/tools/clang/lib/Sema/SemaExpr.cpp
+++ llvm/tools/clang/lib/Sema/SemaExpr.cpp
@@ -8784,6 +8784,65 @@
 << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
   return QualType();
 }
+if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
+  const BuiltinType *LHSBT = LHSEleType->getAs();
+  const BuiltinType *RHSBT = RHSEleType->getAs();
+  if (LHSBT != RHSBT) {
+BuiltinType::Kind LHSKind = LHSBT->getKind();
+BuiltinType::Kind RHSKind = RHSBT->getKind();
+bool DiffSizes = true;
+switch (LHSKind) {
+case BuiltinType::Char_S:
+  DiffSizes =
+  RHSKind != BuiltinType::Char_U && RHSKind != BuiltinType::UChar;
+  break;
+case BuiltinType::Char_U:
+  DiffSizes =
+  RHSKind != BuiltinType::Char_S && RHSKind != BuiltinType::UChar;
+  break;
+case BuiltinType::UChar:
+  DiffSizes =
+  RHSKind != BuiltinType::Char_U && RHSKind != BuiltinType::Char_S;
+  break;
+case BuiltinType::Short:
+  DiffSizes = RHSKind != BuiltinType::UShort;
+  break;
+case BuiltinType::UShort:
+  DiffSizes = RHSKind != BuiltinType::Short;
+  break;
+case BuiltinType::Int:
+  DiffSizes = RHSKind != BuiltinType::UInt;
+  break;
+case BuiltinType::UInt:
+  DiffSizes = RHSKind != BuiltinType::Int;
+  break;
+case BuiltinType::Long:
+  DiffSizes = RHSKind != BuiltinType::ULong;
+  break;
+case BuiltinType::ULong:
+  DiffSizes = RHSKind != BuiltinType::Long;
+  break;
+case BuiltinType::LongLong:
+  DiffSizes = RHSKind != BuiltinType::ULongLong;
+  break;
+case BuiltinType::ULongLong:
+  DiffSizes = RHSKind != BuiltinType::LongLong;
+  break;
+default:
+  DiffSizes = true;
+  break;
+}
+if (DiffSizes) {
+  S.Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
+  << LHS.get()->getType() << RHS.get()->getType()
+  << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+  if (S.Diags.getDiagnosticLevel(
+  diag::warn_typecheck_vector_element_sizes_not_equal, Loc) ==
+  DiagnosticsEngine::Level::Error)
+return QualType();
+}
+  }
+}
   } else {
 // ...else expand RHS to match the number of elements in LHS.
 QualType VecTy =
Index: llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2301,6 +2301,9 @@
   "cannot convert between vector and non-scalar values (%0 and %1)">;
 def err_typecheck_vector_lengths_not_equal : Error<
   "vector operands do not have the same number of elements (%0 and %1)">;
+def warn_typecheck_vector_element_sizes_not_equal : Warning<
+  "vector operands do not have the same elements sizes (%0 and %1)">,
+  InGroup>, DefaultError;
 def err_ext_vector_component_exceeds_length : Error<
   "vector component access exceeds type %0">;
 def err_ext_vector_component_name_illegal : Error<
Index: llvm/tools/clang/test/Sema/vecshift.c
===
--- llvm/tools/clang/test/Sema/vecshift.c
+++ llvm/tools/clang/test/Sema/vecshift.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DERR -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-error-gnu-vec-elem-size -verify %s
 
 typedef __attribute__((__ext_vector_type__(8))) char vector_char8;
 typedef __attribute__((__ext_vector_type__(8))) short vector_short8;
@@ -48,16 +49,30 @@
   vus8 = 1 << vus8;
 
   vc8 = vc8 << vc8;
-  vi8 = vi8 << vuc8;
-  vuc8 = vuc8 << vi8;
-  vus8 = vus8 << vui8;
-  vui8 = vui8 << vs8;
+#ifdef ERR
+  vi8 = vi8 << vuc8; // expected-error {{vector operands do not have the same elements sizes}}
+  vuc8 = vuc8 << vi8; // expected-error {{vector operands do not have the same elements sizes}}
+  vus8 = vus8 << vui8; // expected-error {{vector operands do not have the same elements sizes}}
+  vui8 = vui8 << vs8; // expected-error {{vector operands do not have the same elements sizes}}
+#else
+  vi8 = vi8 << vuc8; // expected-warning {{vector operands do not have the same elements sizes}}
+  vuc8 = vuc8 << vi8; // expected-warning {{vector oper

[PATCH] D25092: [analyzer] Add "Assuming..." diagnostic pieces for short-circuit logical operators.

2016-10-04 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 73472.
NoQ marked 3 inline comments as done.
NoQ added a comment.

Fix review comments.

Correct the order of expected-notes in one of the tests (it doesn't affect how 
the test works).


https://reviews.llvm.org/D25092

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  test/Analysis/conditional-path-notes.c
  test/Analysis/edges-new.mm

Index: test/Analysis/edges-new.mm
===
--- test/Analysis/edges-new.mm
+++ test/Analysis/edges-new.mm
@@ -7655,53 +7655,19 @@
 // CHECK-NEXT:   
 // CHECK-NEXT: 
 // CHECK-NEXT: 
-// CHECK-NEXT:  kindcontrol
-// CHECK-NEXT:  edges
-// CHECK-NEXT:   
-// CHECK-NEXT:
-// CHECK-NEXT: start
-// CHECK-NEXT:  
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col19
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col22
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:  
-// CHECK-NEXT: end
-// CHECK-NEXT:  
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col7
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col7
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:  
-// CHECK-NEXT:
-// CHECK-NEXT:   
-// CHECK-NEXT: 
-// CHECK-NEXT: 
 // CHECK-NEXT:  kindevent
 // CHECK-NEXT:  location
 // CHECK-NEXT:  
 // CHECK-NEXT:   line263
-// CHECK-NEXT:   col7
+// CHECK-NEXT:   col19
 // CHECK-NEXT:   file0
 // CHECK-NEXT:  
 // CHECK-NEXT:  ranges
 // CHECK-NEXT:  
 // CHECK-NEXT:
 // CHECK-NEXT: 
 // CHECK-NEXT:  line263
-// CHECK-NEXT:  col7
+// CHECK-NEXT:  col19
 // CHECK-NEXT:  file0
 // CHECK-NEXT: 
 // CHECK-NEXT: 
@@ -7713,9 +7679,9 @@
 // CHECK-NEXT:  
 // CHECK-NEXT:  depth0
 // CHECK-NEXT:  extended_message
-// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT:  Assuming 'coin' is not equal to 0
 // CHECK-NEXT:  message
-// CHECK-NEXT:  Assuming the condition is true
+// CHECK-NEXT:  Assuming 'coin' is not equal to 0
 // CHECK-NEXT: 
 // CHECK-NEXT: 
 // CHECK-NEXT:  kindcontrol
@@ -7726,12 +7692,12 @@
 // CHECK-NEXT:  
 // CHECK-NEXT:   
 // CHECK-NEXT:line263
-// CHECK-NEXT:col7
+// CHECK-NEXT:col19
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:   
 // CHECK-NEXT:line263
-// CHECK-NEXT:col7
+// CHECK-NEXT:col22
 // CHECK-NEXT:file0
 // CHECK-NEXT:   
 // CHECK-NEXT:  
@@ -8000,53 +7966,19 @@
 // CHECK-NEXT:   
 // CHECK-NEXT: 
 // CHECK-NEXT: 
-// CHECK-NEXT:  kindcontrol
-// CHECK-NEXT:  edges
-// CHECK-NEXT:   
-// CHECK-NEXT:
-// CHECK-NEXT: start
-// CHECK-NEXT:  
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col19
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col22
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:  
-// CHECK-NEXT: end
-// CHECK-NEXT:  
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col7
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:   
-// CHECK-NEXT:line263
-// CHECK-NEXT:col7
-// CHECK-NEXT:file0
-// CHECK-NEXT:   
-// CHECK-NEXT:  
-// CHECK-NEXT:
-// CHECK-NEXT:   
-// CHECK-NEXT: 
-// CHECK-NEXT: 
 // CHECK-NEXT:  kindevent
 // CHECK-NEXT:  location
 // CHECK-NEXT:  
 // CHECK-NEXT:   line263
-// CHECK-NEXT:   col7
+// CHECK-NEXT:   col19
 // CHECK-NEXT:   file0
 // CHECK-NEXT:  
 // CHECK-NEXT:  ranges
 // CHECK-NEXT:  
 // CHECK-NEXT:
 // CHECK-NEXT: 
 // CHECK-NEXT:  line263
-// CHECK-NEXT:  col7
+// CHECK-NEXT:  col19
 // CHECK-NEXT:  file0
 // CHECK-NEXT: 
 // CHECK-NEXT: 
@@ -8058,9 +7990,9 @@
 // CHECK-NEXT:  
 // CHECK-NEXT:  depth0
 // CHECK-NEXT:  extended_message
-// CHECK-NEXT:  Assuming the condition is false
+// CHECK-NEXT:  Assuming 'coin' is 0
 // CHECK-NEXT:  message
-// CHECK-NEXT:  Assuming the condition is false
+// CHECK-NEXT:  Assuming 'coin' is 0
 // CHECK-NEXT: 
 // CHECK-NEXT: 
 // CHECK-NEXT:  kindcontrol
@@ -8071,12 +8003,12 @@
 // CHECK-NEXT:  
 // CH

[libcxx] r283218 - Mark #2739 as ready

2016-10-04 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Oct  4 08:41:56 2016
New Revision: 283218

URL: http://llvm.org/viewvc/llvm-project?rev=283218&view=rev
Log:
Mark #2739 as ready

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=283218&r1=283217&r2=283218&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Tue Oct  4 08:41:56 2016
@@ -109,7 +109,7 @@
 http://wg21.link/LWG2735";>2735std::abs(short), 
std::abs(signed char) and others should return int instead of double in order 
to be compatible with C++98 and CIssaquah
 http://wg21.link/LWG2736";>2736nullopt_t 
insufficiently constrainedIssaquah
 http://wg21.link/LWG2738";>2738is_constructible with void 
typesIssaquahWe already do this
-http://wg21.link/LWG2739";>2739Issue with 
time_point non-member subtraction with an unsigned 
durationIssaquah
+http://wg21.link/LWG2739";>2739Issue with 
time_point non-member subtraction with an unsigned 
durationIssaquahPatch Ready
 http://wg21.link/LWG2740";>2740constexpr 
optional::operator->Issaquah
 http://wg21.link/LWG2742";>2742Inconsistent string interface 
taking string_viewIssaquahPatch Ready
 http://wg21.link/LWG2744";>2744any's 
in_place constructorsIssaquah
@@ -183,7 +183,7 @@
 2735 - 
 2736 - 
 2738 - We already do this; I added tests for cv-void
-2739 - 
+2739 - Patch and tests ready
 2740 - 
 2742 - Patch and tests ready
 2744 - 
@@ -205,7 +205,7 @@
 2769 - 
 
 
-Last Updated: 3-Oct-2016
+Last Updated: 4-Oct-2016
 
 
 


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


[PATCH] D25092: [analyzer] Add "Assuming..." diagnostic pieces for short-circuit logical operators.

2016-10-04 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


> zaks.anna wrote in BugReporterVisitors.cpp:1302
> Is this expected to ever trigger?

Ouch right.

https://reviews.llvm.org/D25092



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


[PATCH] D24339: [clang-tidy] Add check 'readability-redundant-member-init'

2016-10-04 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


> readability-redundant-member-init.cpp:162
> +  const S f;
> +};

Missing a test for `union` member initializers. Also, a test that multiple 
inheritance doesn't cause a fixit malfunction would be nice.

https://reviews.llvm.org/D24339



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


[PATCH] D24965: [clang-tidy] Fix cppcoreguidelines-pro-type-member-init false negatives

2016-10-04 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 73474.
malcolm.parsons added a comment.

Pass records by reference.
Change test to trigger diagnostic for non-template type


https://reviews.llvm.org/D24965

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  clang-tidy/utils/TypeTraits.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -377,3 +377,49 @@
 {
   NegativeInClassInitializedDefaulted s;
 }
+
+struct PositiveVirtualMethod {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these fields: F
+  int F;
+  // CHECK-FIXES: int F{};
+  virtual int f() = 0;
+};
+
+struct PositiveVirtualDestructor {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these fields: F
+  PositiveVirtualDestructor() = default;
+  int F;
+  // CHECK-FIXES: int F{};
+  virtual ~PositiveVirtualDestructor() {}
+};
+
+struct PositiveVirtualBase : public virtual NegativeAggregateType {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these bases: NegativeAggregateType
+  // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: constructor does not initialize these fields: F
+  int F;
+  // CHECK-FIXES: int F{};
+};
+
+template 
+struct PositiveTemplateVirtualDestructor {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these fields: F
+  T Val;
+  int F;
+  // CHECK-FIXES: int F{};
+  virtual ~PositiveTemplateVirtualDestructor() = default;
+};
+
+template struct PositiveTemplateVirtualDestructor;
+
+#define UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(FIELD) \
+  struct UninitializedFieldVirtual##FIELD {  \
+int FIELD;   \
+virtual ~UninitializedFieldVirtual##FIELD() {}   \
+  }; \
+// Ensure FIELD is not initialized since fixes inside of macros are disabled.
+// CHECK-FIXES: int FIELD;
+
+UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(F);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: F
+UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(G);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: G
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -58,6 +58,9 @@
   // constructible.
   if (ClassDecl->hasUserProvidedDefaultConstructor())
 return false;
+  // A polymorphic class is not trivially constructible
+  if (ClassDecl->isPolymorphic())
+return false;
   // A class is trivially constructible if it has a trivial default constructor.
   if (ClassDecl->hasTrivialDefaultConstructor())
 return true;
@@ -73,6 +76,8 @@
   for (const CXXBaseSpecifier &Base : ClassDecl->bases()) {
 if (!isTriviallyDefaultConstructible(Base.getType(), Context))
   return false;
+if (Base.isVirtual())
+  return false;
   }
 
   return true;
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
@@ -46,11 +46,13 @@
   // To fix: Write a data member initializer, or mention it in the member
   // initializer list.
   void checkMissingMemberInitializer(ASTContext &Context,
+ const CXXRecordDecl &ClassDecl,
  const CXXConstructorDecl *Ctor);
 
   // A subtle side effect of Type.6 part 2:
   // Make sure to initialize trivially constructible base classes.
   void checkMissingBaseClassInitializer(const ASTContext &Context,
+const CXXRecordDecl &ClassDecl,
 const CXXConstructorDecl *Ctor);
 
   // Checks Type.6 part 2:
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -32,17 +32,17 @@
 // the record type (or indirect field) is a union, forEachField will stop after
 // the first field.
 template 
-void forEachField(const RecordDecl *Record, const T &Fields,
+void forEachField(const RecordDecl &Record, const T &Fields,
   bool OneFieldPerUnion, Func &&Fn) {
   for (const FieldDecl *F : Fields) {
 if (F->isAnonymousStructOrUnion()) {
   if (const CXXRecordDecl *R = F->getType()->getAsCXXRecordDecl())
-forEachField(R, R->fie

[PATCH] D24965: [clang-tidy] Fix cppcoreguidelines-pro-type-member-init false negatives

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

LGTM, thank you!


https://reviews.llvm.org/D24965



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


[PATCH] D24965: [clang-tidy] Fix cppcoreguidelines-pro-type-member-init false negatives

2016-10-04 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D24965#560785, @aaron.ballman wrote:

> LGTM, thank you!


I don't have commit access, so please commit this for me.
Thanks.


https://reviews.llvm.org/D24965



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


[libcxx] r283220 - Mark #2598 as ready

2016-10-04 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Oct  4 09:08:50 2016
New Revision: 283220

URL: http://llvm.org/viewvc/llvm-project?rev=283220&view=rev
Log:
Mark #2598 as ready

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=283220&r1=283219&r2=283220&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Tue Oct  4 09:08:50 2016
@@ -88,7 +88,7 @@
 http://wg21.link/LWG2584";>2584 
ECMAScript IdentityEscape is ambiguousIssaquah
 http://wg21.link/LWG2589";>2589match_results can't satisfy 
the requirements of a containerIssaquah
 http://wg21.link/LWG2591";>2591std::function's member 
template target() should not lead to undefined 
behaviourIssaquah
-http://wg21.link/LWG2598";>2598addressof 
works on temporariesIssaquah
+http://wg21.link/LWG2598";>2598addressof 
works on temporariesIssaquahPatch ready
 http://wg21.link/LWG2664";>2664operator/ 
(and other append) semantics not useful if argument has 
rootIssaquah
 http://wg21.link/LWG2665";>2665remove_filename() post 
condition is incorrectIssaquah
 http://wg21.link/LWG2672";>2672Should 
is_empty use error_code in its 
specification?Issaquah
@@ -162,7 +162,7 @@
 2584 - 
 2589 - 
 2591 - 
-2598 - 
+2598 - Patch and tests ready
 2664 - 
 2665 - 
 2672 - 


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


[PATCH] D24339: [clang-tidy] Add check 'readability-redundant-member-init'

2016-10-04 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.


> aaron.ballman wrote in readability-redundant-member-init.cpp:162
> Missing a test for `union` member initializers. Also, a test that multiple 
> inheritance doesn't cause a fixit malfunction would be nice.

Note that all the fixits malfunction until https://reviews.llvm.org/D24572 
lands.

https://reviews.llvm.org/D24339



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


[PATCH] D24339: [clang-tidy] Add check 'readability-redundant-member-init'

2016-10-04 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 73479.
malcolm.parsons added a comment.

Add test for initializing a union member.
Add test for multiple inheritance.


https://reviews.llvm.org/D24339

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantMemberInitCheck.cpp
  clang-tidy/readability/RedundantMemberInitCheck.h
  clang-tidy/utils/TypeTraits.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-member-init.rst
  test/clang-tidy/readability-redundant-member-init.cpp

Index: test/clang-tidy/readability-redundant-member-init.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-member-init.cpp
@@ -0,0 +1,181 @@
+// RUN: %check_clang_tidy %s readability-redundant-member-init %t
+
+struct S {
+  S() = default;
+  S(int i) : i(i) {}
+  int i = 1;
+};
+
+struct T {
+  T(int i = 1) : i(i) {}
+  int i;
+};
+
+struct U {
+  int i;
+};
+
+union V {
+  int i;
+  double f;
+};
+
+// Initializer calls default constructor
+struct F1 {
+  F1() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant
+  // CHECK-FIXES: F1() {}
+  S f;
+};
+
+// Initializer calls default constructor with default argument
+struct F2 {
+  F2() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant
+  // CHECK-FIXES: F2() {}
+  T f;
+};
+
+// Multiple redundant initializers for same constructor
+struct F3 {
+  F3() : f(), g(1), h() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant
+  // CHECK-MESSAGES: :[[@LINE-2]]:21: warning: initializer for member 'h' is redundant
+  // CHECK-FIXES: F3() : g(1) {}
+  S f, g, h;
+};
+
+// Templated class independent type
+template 
+struct F4 {
+  F4() : f() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'f' is redundant
+  // CHECK-FIXES: F4() {}
+  S f;
+};
+F4 f4i;
+F4 f4s;
+
+// Base class
+struct F5 : S {
+  F5() : S() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for base class 'S' is redundant
+  // CHECK-FIXES: F5() {}
+};
+
+// Constructor call requires cleanup
+struct Cleanup {
+  ~Cleanup() {}
+};
+
+struct UsesCleanup {
+  UsesCleanup(const Cleanup &c = Cleanup()) {}
+};
+
+struct F6 {
+  F6() : uc() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for member 'uc' is redundant
+  // CHECK-FIXES: F6() {}
+  UsesCleanup uc;
+};
+
+// Multiple inheritance
+struct F7 : S, T {
+  F7() : S(), T() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: initializer for base class 'S' is redundant
+  // CHECK-MESSAGES: :[[@LINE-2]]:15: warning: initializer for base class 'T' is redundant
+  // CHECK-FIXES: F7() {}
+};
+
+// Initializer not written
+struct NF1 {
+  NF1() {}
+  S f;
+};
+
+// Initializer doesn't call default constructor
+struct NF2 {
+  NF2() : f(1) {}
+  S f;
+};
+
+// Initializer calls default constructor without using default argument
+struct NF3 {
+  NF3() : f(1) {}
+  T f;
+};
+
+// Initializer calls default constructor without using default argument
+struct NF4 {
+  NF4() : f(2) {}
+  T f;
+};
+
+// Initializer is zero-initialization
+struct NF5 {
+  NF5() : i() {}
+  int i;
+};
+
+// Initializer is direct-initialization
+struct NF6 {
+  NF6() : i(1) {}
+  int i;
+};
+
+// Initializer is aggregate initialization of struct
+struct NF7 {
+  NF7() : f{} {}
+  U f;
+};
+
+// Initializer is zero-initialization of struct
+struct NF7b {
+  NF7b() : f() {}
+  U f;
+};
+
+// Initializer is aggregate initialization of array
+struct NF8 {
+  NF8() : f{} {}
+  int f[2];
+};
+
+struct NF9 {
+  NF9() : f{} {}
+  S f[2];
+};
+
+// Initializing member of union
+union NF10 {
+  NF10() : s() {}
+  int i;
+  S s;
+};
+
+// Templated class dependent type
+template 
+struct NF11 {
+  NF11() : f() {}
+  V f;
+};
+NF11 nf11i;
+NF11 nf11s;
+
+// Delegating constructor
+class NF12 {
+  NF12() = default;
+  NF12(int) : NF12() {}
+};
+
+// Const member
+struct NF13 {
+  NF13() : f() {}
+  const S f;
+};
+
+// Union member
+struct NF14 {
+  NF14() : f() {}
+  V f;
+};
Index: docs/clang-tidy/checks/readability-redundant-member-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-member-init.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - readability-redundant-member-init
+
+readability-redundant-member-init
+=
+
+Finds member initializations that are unnecessary because the same default
+constructor would be called if they were not present.
+
+Example:
+
+.. code-block:: c++
+
+  // Explicitly initializing the member s is unnecessary.
+  class Foo {
+  public:
+Foo() : s() {}
+
+  private:
+std::string s;
+  };
Index: docs/clang-tidy/checks/list.rst
===

[libcxx] r283222 - Mark #2759 as ready and #2755 as complete

2016-10-04 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Oct  4 09:39:58 2016
New Revision: 283222

URL: http://llvm.org/viewvc/llvm-project?rev=283222&view=rev
Log:
Mark #2759 as ready and #2755 as complete

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=283222&r1=283221&r2=283222&view=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Tue Oct  4 09:39:58 2016
@@ -121,9 +121,9 @@
 http://wg21.link/LWG2752";>2752"Throws:" 
clauses of async and packaged_task are 
unimplementableIssaquah
 http://wg21.link/LWG2753";>2753Optional's 
constructors and assignments need 
constraintsIssaquah
 http://wg21.link/LWG2754";>2754The 
in_place constructors and emplace functions added by P0032R3 don't require 
CopyConstructibleIssaquah
-http://wg21.link/LWG2755";>2755§[string.view.io] uses 
non-existent basic_string_view::to_string 
functionIssaquah
+http://wg21.link/LWG2755";>2755§[string.view.io] uses 
non-existent basic_string_view::to_string functionIssaquahWe 
already do this
 http://wg21.link/LWG2756";>2756C++ WP 
optional should 'forward' T's implicit 
conversionsIssaquah
-http://wg21.link/LWG2759";>2759gcd / lcm 
and bool for the WPIssaquah
+http://wg21.link/LWG2759";>2759gcd / lcm 
and bool for the WPIssaquahPatch ready
 http://wg21.link/LWG2760";>2760non-const 
basic_string::data should not invalidate 
iteratorsIssaquahNothing to do
 http://wg21.link/LWG2765";>2765Did LWG 
1123 go too far?Issaquah
 http://wg21.link/LWG2767";>2767not_fn 
call_wrapper can form invalid typesIssaquah
@@ -174,7 +174,7 @@
 2686 - 
 2694 - 
 2696 - 
-2699 - 
+2699 - I don't think this requires any code changes; look more 
closely.
 2712 - 
 2722 - 
 2729 - 
@@ -195,9 +195,9 @@
 2752 - 
 2753 - 
 2754 - 
-2755 - 
+2755 - Both string and string_view call a common routine for output; so no 
code changes needed.
 2756 - 
-2759 - 
+2759 - Patch and tests ready
 2760 - This is just wording cleanup; no code or test changes needed.
 2765 - 
 2767 - 


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


r283223 - [OpenMP] fix segfault when a variable referenced in reduction clause is a reference parameter\nDifferential Revision: http://reviews.llvm.org/D24524

2016-10-04 Thread David Sheinkman via cfe-commits
Author: davidsh
Date: Tue Oct  4 09:41:36 2016
New Revision: 283223

URL: http://llvm.org/viewvc/llvm-project?rev=283223&view=rev
Log:
[OpenMP] fix segfault when a variable referenced in reduction clause is a 
reference parameter\nDifferential Revision: http://reviews.llvm.org/D24524

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/for_reduction_messages.cpp
cfe/trunk/test/OpenMP/for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_reduction_messages.cpp
cfe/trunk/test/OpenMP/sections_reduction_messages.cpp
cfe/trunk/test/OpenMP/simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp
cfe/trunk/test/OpenMP/target_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_reduction_messages.cpp
cfe/trunk/test/OpenMP/teams_reduction_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=283223&r1=283222&r2=283223&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Oct  4 09:41:36 2016
@@ -9401,7 +9401,7 @@ OMPClause *Sema::ActOnOpenMPReductionCla
 //  for all threads of the team.
 if (!ASE && !OASE && VD) {
   VarDecl *VDDef = VD->getDefinition();
-  if (VD->getType()->isReferenceType() && VDDef) {
+  if (VD->getType()->isReferenceType() && VDDef && VDDef->hasInit()) {
 DSARefChecker Check(DSAStack);
 if (Check.Visit(VDDef->getInit())) {
   Diag(ELoc, diag::err_omp_reduction_ref_type_arg) << ERange;

Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==
--- cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp 
(original)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp Tue 
Oct  4 09:41:36 2016
@@ -9,6 +9,14 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward 
declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: 
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==
--- cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp 
(original)
+++ cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp 
Tue Oct  4 09:41:36 2016
@@ -9,6 +9,14 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for simd reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward 
declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff
==
--- cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp Tue Oct  4 
09:41:36 2016
@@ -9,6 +9,14 @@ bool foobool(int argc) {
   return argc;
 }
 
+void foobar(int &ref) {
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute simd reduction(+:ref)
+  for (int i = 0; i < 10; ++i)
+foo();
+}
+
 struct S1; // expected-note {{declared here}} expected-note 4 {{forward 
declaration of 'S1'}}
 extern S1 a;
 class S2 {

Modified: cfe/trunk/test/OpenMP/for_reduction_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_messages.cpp?rev=283223&r1=283222&r2=283223&view=diff

[clang-tools-extra] r283224 - Fix some false-positives with cppcoreguidelines-pro-type-member-init. Handle classes with default constructors that are defaulted or are not present in the AST.

2016-10-04 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Oct  4 09:48:05 2016
New Revision: 283224

URL: http://llvm.org/viewvc/llvm-project?rev=283224&view=rev
Log:
Fix some false-positives with cppcoreguidelines-pro-type-member-init. Handle 
classes with default constructors that are defaulted or are not present in the 
AST.
Classes with virtual methods or virtual bases are not trivially default 
constructible, so their members and bases need to be initialized.

Patch by Malcolm Parsons.

Modified:

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

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=283224&r1=283223&r2=283224&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Tue Oct  4 09:48:05 2016
@@ -32,17 +32,17 @@ namespace {
 // the record type (or indirect field) is a union, forEachField will stop after
 // the first field.
 template 
-void forEachField(const RecordDecl *Record, const T &Fields,
+void forEachField(const RecordDecl &Record, const T &Fields,
   bool OneFieldPerUnion, Func &&Fn) {
   for (const FieldDecl *F : Fields) {
 if (F->isAnonymousStructOrUnion()) {
   if (const CXXRecordDecl *R = F->getType()->getAsCXXRecordDecl())
-forEachField(R, R->fields(), OneFieldPerUnion, Fn);
+forEachField(*R, R->fields(), OneFieldPerUnion, Fn);
 } else {
   Fn(F);
 }
 
-if (OneFieldPerUnion && Record->isUnion())
+if (OneFieldPerUnion && Record.isUnion())
   break;
   }
 }
@@ -214,16 +214,16 @@ computeInsertions(const CXXConstructorDe
 
 // Gets the list of bases and members that could possibly be initialized, in
 // order as they appear in the class declaration.
-void getInitializationsInOrder(const CXXRecordDecl *ClassDecl,
+void getInitializationsInOrder(const CXXRecordDecl &ClassDecl,
SmallVectorImpl &Decls) {
   Decls.clear();
-  for (const auto &Base : ClassDecl->bases()) {
+  for (const auto &Base : ClassDecl.bases()) {
 // Decl may be null if the base class is a template parameter.
 if (const NamedDecl *Decl = getCanonicalRecordDecl(Base.getType())) {
   Decls.emplace_back(Decl);
 }
   }
-  forEachField(ClassDecl, ClassDecl->fields(), false,
+  forEachField(ClassDecl, ClassDecl.fields(), false,
[&](const FieldDecl *F) { Decls.push_back(F); });
 }
 
@@ -236,7 +236,7 @@ void fixInitializerList(const ASTContext
 return;
 
   SmallVector OrderedDecls;
-  getInitializationsInOrder(Ctor->getParent(), OrderedDecls);
+  getInitializationsInOrder(*Ctor->getParent(), OrderedDecls);
 
   for (const auto &Insertion :
computeInsertions(Ctor->inits(), OrderedDecls, DeclsToInit)) {
@@ -269,6 +269,19 @@ void ProTypeMemberInitCheck::registerMat
IsNonTrivialDefaultConstructor))
   .bind("ctor"),
   this);
+
+  // Match classes with a default constructor that is defaulted or is not in 
the
+  // AST.
+  Finder->addMatcher(
+  cxxRecordDecl(
+  isDefinition(), unless(isInstantiated()),
+  anyOf(has(cxxConstructorDecl(isDefaultConstructor(), isDefaulted(),
+   unless(isImplicit(,
+unless(has(cxxConstructorDecl(,
+  unless(isTriviallyDefaultConstructible()))
+  .bind("record"),
+  this);
+
   auto HasDefaultConstructor = hasInitializer(
   cxxConstructExpr(unless(requiresZeroInitialization()),
hasDeclaration(cxxConstructorDecl(
@@ -287,8 +300,14 @@ void ProTypeMemberInitCheck::check(const
 // Skip declarations delayed by late template parsing without a body.
 if (!Ctor->getBody())
   return;
-checkMissingMemberInitializer(*Result.Context, Ctor);
-checkMissingBaseClassInitializer(*Result.Context, Ctor);
+checkMissingMemberInitializer(*Result.Context, *Ctor->getParent(), Ctor);
+checkMissingBaseClassInitializer(*Result.Context, *Ctor->getParent(), 
Ctor);
+  } else if (const auto *Record =
+ Result.Nodes.getNodeAs("record")) {
+assert(Record->hasDefaultConstructor() &&
+   "Matched record should have a default constructor");
+checkMissingMemberInitializer(*Result.Context, *Record, nullptr);
+checkMissingBaseClassInitializer(*Result.Context, *Record, nullptr);
   } else if (const auto *Var = Result.Nodes.getNodeAs("var")) {
 check

[PATCH] D24965: [clang-tidy] Fix cppcoreguidelines-pro-type-member-init false negatives

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

I've commit in r283224.


https://reviews.llvm.org/D24965



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


[PATCH] D24933: Enable configuration files in clang

2016-10-04 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 73482.
sepavloff added a comment.

Updated comments.


https://reviews.llvm.org/D24933

Files:
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp
  test/Driver/Inputs/config-1.cfg
  test/Driver/Inputs/config-2.cfg
  test/Driver/config-file.c
  test/Driver/config-file2.c
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -305,6 +305,36 @@
   return 1;
 }
 
+// Directories searched for configuration specified by option '--config'.
+static const ArrayRef SearchDirs({ "~/.llvm", "/etc/llvm" });
+
+// Directories searched for default configuration.
+static const ArrayRef DefSearchDirs;
+
+/// \brief Tries to find config file based on executable name.
+///
+/// If clang executable has name like foo-clang, the function tries to find file
+/// foo.cfg. The search is made by same rules as for default config file.
+///
+/// \param ConfigName  [out] File name, if the search is successful.
+/// \param ProgramName [in]  Clang executable name.
+///
+static llvm::cl::SearchResult findConfigFileFromProgramName(
+llvm::SmallVectorImpl &ConfigName, StringRef ProgramName) {
+  ConfigName.clear();
+  StringRef PName = llvm::sys::path::stem(ProgramName);
+  size_t Pos = PName.find("-clang");
+  if (Pos != StringRef::npos) {
+ConfigName.append(PName.begin(), PName.begin() + Pos);
+const StringRef Ext(".cfg");
+ConfigName.append(Ext.begin(), Ext.end());
+std::string CName(ConfigName.begin(), ConfigName.size());
+return llvm::cl::findDefaultCfgFile(ConfigName, DefSearchDirs, ProgramName,
+CName);
+  }
+  return llvm::cl::SearchResult::NotSpecified;
+}
+
 int main(int argc_, const char **argv_) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv_[0]);
   llvm::PrettyStackTraceProgram X(argc_, argv_);
@@ -330,6 +360,47 @@
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
 
+  // Try reading options from configuration file.
+  llvm::SmallString<128> ConfigFile;
+
+  // First try config file specified in command line. It has higher priority
+  // than any other way to specify configuration.
+  auto SRes = llvm::cl::findConfigFileFromArgs(ConfigFile, argv, SearchDirs);
+  if (llvm::cl::checkConfigFileSearchResult(SRes, ConfigFile, SearchDirs,
+ProgName))
+return 1;
+
+  // Environment variable has the next priority. It also specifies config file
+  // explicitly.
+  if (SRes == llvm::cl::SearchResult::NotSpecified) {
+SRes = llvm::cl::findConfigFileFromEnv(ConfigFile, "CLANGCFG");
+if (llvm::cl::checkConfigFileSearchResult(SRes, ConfigFile, SearchDirs,
+  ProgName))
+  return 1;
+  }
+
+  // If config file is not specified explicitly, try determine configuration
+  // implicitly. First try deduce configuration from executable. For instance,
+  // file 'foo-clang' applies config file 'foo.cfg'.
+  if (SRes == llvm::cl::SearchResult::NotSpecified) {
+SRes = findConfigFileFromProgramName(ConfigFile, ProgName);
+if (llvm::cl::checkConfigFileSearchResult(SRes, ConfigFile, DefSearchDirs,
+  ProgName))
+  return 1;
+  }
+
+  // Finally try to find file 'clang.cfg'.
+  if (SRes == llvm::cl::SearchResult::NotSpecified) {
+SRes = llvm::cl::findDefaultCfgFile(ConfigFile, DefSearchDirs, ProgName,
+"clang.cfg");
+if (llvm::cl::checkConfigFileSearchResult(SRes, ConfigFile, DefSearchDirs,
+  ProgName))
+  return 1;
+  }
+
+  if (SRes == llvm::cl::SearchResult::Successful)
+llvm::cl::readConfigFile(ConfigFile, Saver, argv);
+
   // Parse response files using the GNU syntax, unless we're in CL mode. There
   // are two ways to put clang in CL compatibility mode: argv[0] is either
   // clang-cl or cl, or --driver-mode=cl is on the command line. The normal
@@ -446,6 +517,8 @@
   ProcessWarningOptions(Diags, *DiagOpts, /*ReportDiags=*/false);
 
   Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
+  if (!ConfigFile.empty())
+TheDriver.setConfigFile(ConfigFile.str());
   SetInstallDir(argv, TheDriver, CanonicalPrefixes);
 
   insertTargetAndModeArgs(TargetAndMode.first, TargetAndMode.second, argv,
Index: test/Driver/config-file2.c
===
--- /dev/null
+++ test/Driver/config-file2.c
@@ -0,0 +1,13 @@
+// Due to ln -sf:
+// REQUIRES: shell
+
+// RUN: mkdir -p %t.cfgtest
+// RUN: PWD=`pwd`
+// RUN: cd %t.cfgtest
+// RUN: ln -sf %clang test123-clang
+// RUN: echo "-ferror-limit=666" > test123.cfg
+// RUN: cd $PWD
+// RUN: %t.cfgtest/test123-clang -v -c %s -o - 2>&1 | FileCheck %s
+
+// CHECK: Configuration file:{{.*}}test123.cfg
+// CHECK: -ferror-limit{{.*}}666
Index: test/Dr

[PATCH] D24933: Enable configuration files in clang

2016-10-04 Thread Serge Pavlov via cfe-commits
sepavloff added inline comments.


> mgorny wrote in driver.cpp:314
> Please document what this function does, exactly. I see you've documented it 
> in call site but a doc here would be helpful as well.

The function is documented now.

> mgorny wrote in driver.cpp:376
> Are you sure about the name? I would rather see `TARGET-clang.cfg` than a 
> name that doesn't explicitly mention that the file is for clang.

You are right. Changed the comment.

https://reviews.llvm.org/D24933



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


[PATCH] D23853: Assert in performTrivialCopy - Bug report and a possible solution

2016-10-04 Thread Peter Szecsi via cfe-commits
szepet abandoned this revision.
szepet added a comment.

At first I was not able to reproduce it. Then I realized it was my foul because 
I used the analyzer without the core checkers in this case. Sorry for the false 
positive.


https://reviews.llvm.org/D23853



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


[PATCH] D24815: [clang] make reciprocal estimate codegen a function attribute

2016-10-04 Thread Sanjay Patel via cfe-commits
spatel added inline comments.


> mehdi_amini wrote in CGCall.cpp:1735
> I wonder if we couldn’t have this part of the bitcode/IR auto-upgrade: when 
> we load a function with this attribute, we automatically add the individual 
> flag on every instruction.

Auto-upgrading is part of the solution. Based on how we've been doing this with 
vector intrinsics that get converted to IR, it's a ~3-step process:

1. Prepare the backend (DAG) to handle the expected new IR patterns and add 
tests for those.
2. Auto-upgrade the IR, remove deprecated handling of the old IR patterns, and 
change/remove existing tests.
3. Update clang to not produce the deprecated patterns.

The extra step for FMF in the DAG is that we still don't allow FMF on all 
SDNode subclasses. The DAG plumbing for FMF only applies to binops because 
that's all that FMF on IR worked on at the time (fmul/fadd/fsub/fdiv/frem). 
Later, I added FMF to IR calls so we could have that functionality on sqrt, fma 
and other calls. Assuming that is ok (and I realize that it may be 
controversial), we can now extend FMF in the DAG to all SDNodes and have a full 
node-level FMF solution for the DAG layer.

https://reviews.llvm.org/D24815



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


[PATCH] D25238: [clang-tidy] Ignore empty members and bases in cppcoreguidelines-pro-type-member-init

2016-10-04 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, alexfh, mgehre.
malcolm.parsons added a subscriber: cfe-commits.
Herald added a subscriber: nemanjai.

Empty/incomplete variables/members/bases don't need to be initialized


https://reviews.llvm.org/D25238

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp


Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -423,3 +423,30 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: F
 UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(G);
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize 
these fields: G
+
+struct NegativeEmpty {
+};
+
+static void NegativeEmptyVar() {
+  NegativeEmpty e;
+  (void)e;
+}
+
+struct NegativeEmptyMember {
+  NegativeEmptyMember() {}
+  NegativeEmpty e;
+};
+
+struct NegativeEmptyBase : NegativeEmpty {
+  NegativeEmptyBase() {}
+};
+
+struct NegativeEmptyArrayMember {
+  NegativeEmptyArrayMember() {}
+  char e[0];
+};
+
+struct NegativeIncompleteArrayMember {
+  NegativeIncompleteArrayMember() {}
+  char e[];
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -317,6 +317,28 @@
   Options.store(Opts, "IgnoreArrays", IgnoreArrays);
 }
 
+// copied from clang/lib/Sema/SemaDeclCXX.cpp
+static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T) 
{
+  if (T->isIncompleteArrayType())
+return true;
+
+  while (const ConstantArrayType *ArrayT = Context.getAsConstantArrayType(T)) {
+if (!ArrayT->getSize())
+  return true;
+
+T = ArrayT->getElementType();
+  }
+
+  return false;
+}
+
+static bool isEmpty(ASTContext &Context, const QualType &Type) {
+  if (const CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl()) {
+return ClassDecl->isEmpty();
+  }
+  return isIncompleteOrZeroLengthArrayType(Context, Type);
+}
+
 void ProTypeMemberInitCheck::checkMissingMemberInitializer(
 ASTContext &Context, const CXXRecordDecl &ClassDecl,
 const CXXConstructorDecl *Ctor) {
@@ -330,7 +352,8 @@
   forEachField(ClassDecl, ClassDecl.fields(), false, [&](const FieldDecl *F) {
 if (!F->hasInClassInitializer() &&
 utils::type_traits::isTriviallyDefaultConstructible(F->getType(),
-Context))
+Context) &&
+!isEmpty(Context, F->getType()))
   FieldsToInit.insert(F);
   });
   if (FieldsToInit.empty())


Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -423,3 +423,30 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: F
 UNINITIALIZED_FIELD_IN_MACRO_BODY_VIRTUAL(G);
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: G
+
+struct NegativeEmpty {
+};
+
+static void NegativeEmptyVar() {
+  NegativeEmpty e;
+  (void)e;
+}
+
+struct NegativeEmptyMember {
+  NegativeEmptyMember() {}
+  NegativeEmpty e;
+};
+
+struct NegativeEmptyBase : NegativeEmpty {
+  NegativeEmptyBase() {}
+};
+
+struct NegativeEmptyArrayMember {
+  NegativeEmptyArrayMember() {}
+  char e[0];
+};
+
+struct NegativeIncompleteArrayMember {
+  NegativeIncompleteArrayMember() {}
+  char e[];
+};
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -317,6 +317,28 @@
   Options.store(Opts, "IgnoreArrays", IgnoreArrays);
 }
 
+// copied from clang/lib/Sema/SemaDeclCXX.cpp
+static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T) {
+  if (T->isIncompleteArrayType())
+return true;
+
+  while (const ConstantArrayType *ArrayT = Context.getAsConstantArrayType(T)) {
+if (!ArrayT->getSize())
+  return true;
+
+T = ArrayT->getElementType();
+  }
+
+  return false;
+}
+
+static bool isEmpty(ASTContext &Context, const QualType &Type) {
+  if (const CXXRecordDecl *ClassDecl = Type->getAsCXXRecordDecl()) {
+return ClassDecl->isEmpty();
+  }
+  return isIncompleteOrZeroLengthArrayType(Context, Type);
+}
+
 void ProTypeMemberInitCheck::checkMissingMemberInitializer(
 ASTContext &Context, const CXXRecordDecl &ClassDecl,

[PATCH] D25199: [ubsan] Sanitize deleted pointers

2016-10-04 Thread Filipe Cabecinhas via cfe-commits
filcab added a comment.

In https://reviews.llvm.org/D25199#560061, @vsk wrote:

> My question was about whether it's possible to resume normal program 
> execution after printing the stack trace from the segv handler. I had assumed 
> this is not possible, and (mistakenly) thought that you were suggesting this 
> approach.


I guess we can eventually add a warning if you have this check + trap-function. 
If there's really a need for it.



> UndefinedBehaviorSanitizer.rst:122
> +  -  ``-fsanitize=value-after-delete``: Set the value of the pointer
> + passed in a delete expression to 0xDEADBEEF.
>-  ``-fsanitize=vla-bound``: A variable-length array whose bound

Why just `delete` and not `free()`?

> CGExprScalar.cpp:416
> +  if (arg->IgnoreImplicit()->isLValue() &&
> +  !arg->HasSideEffects(CGF.getContext())) {
> +LValue LHS = EmitLValue(arg);

Missing a test for this condition.

> sanitize-value-after-delete.cpp:2
> +// Test -fsanitize-value-after-delete
> +// RUN: %clang_cc1 -O3 -fsanitize=value-after-delete -disable-llvm-optzns 
> -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
> +

Please keep the test simple. You don't even need C++11 (in addition to the 
flags vsk mentioned).

> sanitize-value-after-delete.cpp:22
> +// CHECK: store {{.*}} inttoptr (i64 -2401053088876216593 {{.*}} %p2
> +// CHECK-NOT: store {{.*}} inttoptr (i64 -2401053088876216593 {{.*}} %p2
> +// CHECK-LABEL: DO_NOT_MODIFY

Why?

https://reviews.llvm.org/D25199



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


[PATCH] D25204: Register Calling Convention, Clang changes

2016-10-04 Thread Erich Keane via cfe-commits
erichkeane added a comment.

Hi Alexey-
Can you let me know what you mean by "Full Context Review"?  I'm unfamiliar 
with that process.  The other fixes I'll look at today.


Repository:
  rL LLVM

https://reviews.llvm.org/D25204



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


[PATCH] D24669: {Sema] Gcc compatibility of vector shift.

2016-10-04 Thread Akira Hatanaka via cfe-commits
ahatanak added inline comments.


> SemaExpr.cpp:8787
>  }
> +if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
> +  const BuiltinType *LHSBT = LHSEleType->getAs();

Is it possible to use ASTContext::getTypeSize here?

https://reviews.llvm.org/D24669



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


[PATCH] D25001: [Module] Merge function prototype with a non-prototype function declaration

2016-10-04 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

ping


https://reviews.llvm.org/D25001



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


[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

2016-10-04 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

ping


https://reviews.llvm.org/D24969



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


[PATCH] D25204: Register Calling Convention, Clang changes

2016-10-04 Thread Erich Keane via cfe-commits
erichkeane removed rL LLVM as the repository for this revision.
erichkeane updated this revision to Diff 73489.

https://reviews.llvm.org/D25204

Files:
  include/clang-c/Index.h
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  lib/AST/Expr.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/Mangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/regcall.c
  test/CodeGenCXX/regcall.cpp
  tools/libclang/CXType.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -605,6 +605,7 @@
 case tok::kw___fastcall:
 case tok::kw___stdcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___cdecl:
 case tok::kw___vectorcall:
 case tok::kw___ptr64:
@@ -3137,6 +3138,7 @@
 case tok::kw___stdcall:
 case tok::kw___fastcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___vectorcall:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
@@ -4454,6 +4456,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___ptr64:
@@ -4638,6 +4641,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___sptr:
@@ -4876,6 +4880,7 @@
 case tok::kw___stdcall:
 case tok::kw___fastcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___vectorcall:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -909,7 +909,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___regcall, tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
@@ -1058,6 +1058,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___unaligned:
   case tok::kw___vector:
@@ -1351,6 +1352,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___sptr:
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -683,7 +683,15 @@
   } else {
 IdentifierInfo *II = ND->getIdentifier();
 assert(II && "Attempt to mangle unnamed decl.");
-Str = II->getName();
+const FunctionDecl *FD = dyn_cast(ND);
+
+if (FD && FD->getType()->castAs()->getCallConv() == CC_X86RegCall) {
+  llvm::raw_svector_ostream Out(Buffer);
+  Out << "__regcall3__" << II->getName();
+  Str = Out.str();
+} else {
+  Str = II->getName();
+}
   }
 
   // Keep the first result in the case of a mangling collision.
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -48,6 +48,7 @@
   default: return llvm::CallingConv::C;
   case CC_X86StdCall: return llvm::CallingConv::X86_StdCall;
   case CC_X86FastCall: return llvm::CallingConv::X86_FastCall;
+  case CC_X86RegCall: return llvm::CallingConv::X86_RegCall;
   case CC_X86ThisCall: return llvm::CallingConv::X86_ThisCall;
   case CC_X86_64Win64: return llvm::CallingConv::X86_64_Win64;
   case CC_X86_64SysV: return llvm::CallingConv::X86_64_SysV;
@@ -173,6 +174,9 @@
   if (D->hasAttr())
 return CC_X86FastCall;
 
+  if (D->hasAttr())
+return CC_X86RegCall;
+
   if (D->hasAttr())
 return CC_X86ThisCall;
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -893,6 +893,7 @@
   case CC_Swift:
   case CC_PreserveMost:
   case CC_PreserveAll:
+  case CC_X8

[PATCH] D25204: Register Calling Convention, Clang changes

2016-10-04 Thread Erich Keane via cfe-commits
erichkeane marked 4 inline comments as done.
erichkeane added a comment.

Updated the code, fixed Alexey's concerns.  Thanks again for the comments!


https://reviews.llvm.org/D25204



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


[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

2016-10-04 Thread Richard Smith via cfe-commits
rsmith added inline comments.


> SemaTemplateInstantiateDecl.cpp:4849
> +  DeclarationName Name = D->getDeclName();
> +  if (auto *DD = dyn_cast(D))
> +Name =

Do we need to do this for conversion function names too? (Eg, `operator C1*`)

https://reviews.llvm.org/D24969



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


[PATCH] D25204: Register Calling Convention, Clang changes

2016-10-04 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

In https://reviews.llvm.org/D25204#560894, @erichkeane wrote:

> Hi Alexey-
>  Can you let me know what you mean by "Full Context Review"?  I'm unfamiliar 
> with that process.  The other fixes I'll look at today.


Check this page http://llvm.org/docs/Phabricator.html
use

  git diff -U99 other-branch

or

  svn diff --diff-cmd=diff -x -U99


https://reviews.llvm.org/D25204



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


[PATCH] D23712: [OpenCL] Override supported OpenCL extensions with -cl-ext option

2016-10-04 Thread Yaxun Liu via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D23712



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


[PATCH] D25204: Register Calling Convention, Clang changes

2016-10-04 Thread Erich Keane via cfe-commits
erichkeane updated this revision to Diff 73490.
erichkeane added a comment.

Did a full context diff, as requested.


https://reviews.llvm.org/D25204

Files:
  include/clang-c/Index.h
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  lib/AST/Expr.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/Mangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaType.cpp
  test/CodeGen/regcall.c
  test/CodeGenCXX/regcall.cpp
  tools/libclang/CXType.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -605,6 +605,7 @@
 case tok::kw___fastcall:
 case tok::kw___stdcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___cdecl:
 case tok::kw___vectorcall:
 case tok::kw___ptr64:
@@ -3137,6 +3138,7 @@
 case tok::kw___stdcall:
 case tok::kw___fastcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___vectorcall:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
@@ -4454,6 +4456,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___ptr64:
@@ -4638,6 +4641,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___sptr:
@@ -4876,6 +4880,7 @@
 case tok::kw___stdcall:
 case tok::kw___fastcall:
 case tok::kw___thiscall:
+case tok::kw___regcall:
 case tok::kw___vectorcall:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -909,7 +909,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___regcall, tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
@@ -1058,6 +1058,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___unaligned:
   case tok::kw___vector:
@@ -1351,6 +1352,7 @@
   case tok::kw___stdcall:
   case tok::kw___fastcall:
   case tok::kw___thiscall:
+  case tok::kw___regcall:
   case tok::kw___vectorcall:
   case tok::kw___w64:
   case tok::kw___sptr:
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -683,7 +683,15 @@
   } else {
 IdentifierInfo *II = ND->getIdentifier();
 assert(II && "Attempt to mangle unnamed decl.");
-Str = II->getName();
+const FunctionDecl *FD = dyn_cast(ND);
+
+if (FD && FD->getType()->castAs()->getCallConv() == CC_X86RegCall) {
+  llvm::raw_svector_ostream Out(Buffer);
+  Out << "__regcall3__" << II->getName();
+  Str = Out.str();
+} else {
+  Str = II->getName();
+}
   }
 
   // Keep the first result in the case of a mangling collision.
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -48,6 +48,7 @@
   default: return llvm::CallingConv::C;
   case CC_X86StdCall: return llvm::CallingConv::X86_StdCall;
   case CC_X86FastCall: return llvm::CallingConv::X86_FastCall;
+  case CC_X86RegCall: return llvm::CallingConv::X86_RegCall;
   case CC_X86ThisCall: return llvm::CallingConv::X86_ThisCall;
   case CC_X86_64Win64: return llvm::CallingConv::X86_64_Win64;
   case CC_X86_64SysV: return llvm::CallingConv::X86_64_SysV;
@@ -173,6 +174,9 @@
   if (D->hasAttr())
 return CC_X86FastCall;
 
+  if (D->hasAttr())
+return CC_X86RegCall;
+
   if (D->hasAttr())
 return CC_X86ThisCall;
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -893,6 +893,7 @@
   case CC_Swift:
   case CC_PreserveMost:
   case CC_PreserveAll:
+  case 

[PATCH] D25153: preprocessor supports `-dI` flag

2016-10-04 Thread Richard Smith via cfe-commits
rsmith added inline comments.


> PrintPreprocessedOutput.cpp:328
> +  case '"':  // paths are enclosed in quotes; escape them
> +  case '*':  // don't allow a "*/" sequence to accidentally open the 
> comment
> +  case '\\': // escape the escape character itself.

Putting a \ before a * won't stop it being recognised as part of a */.

> PrintPreprocessedOutput.cpp:329
> +  case '*':  // don't allow a "*/" sequence to accidentally open the 
> comment
> +  case '\\': // escape the escape character itself.
> +str[len++] = '\\';

Is this really necessary? It'll be very ugly on Windows.

> PrintPreprocessedOutput.cpp:396
> +  StringRef InclusionKeyword("include");
> +  tryGetTokenText(&InclusionKeyword, IncludeTok);
> +

Please do this in the preceding case too.

https://reviews.llvm.org/D25153



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


r283227 - [MS] Move hex long long sign compat hack to -fms-compatibility

2016-10-04 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Oct  4 10:57:49 2016
New Revision: 283227

URL: http://llvm.org/viewvc/llvm-project?rev=283227&view=rev
Log:
[MS] Move hex long long sign compat hack to -fms-compatibility

Treating large 0x*LL literals as signed instead of unsigned is not a
conforming language extension, so move it out of -fms-extensions.

Came up in PR30605

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=283227&r1=283226&r2=283227&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Oct  4 10:57:49 2016
@@ -3518,7 +3518,7 @@ ExprResult Sema::ActOnNumericConstant(co
   // To be compatible with MSVC, hex integer literals ending with the
   // LL or i64 suffix are always signed in Microsoft mode.
   if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
-  (getLangOpts().MicrosoftExt && Literal.isLongLong)))
+  (getLangOpts().MSVCCompat && Literal.isLongLong)))
 Ty = Context.LongLongTy;
   else if (AllowUnsigned)
 Ty = Context.UnsignedLongLongTy;

Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=283227&r1=283226&r2=283227&view=diff
==
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Tue Oct  4 10:57:49 2016
@@ -242,3 +242,14 @@ namespace IntToNullPtrConv {
   template int *get_n() { return N; }   // expected-warning 
{{expression which evaluates to zero treated as a null pointer constant}}
   int *g_nullptr = get_n<0>();  // expected-note {{in instantiation of 
function template specialization}}
 }
+
+namespace signed_hex_i64 {
+void f(long long);
+void f(int);
+void g() {
+  // This is an ambiguous call in standard C++.
+  // This calls f(long long) in Microsoft mode because LL is always signed.
+  f(0xLL);
+  f(0xi64);
+}
+}

Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=283227&r1=283226&r2=283227&view=diff
==
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Tue Oct  4 10:57:49 2016
@@ -158,19 +158,16 @@ void m1() {
 }
 
 
-
-
-
-void f(long long);
-void f(int);
-
-int main()
-{
-  // This is an ambiguous call in standard C++.
-  // This calls f(long long) in Microsoft mode because LL is always signed.
-  f(0xLL);
+namespace signed_hex_i64 {
+void f(long long); // expected-note {{candidate function}}
+void f(int); // expected-note {{candidate function}}
+void g() {
+  // This used to be controlled by -fms-extensions, but it is now under
+  // -fms-compatibility.
+  f(0xLL); // expected-error {{call to 'f' is ambiguous}}
   f(0xi64);
 }
+}
 
 // Enumeration types with a fixed underlying type.
 const int seventeen = 17;


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


[PATCH] D25241: [libcxx] Improve code generation for vector::clear().

2016-10-04 Thread Bruce Mitchener via cfe-commits
brucem created this revision.
brucem added a subscriber: cfe-commits.

By manipulating a local variable in the loop, when the loop can
be optimized away (due to no non-trivial destructors), this lets
it be fully optimized away and we modify the __end_ separately.

This results in a substantial improvement in the generated code.

Prior to this change, this would be generated (on x86_64):

  movq(%rdi), %rdx
  movq8(%rdi), %rcx
  cmpq%rdx, %rcx
  jeLBB2_2
  leaq-12(%rcx), %rax
  subq%rdx, %rax
  movabsq$-6148914691236517205, %rdx ## imm = 0xAAAB
  mulq%rdx
  shrq$3, %rdx
  notq%rdx
  leaq(%rdx,%rdx,2), %rax
  leaq(%rcx,%rax,4), %rax
  movq%rax, 8(%rdi)

And after:

  movq(%rdi), %rax
  movq%rax, 8(%rdi)

This brings this in line with what other implementations do.


https://reviews.llvm.org/D25241

Files:
  include/vector
  test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp


Index: test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
===
--- /dev/null
+++ test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// void clear();
+
+#include 
+#include 
+
+#include "min_allocator.h"
+
+int main()
+{
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+}
+#if TEST_STD_VER >= 11
+{
+int a[] = {1, 2, 3};
+std::vector> c(a, a+3);
+c.clear();
+assert(c.empty());
+}
+#endif
+}
Index: include/vector
===
--- include/vector
+++ include/vector
@@ -413,8 +413,10 @@
 void
 __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
 {
-while (__new_last != __end_)
-__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
+pointer __soon_to_be_end = __end_;
+while (__new_last != __soon_to_be_end)
+__alloc_traits::destroy(__alloc(), 
_VSTD::__to_raw_pointer(--__soon_to_be_end));
+__end_ = __new_last;
 }
 
 template 


Index: test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
===
--- /dev/null
+++ test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// void clear();
+
+#include 
+#include 
+
+#include "min_allocator.h"
+
+int main()
+{
+{
+int a[] = {1, 2, 3};
+std::vector c(a, a+3);
+c.clear();
+assert(c.empty());
+}
+#if TEST_STD_VER >= 11
+{
+int a[] = {1, 2, 3};
+std::vector> c(a, a+3);
+c.clear();
+assert(c.empty());
+}
+#endif
+}
Index: include/vector
===
--- include/vector
+++ include/vector
@@ -413,8 +413,10 @@
 void
 __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT
 {
-while (__new_last != __end_)
-__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__end_));
+pointer __soon_to_be_end = __end_;
+while (__new_last != __soon_to_be_end)
+__alloc_traits::destroy(__alloc(), _VSTD::__to_raw_pointer(--__soon_to_be_end));
+__end_ = __new_last;
 }
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r283228 - [Sema] Format a comment line so that it fits 80 columns. NFC

2016-10-04 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Oct  4 11:06:37 2016
New Revision: 283228

URL: http://llvm.org/viewvc/llvm-project?rev=283228&view=rev
Log:
[Sema] Format a comment line so that it fits 80 columns. NFC

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=283228&r1=283227&r2=283228&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct  4 11:06:37 2016
@@ -9812,8 +9812,9 @@ public:
 
   /// \brief This function checks if the expression is in the sef of 
potentially
   /// misaligned members and it is converted to some pointer type T with lower
-  /// or equal alignment requirements.  If so it removes it. This is used when
-  /// we do not want to diagnose such misaligned access (e.g. in conversions 
to void*).
+  /// or equal alignment requirements. If so it removes it. This is used when
+  /// we do not want to diagnose such misaligned access (e.g. in conversions to
+  /// void*).
   void DiscardMisalignedMemberAddress(const Type *T, Expr *E);
 
   /// \brief This function calls Action when it determines that E designates a


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


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-04 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

Thanks for working on this!

This patch fixes a couple of our internal warnings that shouldn't be presented. 
I included a code sample that reproduces our warnings,  would you mind adding 
some code to the test case that's similar to the sample below?

  typedef   struct {
uint32_t msgh_bits;
uint32_t msgh_size;
int32_t msgh_voucher_port;
int32_t msgh_id;
  } S10Header;
  
  typedef struct {
  uint32_t t;
  uint64_t m;
  uint32_t p;
  union {
  struct {
  uint32_t a;
  double z;
  } __attribute__ ((aligned (8), packed)) a;
  struct {
  uint32_t b;
  double z;
  uint32_t a;
  } __attribute__ ((aligned (8), packed)) b;
  };
  } __attribute__ ((aligned (8), packed)) S10Data;
  
  typedef struct {
S10Header hdr;
uint32_t size;
uint8_t count;
S10Data data[] __attribute__ ((aligned (8)));
  } __attribute__ ((aligned (8), packed)) S10;
  
  void foo(S10Header *hdr);
  void bar(S10 *s) {
foo(&s->hdr); // No warning expected.
  }

Btw, slightly off-topic, but I noticed that the declaration 
`DiagnoseMisalignedMembers` in the header has a doc comment that violates the 
80 chars rule. I committed a fix in r283228.


https://reviews.llvm.org/D23657



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


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-04 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D23657#560938, @arphaman wrote:

> Btw, slightly off-topic, but I noticed that the declaration 
> `DiagnoseMisalignedMembers` in the header has a doc comment that violates the 
> 80 chars rule. I committed a fix in r283228.


I meant to say `DiscardMisalignedMemberAddress`, sorry.


https://reviews.llvm.org/D23657



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


[PATCH] D25204: Register Calling Convention, Clang changes

2016-10-04 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


> Index.h:3029
>CXCallingConv_PreserveAll = 15,
> +  CXCallingConv_X86RegCall = 16,
>  

Maybe it is better to use 8, as the previous comment allows it?

  /* Value 8 was PnaclCall, but it was never used, so it could safely be 
re-used. */

In this case you don't need to increase number of bits used for calling 
conventions

> ItaniumMangle.cpp:1236-1237
> +  bool isRegCall = (FD != nullptr) &&
> +FD->getType()->castAs()->getCallConv() ==
> +  clang::CC_X86RegCall;
> +

What if function type is not a FunctionProtoType?

> MicrosoftMangle.cpp:435-436
> +  if (auto FD = dyn_cast(D))
> +if (FD->getType()->castAs()->getCallConv() ==
> +clang::CC_X86RegCall)
> +  Out << "__regcall3__";

Again, what if type is not FunctionProtoType?

> TargetInfo.cpp:1546-1548
>State.CC == llvm::CallingConv::X86_FastCall ||
> -  State.CC == llvm::CallingConv::X86_VectorCall,
> +  State.CC == llvm::CallingConv::X86_VectorCall || 
> +  State.CC == llvm::CallingConv::X86_RegCall,

Seems to me this code is clang-formatted

> TargetInfo.cpp:3301-3303
> +  if (RT->getDecl()->hasFlexibleArrayMember()) {
> +return getIndirectReturnResult(Ty);
> +  }

No braces

> TargetInfo.cpp:3388-3392
> +if (IsRegCall && it->type->isStructureType())
> +{
> +  it->info = classifyRegCallStructType(it->type, neededInt, neededSSE);
> +}
> +else

Not clang-formatted and extra braces

> SemaDecl.cpp:8288
>  int DiagID =
> -CC == CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
> +(CC == CC_X86StdCall || CC == CC_X86RegCall) ? 
> diag::warn_cconv_knr : diag::err_cconv_knr;
>  Diag(NewFD->getLocation(), DiagID)

Is this formatted?

> SemaDeclAttr.cpp:3833-3837
> +  case AttributeList::AT_RegCall:
> +D->addAttr(::new (S.Context)
> +  RegCallAttr(Attr.getRange(), S.Context,
> +  Attr.getAttributeSpellingListIndex()));
> +return;

Not formatted

https://reviews.llvm.org/D25204



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


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-04 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

@arphaman thanks for the testcase! Will do.


https://reviews.llvm.org/D23657



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


[PATCH] D24998: Add a new optimization option -Og

2016-10-04 Thread David Blaikie via cfe-commits
dblaikie added inline comments.


> debug-options.c:21-22
>  
> +// RUN: %clang -### -c -Og -g %s -target x86_64-linux-gnu 2>&1 \
> +// RUN: | FileCheck -check-prefix=G -check-prefix=G_GDB %s
> +

I don't think we need this test case: -Og doesn't actually have anything to do 
with -g mechanically speaking, so there's no need to test them together.

I'd probably go find wherever -O1 is tested in the driver, and test -Og there.

https://reviews.llvm.org/D24998



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


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-04 Thread Joerg Sonnenberger via cfe-commits
joerg added a comment.

Seems to work for the false positives I have identified so far.


https://reviews.llvm.org/D23657



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


[PATCH] D25204: Register Calling Convention, Clang changes

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


> AttrDocs.td:1263
> +On x86 targets, this attribute changes the calling convention to
> +__regcall convention. This convention aimes to pass as many arguments
> +as possible in registers. It also tries to utilize registers for the

"aims"

> TargetInfo.cpp:3306
> +  // Sum up bases
> +  if (auto CXXRD = dyn_cast(RT->getDecl()))
> +for (const auto &I : CXXRD->bases())

You might want to defend against dynamic C++ records which will have vtable 
fields.

> TargetInfo.cpp:3323
> +  unsigned localNeededInt, localNeededSSE;
> +  if (classifyArgumentType(FD->getType(), 
> (std::numeric_limits::max)(),
> +localNeededInt, localNeededSSE, 
> true).isIndirect()) {

This code doesn't need to worry about windows.h defining max.

> TargetInfo.cpp:3388-3389
>  
> -unsigned neededInt, neededSSE;
> -it->info = classifyArgumentType(it->type, freeIntRegs, neededInt,
> +if (IsRegCall && it->type->isStructureType())
> +{
> +  it->info = classifyRegCallStructType(it->type, neededInt, neededSSE);

not llvm style

> TargetInfo.cpp:3742-3743
>  
> -  // We can use up to 6 SSE register parameters with vectorcall.
> -  FreeSSERegs = IsVectorCall ? 6 : 0;
> +  // Regcall doesn't differentiate between return and parameter registers,
> +  // and non Reg/Vector call was 0 anyway.
> +  if (IsVectorCall) {

'classify' takes FreeSSERegs by reference and modifies it, so are you sure this 
is correct? It means if I have this kind of prototype, we won't pass 'd' in 
registers because we'll consume four registers for the return value:

  struct HFA { __m128 f[4]; };
  HFA __regcall f(HFA a, HFA b, HFA c, HFA d) {
...
  }

> SemaDecl.cpp:8288
>  int DiagID =
> -CC == CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
> +(CC == CC_X86StdCall || CC == CC_X86RegCall) ? 
> diag::warn_cconv_knr : diag::err_cconv_knr;
>  Diag(NewFD->getLocation(), DiagID)

The comment doesn't apply here. Are you sure you don't want some other 
behavior, like unprototyped functions are actually implicitly void when regcall 
is used, as in C++?

https://reviews.llvm.org/D25204



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


  1   2   3   >