Re: [PATCH] D12036: We shouldn't need to pass -fno-strict-aliasing when building clang with clang.

2015-08-18 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245304: We shouldn't need to pass -fno-strict-aliasing when 
building clang with clang. (authored by cbieneman).

Changed prior to commit:
  http://reviews.llvm.org/D12036?vs=32349id=32420#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12036

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/Makefile

Index: cfe/trunk/Makefile
===
--- cfe/trunk/Makefile
+++ cfe/trunk/Makefile
@@ -67,8 +67,11 @@
 #   http://gcc.gnu.org/PR41874
 #   http://gcc.gnu.org/PR41838
 #
-# We can revisit this when LLVM/Clang support it.
+# We don't need to do this if the host compiler is clang.
+ifeq ($(CXX_COMPILER), clang)
 CXX.Flags += -fno-strict-aliasing
+endif
+
 
 # Set up Clang's tblgen.
 ifndef CLANG_TBLGEN
Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -253,7 +253,10 @@
 
 # Add appropriate flags for GCC
 if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
-  set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual 
-fno-strict-aliasing)
+  set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual)
+  if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
+set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fno-strict-aliasing)
+  endif ()
 
   # Enable -pedantic for Clang even if it's not enabled for LLVM.
   if (NOT LLVM_ENABLE_PEDANTIC)


Index: cfe/trunk/Makefile
===
--- cfe/trunk/Makefile
+++ cfe/trunk/Makefile
@@ -67,8 +67,11 @@
 #   http://gcc.gnu.org/PR41874
 #   http://gcc.gnu.org/PR41838
 #
-# We can revisit this when LLVM/Clang support it.
+# We don't need to do this if the host compiler is clang.
+ifeq ($(CXX_COMPILER), clang)
 CXX.Flags += -fno-strict-aliasing
+endif
+
 
 # Set up Clang's tblgen.
 ifndef CLANG_TBLGEN
Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -253,7 +253,10 @@
 
 # Add appropriate flags for GCC
 if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
-  set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -fno-strict-aliasing)
+  set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual)
+  if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
+set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fno-strict-aliasing)
+  endif ()
 
   # Enable -pedantic for Clang even if it's not enabled for LLVM.
   if (NOT LLVM_ENABLE_PEDANTIC)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12240: [AArch64] Define the macro __ARM_FP16_ARGS

2015-08-24 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245833: [AArch64] Define the macro __ARM_FP16_ARGS (authored 
by kwalker).

Changed prior to commit:
  http://reviews.llvm.org/D12240?vs=32832id=32938#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12240

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/aarch64-target-features.c

Index: cfe/trunk/test/Preprocessor/aarch64-target-features.c
===
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c
@@ -19,6 +19,7 @@
 // CHECK: __ARM_FEATURE_NUMERIC_MAXMIN 1
 // CHECK: __ARM_FEATURE_UNALIGNED 1
 // CHECK: __ARM_FP 0xe
+// CHECK: __ARM_FP16_ARGS 1
 // CHECK: __ARM_FP16_FORMAT_IEEE 1
 // CHECK-NOT: __ARM_FP_FAST 1
 // CHECK: __ARM_FP_FENV_ROUNDING 1
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -5176,6 +5176,7 @@
 // PCS specifies this for SysV variants, which is all we support. Other 
ABIs
 // may choose __ARM_FP16_FORMAT_ALTERNATIVE.
 Builder.defineMacro(__ARM_FP16_FORMAT_IEEE);
+Builder.defineMacro(__ARM_FP16_ARGS);
 
 if (Opts.FastMath || Opts.FiniteMathOnly)
   Builder.defineMacro(__ARM_FP_FAST);


Index: cfe/trunk/test/Preprocessor/aarch64-target-features.c
===
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c
@@ -19,6 +19,7 @@
 // CHECK: __ARM_FEATURE_NUMERIC_MAXMIN 1
 // CHECK: __ARM_FEATURE_UNALIGNED 1
 // CHECK: __ARM_FP 0xe
+// CHECK: __ARM_FP16_ARGS 1
 // CHECK: __ARM_FP16_FORMAT_IEEE 1
 // CHECK-NOT: __ARM_FP_FAST 1
 // CHECK: __ARM_FP_FENV_ROUNDING 1
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -5176,6 +5176,7 @@
 // PCS specifies this for SysV variants, which is all we support. Other ABIs
 // may choose __ARM_FP16_FORMAT_ALTERNATIVE.
 Builder.defineMacro(__ARM_FP16_FORMAT_IEEE);
+Builder.defineMacro(__ARM_FP16_ARGS);
 
 if (Opts.FastMath || Opts.FiniteMathOnly)
   Builder.defineMacro(__ARM_FP_FAST);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10016: Refactor: Simplify boolean conditional return statements in lib/Frontend

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38309.
LegalizeAdulthood added a comment.

Update to latest


http://reviews.llvm.org/D10016

Files:
  lib/Frontend/VerifyDiagnosticConsumer.cpp

Index: lib/Frontend/VerifyDiagnosticConsumer.cpp
===
--- lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -186,9 +186,7 @@
   Regex(RegexStr) { }
 
   bool isValid(std::string ) override {
-if (Regex.isValid(Error))
-  return true;
-return false;
+return Regex.isValid(Error);
   }
 
   bool match(StringRef S) override {


Index: lib/Frontend/VerifyDiagnosticConsumer.cpp
===
--- lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -186,9 +186,7 @@
   Regex(RegexStr) { }
 
   bool isValid(std::string ) override {
-if (Regex.isValid(Error))
-  return true;
-return false;
+return Regex.isValid(Error);
   }
 
   bool match(StringRef S) override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10025: Refactor: Simplify boolean conditional return statements in clang-apply-replacements

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

I do not have commit access; someone will need to commit this for me.


http://reviews.llvm.org/D10025



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


Re: [PATCH] D10025: Refactor: Simplify boolean conditional return statements in clang-apply-replacements

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38313.
LegalizeAdulthood added a comment.

Update to latest


http://reviews.llvm.org/D10025

Files:
  clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Index: clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -184,10 +184,7 @@
   }
 
   // Ask clang to deduplicate and report conflicts.
-  if (deduplicateAndDetectConflicts(GroupedReplacements, SM))
-return false;
-
-  return true;
+  return !deduplicateAndDetectConflicts(GroupedReplacements, SM);
 }
 
 bool applyReplacements(const FileToReplacementsMap ,


Index: clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -184,10 +184,7 @@
   }
 
   // Ask clang to deduplicate and report conflicts.
-  if (deduplicateAndDetectConflicts(GroupedReplacements, SM))
-return false;
-
-  return true;
+  return !deduplicateAndDetectConflicts(GroupedReplacements, SM);
 }
 
 bool applyReplacements(const FileToReplacementsMap ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10024: Refactor: Simplify boolean conditional return statements in tools/libclang

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38315.
LegalizeAdulthood marked 2 inline comments as done.
LegalizeAdulthood added a comment.

Update to latest.
Update from comments.
I don't have commit access.


http://reviews.llvm.org/D10024

Files:
  tools/libclang/CIndex.cpp
  tools/libclang/Indexing.cpp
  tools/libclang/IndexingContext.cpp

Index: tools/libclang/IndexingContext.cpp
===
--- tools/libclang/IndexingContext.cpp
+++ tools/libclang/IndexingContext.cpp
@@ -804,10 +804,7 @@
   RefFileOccurrence RefOccur(FE, D);
   std::pair
   res = RefFileOccurrences.insert(RefOccur);
-  if (!res.second)
-return true; // already in map.
-
-  return false;
+  return !res.second; // already in map
 }
 
 const NamedDecl *IndexingContext::getEntityDecl(const NamedDecl *D) const {
Index: tools/libclang/Indexing.cpp
===
--- tools/libclang/Indexing.cpp
+++ tools/libclang/Indexing.cpp
@@ -669,9 +669,7 @@
 static bool topLevelDeclVisitor(void *context, const Decl *D) {
   IndexingContext  = *static_cast(context);
   IdxCtx.indexTopLevelDecl(D);
-  if (IdxCtx.shouldAbort())
-return false;
-  return true;
+  return !IdxCtx.shouldAbort();
 }
 
 static void indexTranslationUnit(ASTUnit , IndexingContext ) {
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -710,11 +710,8 @@
   return true;
 }
   }
-  
-  if (ShouldVisitBody && VisitCXXRecordDecl(D))
-return true;
-  
-  return false;
+
+  return ShouldVisitBody && VisitCXXRecordDecl(D);
 }
 
 bool CursorVisitor::VisitClassTemplatePartialSpecializationDecl(
@@ -939,11 +936,8 @@
   return true;
   }
 
-  if (ND->isThisDeclarationADefinition() &&
-  Visit(MakeCXCursor(ND->getBody(), StmtParent, TU, RegionOfInterest)))
-return true;
-
-  return false;
+  return ND->isThisDeclarationADefinition() &&
+ Visit(MakeCXCursor(ND->getBody(), StmtParent, TU, RegionOfInterest));
 }
 
 template 
@@ -6074,10 +6068,7 @@
 
   ++NextIdx;
   Lex.LexFromRawLexer(Tok);
-  if (Tok.is(tok::eof))
-return true;
-
-  return false;
+  return Tok.is(tok::eof);
 }
 
 static void annotatePreprocessorTokens(CXTranslationUnit TU,


Index: tools/libclang/IndexingContext.cpp
===
--- tools/libclang/IndexingContext.cpp
+++ tools/libclang/IndexingContext.cpp
@@ -804,10 +804,7 @@
   RefFileOccurrence RefOccur(FE, D);
   std::pair
   res = RefFileOccurrences.insert(RefOccur);
-  if (!res.second)
-return true; // already in map.
-
-  return false;
+  return !res.second; // already in map
 }
 
 const NamedDecl *IndexingContext::getEntityDecl(const NamedDecl *D) const {
Index: tools/libclang/Indexing.cpp
===
--- tools/libclang/Indexing.cpp
+++ tools/libclang/Indexing.cpp
@@ -669,9 +669,7 @@
 static bool topLevelDeclVisitor(void *context, const Decl *D) {
   IndexingContext  = *static_cast(context);
   IdxCtx.indexTopLevelDecl(D);
-  if (IdxCtx.shouldAbort())
-return false;
-  return true;
+  return !IdxCtx.shouldAbort();
 }
 
 static void indexTranslationUnit(ASTUnit , IndexingContext ) {
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -710,11 +710,8 @@
   return true;
 }
   }
-  
-  if (ShouldVisitBody && VisitCXXRecordDecl(D))
-return true;
-  
-  return false;
+
+  return ShouldVisitBody && VisitCXXRecordDecl(D);
 }
 
 bool CursorVisitor::VisitClassTemplatePartialSpecializationDecl(
@@ -939,11 +936,8 @@
   return true;
   }
 
-  if (ND->isThisDeclarationADefinition() &&
-  Visit(MakeCXCursor(ND->getBody(), StmtParent, TU, RegionOfInterest)))
-return true;
-
-  return false;
+  return ND->isThisDeclarationADefinition() &&
+ Visit(MakeCXCursor(ND->getBody(), StmtParent, TU, RegionOfInterest));
 }
 
 template 
@@ -6074,10 +6068,7 @@
 
   ++NextIdx;
   Lex.LexFromRawLexer(Tok);
-  if (Tok.is(tok::eof))
-return true;
-
-  return false;
+  return Tok.is(tok::eof);
 }
 
 static void annotatePreprocessorTokens(CXTranslationUnit TU,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10020: Refactor: Simplify boolean conditional return statements in lib/Serialization

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38310.
LegalizeAdulthood added a comment.

Update to latest


http://reviews.llvm.org/D10020

Files:
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTWriter.cpp

Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -3112,14 +3112,10 @@
   /// doesn't check whether the name has macros defined; use 
PublicMacroIterator
   /// to check that.
   bool isInterestingIdentifier(const IdentifierInfo *II, uint64_t MacroOffset) 
{
-if (MacroOffset ||
-II->isPoisoned() ||
-(IsModule ? II->hasRevertedBuiltin() : II->getObjCOrBuiltinID()) ||
-II->hasRevertedTokenIDToIdentifier() ||
-(NeedDecls && II->getFETokenInfo()))
-  return true;
-
-return false;
+return MacroOffset || II->isPoisoned() ||
+   (IsModule ? II->hasRevertedBuiltin() : II->getObjCOrBuiltinID()) ||
+   II->hasRevertedTokenIDToIdentifier() ||
+   (NeedDecls && II->getFETokenInfo());
   }
 
 public:
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -3956,10 +3956,7 @@
 
 case llvm::BitstreamEntry::SubBlock:
   if (Entry.ID == BlockID) {
-if (Cursor.EnterSubBlock(BlockID))
-  return true;
-// Found it!
-return false;
+return Cursor.EnterSubBlock(BlockID);
   }
   
   if (Cursor.SkipBlock())


Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -3112,14 +3112,10 @@
   /// doesn't check whether the name has macros defined; use PublicMacroIterator
   /// to check that.
   bool isInterestingIdentifier(const IdentifierInfo *II, uint64_t MacroOffset) {
-if (MacroOffset ||
-II->isPoisoned() ||
-(IsModule ? II->hasRevertedBuiltin() : II->getObjCOrBuiltinID()) ||
-II->hasRevertedTokenIDToIdentifier() ||
-(NeedDecls && II->getFETokenInfo()))
-  return true;
-
-return false;
+return MacroOffset || II->isPoisoned() ||
+   (IsModule ? II->hasRevertedBuiltin() : II->getObjCOrBuiltinID()) ||
+   II->hasRevertedTokenIDToIdentifier() ||
+   (NeedDecls && II->getFETokenInfo());
   }
 
 public:
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -3956,10 +3956,7 @@
 
 case llvm::BitstreamEntry::SubBlock:
   if (Entry.ID == BlockID) {
-if (Cursor.EnterSubBlock(BlockID))
-  return true;
-// Found it!
-return false;
+return Cursor.EnterSubBlock(BlockID);
   }
   
   if (Cursor.SkipBlock())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10020: Refactor: Simplify boolean conditional return statements in lib/Serialization

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

This changeset needs review, but I'm unsure of who to add as explicit reviewers.


http://reviews.llvm.org/D10020



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


Re: [PATCH] D10021: Refactor: Simplify boolean conditional return statements in lib/StaticAnalyzer/Checkers

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38311.
LegalizeAdulthood added a comment.

Update to latest.
This changeset needs review; I am unsure who to add as specific reviewers.


http://reviews.llvm.org/D10021

Files:
  lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
  lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
  lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
  lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
  lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp

Index: lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
@@ -235,12 +235,9 @@
 return false;
 
   // Run each of the checks on the conditions
-  if (containsMacro(cond) || containsEnum(cond)
-  || containsStaticLocal(cond) || containsBuiltinOffsetOf(cond)
-  || containsStmt(cond))
-return true;
-
-  return false;
+  return containsMacro(cond) || containsEnum(cond) ||
+ containsStaticLocal(cond) || containsBuiltinOffsetOf(cond) ||
+ containsStmt(cond);
 }
 
 // Returns true if the given CFGBlock is empty
Index: lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
@@ -404,10 +404,7 @@
 if (II == NSObjectII)
   break;
   }
-  if (!ID)
-return false;
-
-  return true;
+  return ID != nullptr;
 }
 
 /// \brief Returns true if the location is 'self'.
Index: lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
+++ lib/StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp
@@ -66,9 +66,8 @@
 // The type must be an array/pointer type.
 
 // This could be a null constant, which is allowed.
-if (E->isNullPointerConstant(ASTC, Expr::NPC_ValueDependentIsNull))
-  return true;
-return false;
+return static_cast(
+E->isNullPointerConstant(ASTC, Expr::NPC_ValueDependentIsNull));
   }
 
 public:
Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1000,12 +1000,9 @@
   // Ex:  [NSData dataWithBytesNoCopy:bytes length:10];
   // (...unless a 'freeWhenDone' parameter is false, but that's checked later.)
   StringRef FirstSlot = Call.getSelector().getNameForSlot(0);
-  if (FirstSlot == "dataWithBytesNoCopy" ||
-  FirstSlot == "initWithBytesNoCopy" ||
-  FirstSlot == "initWithCharactersNoCopy")
-return true;
-
-  return false;
+  return FirstSlot == "dataWithBytesNoCopy" ||
+ FirstSlot == "initWithBytesNoCopy" ||
+ FirstSlot == "initWithCharactersNoCopy";
 }
 
 static Optional getFreeWhenDoneArg(const ObjCMethodCall ) {
Index: lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp
@@ -201,12 +201,8 @@
 static bool isBadDeallocationArgument(const MemRegion *Arg) {
   if (!Arg)
 return false;
-  if (isa(Arg) ||
-  isa(Arg) ||
-  isa(Arg)) {
-return true;
-  }
-  return false;
+  return isa(Arg) || isa(Arg) ||
+ isa(Arg);
 }
 
 /// Given the address expression, retrieve the value it's pointing to. Assume
@@ -240,11 +236,7 @@
   DefinedOrUnknownSVal NoErr = Builder.evalEQ(State, NoErrVal,
  nonloc::SymbolVal(RetSym));
   ProgramStateRef ErrState = State->assume(NoErr, noError);
-  if (ErrState == State) {
-return true;
-  }
-
-  return false;
+  return ErrState == State;
 }
 
 // Report deallocator mismatch. Remove the region from tracking - reporting a
Index: lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
@@ -305,9 +305,7 @@
 const Stmt *Stmt2, bool IgnoreSideEffects) {
 
   if (!Stmt1 || !Stmt2) {
-if (!Stmt1 && !Stmt2)
-  return true;
-return false;
+return !Stmt1 && !Stmt2;
   }
 
   // If Stmt1 & Stmt2 are of different class then they are not
Index: 

Re: [PATCH] D14011: [AST] Re-add TypeLocs and NestedNameSpecifierLocs to the ParentMap.

2015-10-23 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251101: [AST] Re-add TypeLocs and NestedNameSpecifierLocs to 
the ParentMap. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D14011?vs=38216=38220#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14011

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/ASTTypeTraits.h
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
  cfe/trunk/unittests/AST/ASTContextParentMapTest.cpp
  cfe/trunk/unittests/ASTMatchers/Dynamic/ParserTest.cpp
  cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -793,8 +793,15 @@
 }
 
 void ASTContext::ReleaseParentMapEntries() {
-  if (!AllParents) return;
-  for (const auto  : *AllParents) {
+  if (!PointerParents) return;
+  for (const auto  : *PointerParents) {
+if (Entry.second.is()) {
+  delete Entry.second.get();
+} else if (Entry.second.is()) {
+  delete Entry.second.get();
+}
+  }
+  for (const auto  : *OtherParents) {
 if (Entry.second.is()) {
   delete Entry.second.get();
 } else if (Entry.second.is()) {
@@ -8670,15 +8677,32 @@
 
 namespace {
 
-ast_type_traits::DynTypedNode
-getSingleDynTypedNodeFromParentMap(ASTContext::ParentMap::mapped_type U) {
+ast_type_traits::DynTypedNode getSingleDynTypedNodeFromParentMap(
+ASTContext::ParentMapPointers::mapped_type U) {
   if (const auto *D = U.dyn_cast())
 return ast_type_traits::DynTypedNode::create(*D);
   if (const auto *S = U.dyn_cast())
 return ast_type_traits::DynTypedNode::create(*S);
   return *U.get();
 }
 
+/// Template specializations to abstract away from pointers and TypeLocs.
+/// @{
+template 
+ast_type_traits::DynTypedNode createDynTypedNode(const T ) {
+  return ast_type_traits::DynTypedNode::create(*Node);
+}
+template <>
+ast_type_traits::DynTypedNode createDynTypedNode(const TypeLoc ) {
+  return ast_type_traits::DynTypedNode::create(Node);
+}
+template <>
+ast_type_traits::DynTypedNode
+createDynTypedNode(const NestedNameSpecifierLoc ) {
+  return ast_type_traits::DynTypedNode::create(Node);
+}
+/// @}
+
   /// \brief A \c RecursiveASTVisitor that builds a map from nodes to their
   /// parents as defined by the \c RecursiveASTVisitor.
   ///
@@ -8693,17 +8717,21 @@
 /// \brief Builds and returns the translation unit's parent map.
 ///
 ///  The caller takes ownership of the returned \c ParentMap.
-static ASTContext::ParentMap *buildMap(TranslationUnitDecl ) {
-  ParentMapASTVisitor Visitor(new ASTContext::ParentMap);
+static std::pair
+buildMap(TranslationUnitDecl ) {
+  ParentMapASTVisitor Visitor(new ASTContext::ParentMapPointers,
+  new ASTContext::ParentMapOtherNodes);
   Visitor.TraverseDecl();
-  return Visitor.Parents;
+  return std::make_pair(Visitor.Parents, Visitor.OtherParents);
 }
 
   private:
 typedef RecursiveASTVisitor VisitorBase;
 
-ParentMapASTVisitor(ASTContext::ParentMap *Parents) : Parents(Parents) {
-}
+ParentMapASTVisitor(ASTContext::ParentMapPointers *Parents,
+ASTContext::ParentMapOtherNodes *OtherParents)
+: Parents(Parents), OtherParents(OtherParents) {}
 
 bool shouldVisitTemplateInstantiations() const {
   return true;
@@ -8717,8 +8745,9 @@
   return false;
 }
 
-template 
-bool TraverseNode(T *Node, bool(VisitorBase:: *traverse) (T *)) {
+template 
+bool TraverseNode(T Node, MapNodeTy MapNode,
+  bool (VisitorBase::*traverse)(T), MapTy *Parents) {
   if (!Node)
 return true;
   if (ParentStack.size() > 0) {
@@ -8732,7 +8761,7 @@
 // map. The main problem there is to implement hash functions /
 // comparison operators for all types that DynTypedNode supports that
 // do not have pointer identity.
-auto  = (*Parents)[Node];
+auto  = (*Parents)[MapNode];
 if (NodeOrVector.isNull()) {
   if (const auto *D = ParentStack.back().get())
 NodeOrVector = D;
@@ -8765,49 +8794,70 @@
 Vector->push_back(ParentStack.back());
 }
   }
-  ParentStack.push_back(ast_type_traits::DynTypedNode::create(*Node));
+  ParentStack.push_back(createDynTypedNode(Node));
   bool Result = (this ->* traverse) (Node);
   ParentStack.pop_back();
   return Result;
 }
 
 bool TraverseDecl(Decl *DeclNode) {
-  return TraverseNode(DeclNode, ::TraverseDecl);
+  return TraverseNode(DeclNode, DeclNode, ::TraverseDecl,
+  Parents);
 }
 
 bool 

Re: [PATCH] D10022: Refactor: Simplify boolean conditional return statements in lib/StaticAnalyzer/Core

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood added inline comments.


Comment at: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:692-693
@@ -691,4 +691,2 @@
 
   CXXBasePaths Paths(false, false, false);
-  if (RD->lookupInBases(
-  [DeclName](const CXXBaseSpecifier *Specifier, CXXBasePath ) {

In this case it isn't a simple if-return, if-return, if-return.


http://reviews.llvm.org/D10022



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


Re: [PATCH] D10014: Refactor: Simplify boolean conditional return statements in lib/Edit

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

In http://reviews.llvm.org/D10014#178294, @calabrese wrote:

> I like the idea of all of these changes (this change list and the others), 
> but just a suggestion -- it looks like when the branch of the original 
> condition returns false, as was the case in the original code here, the 
> internal expressions of the check are transformed via De Morgan's laws in the 
> new code. IMO, this transformation sometimes makes things more complicated 
> rather than less, where by "more complicated" I mean that the transformation 
> produces an overall expression that is constructed from a considerably 
> greater number of logical operations. For instance, here it changed a bunch 
> of || expressions into a bunch of && expressions, with each operand 
> individually prefixed with "!". The equivalent without having applied De 
> Morgan's laws would just have left all of the || expressions as-is and added 
> a single ! around the overall expression parenthesized. It would have also 
> looked much more similar to the original code.
>
> My general thought here is that it might make sense when performing this kind 
> of transformation to first see if the translation via De Morgan's laws 
> actually produces an overall expression that has fewer logical 
> subexpressions, otherwise prefer the minimal transformation of a ! around a 
> parenthesized expression.


This should be addressed in the latest diff.


http://reviews.llvm.org/D10014



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


Re: [PATCH] D10010: Refactor: Simplify boolean conditional return statements in lib/AST

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38321.
LegalizeAdulthood added a comment.

Update from latest.
I do not have commit access.


http://reviews.llvm.org/D10010

Files:
  lib/AST/ASTContext.cpp
  lib/AST/ASTDiagnostic.cpp
  lib/AST/Decl.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/Type.cpp

Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -1918,9 +1918,7 @@
 // CXXRecordDecl, use that one.
 RD = RD->getMostRecentDecl();
 // Nothing interesting to do if the inheritance attribute is already set.
-if (RD->hasAttr())
-  return false;
-return true;
+return !RD->hasAttr();
   }
   case ObjCObject:
 return cast(CanonicalType)->getBaseType()
@@ -2311,13 +2309,11 @@
   // Enumerated types are promotable to their compatible integer types
   // (C99 6.3.1.1) a.k.a. its underlying type (C++ [conv.prom]p2).
   if (const EnumType *ET = getAs()){
-if (this->isDependentType() || ET->getDecl()->getPromotionType().isNull()
-|| ET->getDecl()->isScoped())
-  return false;
-
-return true;
+return !(this->isDependentType() ||
+ ET->getDecl()->getPromotionType().isNull() ||
+ ET->getDecl()->isScoped());
   }
-  
+
   return false;
 }
 
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -6962,10 +6962,7 @@
   assert(E->getLHS()->getType()->isIntegralOrEnumerationType() &&
  E->getRHS()->getType()->isIntegralOrEnumerationType());
 
-  if (LHSResult.Failed && !Info.keepEvaluatingAfterFailure())
-return false; // Ignore RHS;
-
-  return true;
+  return !(LHSResult.Failed && !Info.keepEvaluatingAfterFailure());
 }
 
 bool DataRecursiveIntBinOpEvaluator::
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -3429,10 +3429,7 @@
   if (const ArraySubscriptExpr *ASE = dyn_cast(E))
 return ASE->getBase()->getType()->isVectorType();
 
-  if (isa(E))
-return true;
-
-  return false;
+  return isa(E);
 }
 
 bool Expr::refersToGlobalRegisterVar() const {
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1861,10 +1861,7 @@
   // Is it the same as our our class type?
   CanQualType ClassTy 
 = Context.getCanonicalType(Context.getTagDeclType(getParent()));
-  if (ParamType.getUnqualifiedType() != ClassTy)
-return false;
-  
-  return true;  
+  return ParamType.getUnqualifiedType() == ClassTy;
 }
 
 const CXXConstructorDecl *CXXConstructorDecl::getInheritedConstructor() const {
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -2377,9 +2377,7 @@
 return false;
   }
 
-  if (isa(S) && cast(S)->body_empty())
-return true;
-  return false;
+  return isa(S) && cast(S)->body_empty();
 }
 
 bool FunctionDecl::isDefined(const FunctionDecl *) const {
@@ -2737,10 +2735,7 @@
   if (Redecl->isImplicit())
 return false;
 
-  if (!Redecl->isInlineSpecified() || Redecl->getStorageClass() == SC_Extern) 
-return true; // Not an inline definition
-
-  return false;
+  return !Redecl->isInlineSpecified() || Redecl->getStorageClass() == SC_Extern;
 }
 
 /// \brief For a function declaration in C or C++, determine whether this
Index: lib/AST/ASTDiagnostic.cpp
===
--- lib/AST/ASTDiagnostic.cpp
+++ lib/AST/ASTDiagnostic.cpp
@@ -1032,11 +1032,7 @@
   return false;
 }
 
-if (!Default->getType()->isReferenceType()) {
-  return true;
-}
-
-return false;
+return !Default->getType()->isReferenceType();
   }
 
   /// DiffNonTypes - Handles any template parameters not handled by DiffTypes
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -6654,15 +6654,12 @@
   // equivalent GCC vector types.
   const VectorType *First = FirstVec->getAs();
   const VectorType *Second = SecondVec->getAs();
-  if (First->getNumElements() == Second->getNumElements() &&
-  hasSameType(First->getElementType(), Second->getElementType()) &&
-  First->getVectorKind() != VectorType::AltiVecPixel &&
-  First->getVectorKind() != VectorType::AltiVecBool &&
-  Second->getVectorKind() != VectorType::AltiVecPixel &&
-  Second->getVectorKind() != VectorType::AltiVecBool)
-return true;
-
-  return false;
+  return First->getNumElements() == Second->getNumElements() &&
+ hasSameType(First->getElementType(), Second->getElementType()) &&
+ First->getVectorKind() != VectorType::AltiVecPixel &&
+ First->getVectorKind() != 

Re: [PATCH] D10019: Refactor: Simplify boolean conditional return statements in lib/Sema

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38324.
LegalizeAdulthood added a comment.

Update from latest.
Update from comments.
I do not have commit access.


http://reviews.llvm.org/D10019

Files:
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaFixItUtils.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaOverload.cpp

Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -214,15 +214,12 @@
   // array-to-pointer or function-to-pointer implicit conversions, so
   // check for their presence as well as checking whether FromType is
   // a pointer.
-  if (getToType(1)->isBooleanType() &&
-  (getFromType()->isPointerType() ||
-   getFromType()->isObjCObjectPointerType() ||
-   getFromType()->isBlockPointerType() ||
-   getFromType()->isNullPtrType() ||
-   First == ICK_Array_To_Pointer || First == ICK_Function_To_Pointer))
-return true;
-
-  return false;
+  return getToType(1)->isBooleanType() &&
+ (getFromType()->isPointerType() ||
+  getFromType()->isObjCObjectPointerType() ||
+  getFromType()->isBlockPointerType() ||
+  getFromType()->isNullPtrType() || First == ICK_Array_To_Pointer ||
+  First == ICK_Function_To_Pointer);
 }
 
 /// isPointerConversionToVoidPointer - Determines whether this
@@ -1884,11 +1881,7 @@
 
   // An rvalue of type bool can be converted to an rvalue of type int,
   // with false becoming zero and true becoming one (C++ 4.5p4).
-  if (FromType->isBooleanType() && To->getKind() == BuiltinType::Int) {
-return true;
-  }
-
-  return false;
+  return FromType->isBooleanType() && To->getKind() == BuiltinType::Int;
 }
 
 /// IsFloatingPointPromotion - Determines whether the conversion from
@@ -2806,11 +2799,8 @@
 static bool isNonTrivialObjCLifetimeConversion(Qualifiers FromQuals,
Qualifiers ToQuals) {
   // Converting anything to const __unsafe_unretained is trivial.
-  if (ToQuals.hasConst() && 
-  ToQuals.getObjCLifetime() == Qualifiers::OCL_ExplicitNone)
-return false;
-
-  return true;
+  return !(ToQuals.hasConst() &&
+   ToQuals.getObjCLifetime() == Qualifiers::OCL_ExplicitNone);
 }
 
 /// IsQualificationConversion - Determines whether the conversion from
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6288,9 +6288,7 @@
 return true;
   DSAStackTy::DSAVarData DVarPrivate =
   Stack->hasDSA(VD, isOpenMPPrivate, MatchesAlways(), false);
-  if (DVarPrivate.CKind != OMPC_unknown)
-return true;
-  return false;
+  return DVarPrivate.CKind != OMPC_unknown;
 }
 return false;
   }
Index: lib/Sema/SemaFixItUtils.cpp
===
--- lib/Sema/SemaFixItUtils.cpp
+++ lib/Sema/SemaFixItUtils.cpp
@@ -42,10 +42,8 @@
   const CanQualType FromUnq = From.getUnqualifiedType();
   const CanQualType ToUnq = To.getUnqualifiedType();
 
-  if ((FromUnq == ToUnq || (S.IsDerivedFrom(FromUnq, ToUnq)) ) &&
-  To.isAtLeastAsQualifiedAs(From))
-return true;
-  return false;
+  return (FromUnq == ToUnq || (S.IsDerivedFrom(FromUnq, ToUnq))) &&
+ To.isAtLeastAsQualifiedAs(From);
 }
 
 bool ConversionFixItGenerator::tryToFixConversion(const Expr *FullExpr,
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -2314,11 +2314,9 @@
   return true;
 }
 
-if (CheckAllocationAccess(StartLoc, SourceRange(), Found.getNamingClass(),
-  Matches[0], Diagnose) == AR_inaccessible)
-  return true;
-
-return false;
+return CheckAllocationAccess(StartLoc, SourceRange(),
+ Found.getNamingClass(), Matches[0],
+ Diagnose) == AR_inaccessible;
 
   // We found multiple suitable operators;  complain about the ambiguity.
   } else if (!Matches.empty()) {
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -7716,9 +7716,7 @@
 return !S.getLangOpts().CPlusPlus;
   }
 
-  if (checkArithmeticIncompletePointerType(S, Loc, Operand)) return false;
-
-  return true;
+  return !checkArithmeticIncompletePointerType(S, Loc, Operand);
 }
 
 /// \brief Check the validity of a binary arithmetic operation w.r.t. pointer
@@ -8424,10 +8422,7 @@
 return false;
 
   QualType R = Method->getReturnType();
-  if (!R->isScalarType())
-return false;
-
-  

Re: [PATCH] D10012: Refactor: Simplify boolean conditional return statements in lib/CodeGen

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38317.
LegalizeAdulthood added a comment.

Update to latest.
I do not have commit access.


http://reviews.llvm.org/D10012

Files:
  lib/CodeGen/BranchFolding.cpp
  lib/CodeGen/CodeGenPrepare.cpp
  lib/CodeGen/LiveDebugVariables.cpp
  lib/CodeGen/MachineRegisterInfo.cpp
  lib/CodeGen/PeepholeOptimizer.cpp
  lib/CodeGen/PseudoSourceValue.cpp
  lib/CodeGen/ScheduleDAGInstrs.cpp
  lib/CodeGen/StackProtector.cpp
  lib/CodeGen/TargetInstrInfo.cpp

Index: lib/CodeGen/TargetInstrInfo.cpp
===
--- lib/CodeGen/TargetInstrInfo.cpp
+++ lib/CodeGen/TargetInstrInfo.cpp
@@ -576,10 +576,7 @@
 MI2 = MRI.getUniqueVRegDef(Op2.getReg());
 
   // And they need to be in the trace (otherwise, they won't have a depth).
-  if (MI1 && MI2 && MI1->getParent() == MBB && MI2->getParent() == MBB)
-return true;
-
-  return false;
+  return MI1 && MI2 && MI1->getParent() == MBB && MI2->getParent() == MBB;
 }
 
 bool TargetInstrInfo::hasReassociableSibling(const MachineInstr ,
@@ -600,25 +597,20 @@
   // 2. The previous instruction must have virtual register definitions for its
   //operands in the same basic block as Inst.
   // 3. The previous instruction's result must only be used by Inst.
-  if (MI1->getOpcode() == AssocOpcode && hasReassociableOperands(*MI1, MBB) &&
-  MRI.hasOneNonDBGUse(MI1->getOperand(0).getReg()))
-return true;
-
-  return false;
+  return MI1->getOpcode() == AssocOpcode &&
+ hasReassociableOperands(*MI1, MBB) &&
+ MRI.hasOneNonDBGUse(MI1->getOperand(0).getReg());
 }
 
 // 1. The operation must be associative and commutative.
 // 2. The instruction must have virtual register definitions for its
 //operands in the same basic block.
 // 3. The instruction must have a reassociable sibling.
 bool TargetInstrInfo::isReassociationCandidate(const MachineInstr ,
bool ) const {
-  if (isAssociativeAndCommutative(Inst) &&
-  hasReassociableOperands(Inst, Inst.getParent()) &&
-  hasReassociableSibling(Inst, Commuted))
-return true;
-
-  return false;
+  return isAssociativeAndCommutative(Inst) &&
+ hasReassociableOperands(Inst, Inst.getParent()) &&
+ hasReassociableSibling(Inst, Commuted);
 }
 
 // The concept of the reassociation pass is that these operations can benefit
@@ -940,10 +932,7 @@
   // modification.
   const TargetLowering  = *MF.getSubtarget().getTargetLowering();
   const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
-  if (MI->modifiesRegister(TLI.getStackPointerRegisterToSaveRestore(), TRI))
-return true;
-
-  return false;
+  return MI->modifiesRegister(TLI.getStackPointerRegisterToSaveRestore(), TRI);
 }
 
 // Provide a global flag for disabling the PreRA hazard recognizer that targets
Index: lib/CodeGen/StackProtector.cpp
===
--- lib/CodeGen/StackProtector.cpp
+++ lib/CodeGen/StackProtector.cpp
@@ -465,10 +465,7 @@
 
   // Return if we didn't modify any basic blocks. i.e., there are no return
   // statements in the function.
-  if (!HasPrologue)
-return false;
-
-  return true;
+  return HasPrologue;
 }
 
 /// CreateFailBB - Create a basic block to jump to when the stack protector
Index: lib/CodeGen/ScheduleDAGInstrs.cpp
===
--- lib/CodeGen/ScheduleDAGInstrs.cpp
+++ lib/CodeGen/ScheduleDAGInstrs.cpp
@@ -462,11 +462,9 @@
 /// Return true if MI is an instruction we are unable to reason about
 /// (like a call or something with unmodeled side effects).
 static inline bool isGlobalMemoryObject(AliasAnalysis *AA, MachineInstr *MI) {
-  if (MI->isCall() || MI->hasUnmodeledSideEffects() ||
-  (MI->hasOrderedMemoryRef() &&
-   (!MI->mayLoad() || !MI->isInvariantLoad(AA
-return true;
-  return false;
+  return MI->isCall() || MI->hasUnmodeledSideEffects() ||
+ (MI->hasOrderedMemoryRef() &&
+  (!MI->mayLoad() || !MI->isInvariantLoad(AA)));
 }
 
 // This MI might have either incomplete info, or known to be unsafe
Index: lib/CodeGen/PseudoSourceValue.cpp
===
--- lib/CodeGen/PseudoSourceValue.cpp
+++ lib/CodeGen/PseudoSourceValue.cpp
@@ -50,9 +50,7 @@
 }
 
 bool PseudoSourceValue::mayAlias(const MachineFrameInfo *) const {
-  if (isGOT() || isConstantPool() || isJumpTable())
-return false;
-  return true;
+  return !(isGOT() || isConstantPool() || isJumpTable());
 }
 
 bool FixedStackPseudoSourceValue::isConstant(
Index: lib/CodeGen/PeepholeOptimizer.cpp
===
--- lib/CodeGen/PeepholeOptimizer.cpp
+++ lib/CodeGen/PeepholeOptimizer.cpp
@@ -686,10 +686,7 @@
   }
 
   // If we did not find a more suitable source, there is nothing to optimize.
-  if (CurSrcPair.Reg == Reg)
-return 

Re: [PATCH] D10011: Refactor: Simplify boolean conditional return statements in lib/Basic

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38318.
LegalizeAdulthood added a comment.

Update to latest.
I do not have commit access.


http://reviews.llvm.org/D10011

Files:
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2704,22 +2704,22 @@
 
   // Enable popcnt if sse4.2 is enabled and popcnt is not explicitly disabled.
   auto I = Features.find("sse4.2");
-  if (I != Features.end() && I->getValue() == true &&
+  if (I != Features.end() && I->getValue() &&
   std::find(FeaturesVec.begin(), FeaturesVec.end(), "-popcnt") ==
   FeaturesVec.end())
 Features["popcnt"] = true;
 
   // Enable prfchw if 3DNow! is enabled and prfchw is not explicitly disabled.
   I = Features.find("3dnow");
-  if (I != Features.end() && I->getValue() == true &&
+  if (I != Features.end() && I->getValue() &&
   std::find(FeaturesVec.begin(), FeaturesVec.end(), "-prfchw") ==
   FeaturesVec.end())
 Features["prfchw"] = true;
 
   // Additionally, if SSE is enabled and mmx is not explicitly disabled,
   // then enable MMX.
   I = Features.find("sse");
-  if (I != Features.end() && I->getValue() == true &&
+  if (I != Features.end() && I->getValue() &&
   std::find(FeaturesVec.begin(), FeaturesVec.end(), "-mmx") ==
   FeaturesVec.end())
 Features["mmx"] = true;


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2704,22 +2704,22 @@
 
   // Enable popcnt if sse4.2 is enabled and popcnt is not explicitly disabled.
   auto I = Features.find("sse4.2");
-  if (I != Features.end() && I->getValue() == true &&
+  if (I != Features.end() && I->getValue() &&
   std::find(FeaturesVec.begin(), FeaturesVec.end(), "-popcnt") ==
   FeaturesVec.end())
 Features["popcnt"] = true;
 
   // Enable prfchw if 3DNow! is enabled and prfchw is not explicitly disabled.
   I = Features.find("3dnow");
-  if (I != Features.end() && I->getValue() == true &&
+  if (I != Features.end() && I->getValue() &&
   std::find(FeaturesVec.begin(), FeaturesVec.end(), "-prfchw") ==
   FeaturesVec.end())
 Features["prfchw"] = true;
 
   // Additionally, if SSE is enabled and mmx is not explicitly disabled,
   // then enable MMX.
   I = Features.find("sse");
-  if (I != Features.end() && I->getValue() == true &&
+  if (I != Features.end() && I->getValue() &&
   std::find(FeaturesVec.begin(), FeaturesVec.end(), "-mmx") ==
   FeaturesVec.end())
 Features["mmx"] = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10022: Refactor: Simplify boolean conditional return statements in lib/StaticAnalyzer/Core

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38319.
LegalizeAdulthood added a comment.

Update from latest


http://reviews.llvm.org/D10022

Files:
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp
  lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -493,9 +493,7 @@
   if (LCtx != ELCtx) {
 // If the reaper's location context is a parent of the expression's
 // location context, then the expression value is now "out of scope".
-if (LCtx->isParentOf(ELCtx))
-  return false;
-return true;
+return !LCtx->isParentOf(ELCtx);
   }
 
   // If no statement is provided, everything is this and parent contexts is 
live.
Index: lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -394,10 +394,7 @@
   if (ToTy->isVoidType())
 return true;
 
-  if (ToTy != FromTy)
-return false;
-
-  return true;
+  return ToTy == FromTy;
 }
 
 // FIXME: should rewrite according to the cast kind.
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -690,14 +690,11 @@
 return true;
 
   CXXBasePaths Paths(false, false, false);
-  if (RD->lookupInBases(
-  [DeclName](const CXXBaseSpecifier *Specifier, CXXBasePath ) {
-return CXXRecordDecl::FindOrdinaryMember(Specifier, Path, 
DeclName);
-  },
-  Paths))
-return true;
-
-  return false;
+  return RD->lookupInBases(
+  [DeclName](const CXXBaseSpecifier *Specifier, CXXBasePath ) {
+return CXXRecordDecl::FindOrdinaryMember(Specifier, Path, DeclName);
+  },
+  Paths);
 }
 
 /// Returns true if the given C++ class is a container or iterator.


Index: lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -493,9 +493,7 @@
   if (LCtx != ELCtx) {
 // If the reaper's location context is a parent of the expression's
 // location context, then the expression value is now "out of scope".
-if (LCtx->isParentOf(ELCtx))
-  return false;
-return true;
+return !LCtx->isParentOf(ELCtx);
   }
 
   // If no statement is provided, everything is this and parent contexts is live.
Index: lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -394,10 +394,7 @@
   if (ToTy->isVoidType())
 return true;
 
-  if (ToTy != FromTy)
-return false;
-
-  return true;
+  return ToTy == FromTy;
 }
 
 // FIXME: should rewrite according to the cast kind.
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -690,14 +690,11 @@
 return true;
 
   CXXBasePaths Paths(false, false, false);
-  if (RD->lookupInBases(
-  [DeclName](const CXXBaseSpecifier *Specifier, CXXBasePath ) {
-return CXXRecordDecl::FindOrdinaryMember(Specifier, Path, DeclName);
-  },
-  Paths))
-return true;
-
-  return false;
+  return RD->lookupInBases(
+  [DeclName](const CXXBaseSpecifier *Specifier, CXXBasePath ) {
+return CXXRecordDecl::FindOrdinaryMember(Specifier, Path, DeclName);
+  },
+  Paths);
 }
 
 /// Returns true if the given C++ class is a container or iterator.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10014: Refactor: Simplify boolean conditional return statements in lib/Edit

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38323.
LegalizeAdulthood added a comment.

Update from latest.
I do not have commit access.


http://reviews.llvm.org/D10014

Files:
  lib/Edit/RewriteObjCFoundationAPI.cpp

Index: lib/Edit/RewriteObjCFoundationAPI.cpp
===
--- lib/Edit/RewriteObjCFoundationAPI.cpp
+++ lib/Edit/RewriteObjCFoundationAPI.cpp
@@ -888,53 +888,29 @@
 // make it broadly available.
 static bool subscriptOperatorNeedsParens(const Expr *FullExpr) {
   const Expr* Expr = FullExpr->IgnoreImpCasts();
-  if (isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(FullExpr) ||
-  isa(Expr) ||
-  isa(Expr))
-return false;
-
-  return true;
+  return !(isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(FullExpr) ||
+   isa(Expr) || isa(Expr));
 }
 static bool castOperatorNeedsParens(const Expr *FullExpr) {
   const Expr* Expr = FullExpr->IgnoreImpCasts();
-  if (isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(FullExpr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr))
-return false;
-
-  return true;
+  return !(isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(FullExpr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr));
 }
 
 static void objectifyExpr(const Expr *E, Commit ) {


Index: lib/Edit/RewriteObjCFoundationAPI.cpp
===
--- lib/Edit/RewriteObjCFoundationAPI.cpp
+++ lib/Edit/RewriteObjCFoundationAPI.cpp
@@ -888,53 +888,29 @@
 // make it broadly available.
 static bool subscriptOperatorNeedsParens(const Expr *FullExpr) {
   const Expr* Expr = FullExpr->IgnoreImpCasts();
-  if (isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(FullExpr) ||
-  isa(Expr) ||
-  isa(Expr))
-return false;
-
-  return true;
+  return !(isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(FullExpr) ||
+   isa(Expr) || isa(Expr));
 }
 static bool castOperatorNeedsParens(const Expr *FullExpr) {
   const Expr* Expr = FullExpr->IgnoreImpCasts();
-  if (isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(FullExpr) ||
-  isa(Expr) ||
-  isa(Expr) ||
-  isa(Expr))
-return false;
-
-  return true;
+  return !(isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr) || isa(FullExpr) ||
+   isa(Expr) || isa(Expr) ||
+   isa(Expr));
 }
 
 static void objectifyExpr(const Expr *E, Commit ) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10017: Refactor: Simplify boolean conditional return statements in lib/Lex

2015-10-24 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 38322.
LegalizeAdulthood added a comment.

Update to latest.
I do not have commit access.


http://reviews.llvm.org/D10017

Files:
  lib/Lex/PPDirectives.cpp
  lib/Lex/PPMacroExpansion.cpp

Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -597,9 +597,7 @@
   Brackets.pop_back();
 }
   }
-  if (!Brackets.empty())
-return false;
-  return true;
+  return Brackets.empty();
 }
 
 /// GenerateNewArgTokens - Returns true if OldTokens can be converted to a new
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -2045,13 +2045,9 @@
   }
 
   // #define inline
-  if (MacroName.isOneOf(tok::kw_extern, tok::kw_inline, tok::kw_static,
-tok::kw_const) &&
-  MI->getNumTokens() == 0) {
-return true;
-  }
-
-  return false;
+  return MacroName.isOneOf(tok::kw_extern, tok::kw_inline, tok::kw_static,
+   tok::kw_const) &&
+ MI->getNumTokens() == 0;
 }
 
 /// HandleDefineDirective - Implements \#define.  This consumes the entire 
macro


Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -597,9 +597,7 @@
   Brackets.pop_back();
 }
   }
-  if (!Brackets.empty())
-return false;
-  return true;
+  return Brackets.empty();
 }
 
 /// GenerateNewArgTokens - Returns true if OldTokens can be converted to a new
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -2045,13 +2045,9 @@
   }
 
   // #define inline
-  if (MacroName.isOneOf(tok::kw_extern, tok::kw_inline, tok::kw_static,
-tok::kw_const) &&
-  MI->getNumTokens() == 0) {
-return true;
-  }
-
-  return false;
+  return MacroName.isOneOf(tok::kw_extern, tok::kw_inline, tok::kw_static,
+   tok::kw_const) &&
+ MI->getNumTokens() == 0;
 }
 
 /// HandleDefineDirective - Implements \#define.  This consumes the entire macro
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13946: Shrink DynTypedNode by one pointer from 40 to 32 bytes (on x86_64).

2015-10-21 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250905: Shrink DynTypedNode by one pointer from 40 to 32 
bytes (on x86_64). (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D13946?vs=38023=38024#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13946

Files:
  cfe/trunk/include/clang/AST/ASTTypeTraits.h
  cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Index: cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -455,8 +455,8 @@
   // Polymorphic.
   EXPECT_TRUE(hasCompletion(
   Comps, "hasDescendant(",
-  "Matcher "
-  "hasDescendant(Matcher"
+  " hasDescendant(Matcher)"));
 
   CompVector WhileComps = getCompletions("whileStmt", 0);
Index: cfe/trunk/include/clang/AST/ASTTypeTraits.h
===
--- cfe/trunk/include/clang/AST/ASTTypeTraits.h
+++ cfe/trunk/include/clang/AST/ASTTypeTraits.h
@@ -106,18 +106,25 @@
 }
   };
 
+  /// Check if the given ASTNodeKind identifies a type that offers pointer
+  /// identity. This is useful for the fast path in DynTypedNode.
+  bool hasPointerIdentity() const {
+return KindId > NKI_LastKindWithoutPointerIdentity;
+  }
+
 private:
   /// \brief Kind ids.
   ///
   /// Includes all possible base and derived kinds.
   enum NodeKindId {
 NKI_None,
-NKI_CXXCtorInitializer,
 NKI_TemplateArgument,
-NKI_NestedNameSpecifier,
 NKI_NestedNameSpecifierLoc,
 NKI_QualType,
 NKI_TypeLoc,
+NKI_LastKindWithoutPointerIdentity = NKI_TypeLoc,
+NKI_CXXCtorInitializer,
+NKI_NestedNameSpecifier,
 NKI_Decl,
 #define DECL(DERIVED, BASE) NKI_##DERIVED##Decl,
 #include "clang/AST/DeclNodes.inc"
@@ -238,7 +245,11 @@
   /// Note that this is not supported by all AST nodes. For AST nodes
   /// that don't have a pointer-defined identity inside the AST, this
   /// method returns NULL.
-  const void *getMemoizationData() const { return MemoizationData; }
+  const void *getMemoizationData() const {
+return NodeKind.hasPointerIdentity()
+   ? *reinterpret_cast(Storage.buffer)
+   : nullptr;
+  }
 
   /// \brief Prints the node to the given output stream.
   void print(llvm::raw_ostream , const PrintingPolicy ) const;
@@ -286,38 +297,38 @@
   template  struct DynCastPtrConverter {
 static const T *get(ASTNodeKind NodeKind, const char Storage[]) {
   if (ASTNodeKind::getFromNodeKind().isBaseOf(NodeKind))
-return cast(*reinterpret_cast(Storage));
+return (NodeKind, Storage);
   return nullptr;
 }
 static const T (ASTNodeKind NodeKind, const char Storage[]) {
   assert(ASTNodeKind::getFromNodeKind().isBaseOf(NodeKind));
-  return *cast(*reinterpret_cast(Storage));
+  return *cast(static_cast(
+  *reinterpret_cast(Storage)));
 }
 static DynTypedNode create(const BaseT ) {
   DynTypedNode Result;
   Result.NodeKind = ASTNodeKind::getFromNode(Node);
-  Result.MemoizationData = 
-  new (Result.Storage.buffer) const BaseT * ();
+  new (Result.Storage.buffer) const void *();
   return Result;
 }
   };
 
   /// \brief Converter that stores T* (by pointer).
   template  struct PtrConverter {
 static const T *get(ASTNodeKind NodeKind, const char Storage[]) {
   if (ASTNodeKind::getFromNodeKind().isSame(NodeKind))
-return *reinterpret_cast(Storage);
+return (NodeKind, Storage);
   return nullptr;
 }
 static const T (ASTNodeKind NodeKind, const char Storage[]) {
   assert(ASTNodeKind::getFromNodeKind().isSame(NodeKind));
-  return **reinterpret_cast(Storage);
+  return *static_cast(
+  *reinterpret_cast(Storage));
 }
 static DynTypedNode create(const T ) {
   DynTypedNode Result;
   Result.NodeKind = ASTNodeKind::getFromNodeKind();
-  Result.MemoizationData = 
-  new (Result.Storage.buffer) const T * ();
+  new (Result.Storage.buffer) const void *();
   return Result;
 }
   };
@@ -336,14 +347,12 @@
 static DynTypedNode create(const T ) {
   DynTypedNode Result;
   Result.NodeKind = ASTNodeKind::getFromNodeKind();
-  Result.MemoizationData = nullptr;
   new (Result.Storage.buffer) T(Node);
   return Result;
 }
   };
 
   ASTNodeKind NodeKind;
-  const void *MemoizationData;
 
   /// \brief Stores the data of the node.
   ///
@@ -353,12 +362,9 @@
   /// \c QualTypes, \c NestedNameSpecifierLocs, \c TypeLocs and
   /// \c TemplateArguments 

Re: [PATCH] D13976: [AST] Store Decl* and Stmt* directly into the ParentMap.

2015-10-22 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251008: [AST] Store Decl* and Stmt* directly into the 
ParentMap. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D13976?vs=38105=38110#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13976

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/lib/AST/ASTContext.cpp

Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -797,8 +797,7 @@
   for (const auto  : *AllParents) {
 if (Entry.second.is()) {
   delete Entry.second.get();
-} else {
-  assert(Entry.second.is());
+} else if (Entry.second.is()) {
   delete Entry.second.get();
 }
   }
@@ -8673,6 +8672,15 @@
 
 namespace {
 
+ast_type_traits::DynTypedNode
+getSingleDynTypedNodeFromParentMap(ASTContext::ParentMap::mapped_type U) {
+  if (const auto *D = U.template dyn_cast())
+return ast_type_traits::DynTypedNode::create(*D);
+  if (const auto *S = U.template dyn_cast())
+return ast_type_traits::DynTypedNode::create(*S);
+  return *U.template get();
+}
+
   /// \brief A \c RecursiveASTVisitor that builds a map from nodes to their
   /// parents as defined by the \c RecursiveASTVisitor.
   ///
@@ -8728,16 +8736,23 @@
 // do not have pointer identity.
 auto  = (*Parents)[Node];
 if (NodeOrVector.isNull()) {
-  NodeOrVector = new ast_type_traits::DynTypedNode(ParentStack.back());
+  if (const auto *D = ParentStack.back().get())
+NodeOrVector = D;
+  else if (const auto *S = ParentStack.back().get())
+NodeOrVector = S;
+  else
+NodeOrVector =
+new ast_type_traits::DynTypedNode(ParentStack.back());
 } else {
-  if (NodeOrVector.template is()) {
-auto *Node =
-NodeOrVector.template get();
-auto *Vector = new ASTContext::ParentVector(1, *Node);
+  if (!NodeOrVector.template is()) {
+auto *Vector = new ASTContext::ParentVector(
+1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
 NodeOrVector = Vector;
-delete Node;
+if (auto *Node =
+NodeOrVector
+.template dyn_cast())
+  delete Node;
   }
-  assert(NodeOrVector.template is());
 
   auto *Vector =
   NodeOrVector.template get();
@@ -8774,7 +8789,7 @@
 
 } // end namespace
 
-ArrayRef
+ASTContext::DynTypedNodeList
 ASTContext::getParents(const ast_type_traits::DynTypedNode ) {
   assert(Node.getMemoizationData() &&
  "Invariant broken: only nodes that support memoization may be "
@@ -8787,12 +8802,12 @@
   }
   ParentMap::const_iterator I = AllParents->find(Node.getMemoizationData());
   if (I == AllParents->end()) {
-return None;
+return llvm::ArrayRef();
   }
-  if (auto *N = I->second.dyn_cast()) {
-return llvm::makeArrayRef(N, 1);
+  if (auto *V = I->second.dyn_cast()) {
+return llvm::makeArrayRef(*V);
   }
-  return *I->second.get();
+  return getSingleDynTypedNodeFromParentMap(I->second);
 }
 
 bool
Index: cfe/trunk/include/clang/AST/ASTContext.h
===
--- cfe/trunk/include/clang/AST/ASTContext.h
+++ cfe/trunk/include/clang/AST/ASTContext.h
@@ -453,8 +453,47 @@
 
   /// \brief Maps from a node to its parents.
   typedef llvm::DenseMap> ParentMap;
+ llvm::PointerUnion4> ParentMap;
+
+  /// Container for either a single DynTypedNode or for an ArrayRef to
+  /// DynTypedNode. For use with ParentMap.
+  class DynTypedNodeList {
+typedef ast_type_traits::DynTypedNode DynTypedNode;
+llvm::AlignedCharArrayUnion Storage;
+bool IsSingleNode;
+
+  public:
+DynTypedNodeList(const DynTypedNode ) : IsSingleNode(true) {
+  new (Storage.buffer) DynTypedNode(N);
+}
+DynTypedNodeList(ArrayRef A) : IsSingleNode(false) {
+  new (Storage.buffer) ArrayRef(A);
+}
+
+const ast_type_traits::DynTypedNode *begin() const {
+  if (!IsSingleNode)
+return reinterpret_cast *>(Storage.buffer)
+->begin();
+  return reinterpret_cast(Storage.buffer);
+}
+
+const ast_type_traits::DynTypedNode *end() const {
+  if (!IsSingleNode)
+return reinterpret_cast *>(Storage.buffer)
+->end();
+  return reinterpret_cast(Storage.buffer) + 1;
+}
+
+size_t size() const { return end() - begin(); }
+bool empty() const { return begin() == end(); }
+const DynTypedNode [](size_t N) const {
+  assert(N < size() && "Out of bounds!");
+  return *(begin() + N);
+}
+  };
 
   /// \brief Returns the parents of the given node.
   ///
@@ 

Re: [PATCH] D13203: [Clang] - Massaging code to fix MSVS 2015 win32-release configuration

2015-10-27 Thread Will Wilson via cfe-commits
Building latest HEAD using:

cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
-DLLVM_USE_CRT_RELWITHDEBINFO=MT -DLLVM_BUILD_TOOLS=OFF
-DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_ENABLE_ASSERTIONS=OFF
LLVM_BUILD_32_BITS=ON ..\llvm


VC++ version: Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026
for x86

Also produces the ICE mentioned before by grimar:

[1003/1049] Building CXX object
tools\...eFiles\clangAST.dir\ASTContext.cpp.obj
FAILED: C:\PROGRA~2\MI0E91~1.0\VC\bin\cl.exe   /nologo /TP /DWIN32
/D_WINDOWS -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345
-wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722
-wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245
-wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577
-wd4091 -wd4324 -w14062 -we4238 /W4 /Zc:inline /Zc:sizedDealloc- /MT /Zi
/O2 /Ob1 /D NDEBUG -Itools\clang\lib\AST -IW:\rec\llvm\tools\clang\lib\AST
-IW:\rec\llvm\tools\clang\include -Itools\clang\include -Iinclude
-IW:\rec\llvm\include /EHs-c- /GR- /showIncludes -DCLANG_ENABLE_ARCMT
-DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER
-DGTEST_HAS_RTTI=0 -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE
-D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
/Fotools\clang\lib\AST\CMakeFiles\clangAST.dir\ASTContext.cpp.obj
/Fdtools\clang\lib\AST\CMakeFiles\clangAST.dir\ /FS -c
W:\rec\llvm\tools\clang\lib\AST\ASTContext.cpp
w:\rec\llvm\tools\clang\lib\ast\astcontext.cpp(334) : fatal error C1001: An
internal error has occurred in the compiler.
(compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 246)
 To work around this problem, try simplifying or changing the program near
the locations listed above.
Please choose the Technical Support command on the Visual C++
 Help menu, or open the Technical Support help file for more information

INTERNAL COMPILER ERROR in 'C:\PROGRA~2\MI0E91~1.0\VC\bin\cl.exe'
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information


Did anyone find a non-invasive workaround or is the patch still the way to
go?

Thanks,
Will.

On 5 October 2015 at 13:39, Manuel Klimek via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> klimek added a comment.
>
> Note: with VS Professional 14.0.23107.0 D14REL I do not get this error.
>
>
> http://reviews.llvm.org/D13203
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>



-- 
*Indefiant *: http://www.indefiant.com
Home of Recode : Runtime C++ Editing for VS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13203: [Clang] - Massaging code to fix MSVS 2015 win32-release configuration

2015-10-27 Thread Will Wilson via cfe-commits
I've ended up using the simplified fix described on the MS connect bug
report for this issue:

https://connect.microsoft.com/VisualStudio/feedback/details/1741530

I’ve been able to work around this by changing ASTContext.cpp:368 from

if (RC) {
Raw.setRaw(RC);
Raw.setKind(RawCommentAndCacheFlags::FromDecl);
} else

to

if (RC) {
Raw.setKind(RawCommentAndCacheFlags::FromDecl);
Raw.setRaw(RC);
} else


Since this simply swaps two orthogonal calls I've checked it passes the
tests and attached the patch.

Let me know if it's okay to commit.

Thanks,
Will.

On 27 October 2015 at 11:42, Will Wilson <w...@indefiant.com> wrote:

> Building latest HEAD using:
>
> cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
> -DLLVM_USE_CRT_RELWITHDEBINFO=MT -DLLVM_BUILD_TOOLS=OFF
> -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_ENABLE_ASSERTIONS=OFF
> LLVM_BUILD_32_BITS=ON ..\llvm
>
>
> VC++ version: Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026
> for x86
>
> Also produces the ICE mentioned before by grimar:
>
> [1003/1049] Building CXX object
> tools\...eFiles\clangAST.dir\ASTContext.cpp.obj
> FAILED: C:\PROGRA~2\MI0E91~1.0\VC\bin\cl.exe   /nologo /TP /DWIN32
> /D_WINDOWS -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345
> -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722
> -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245
> -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577
> -wd4091 -wd4324 -w14062 -we4238 /W4 /Zc:inline /Zc:sizedDealloc- /MT /Zi
> /O2 /Ob1 /D NDEBUG -Itools\clang\lib\AST -IW:\rec\llvm\tools\clang\lib\AST
> -IW:\rec\llvm\tools\clang\include -Itools\clang\include -Iinclude
> -IW:\rec\llvm\include /EHs-c- /GR- /showIncludes -DCLANG_ENABLE_ARCMT
> -DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER
> -DGTEST_HAS_RTTI=0 -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE
> -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> /Fotools\clang\lib\AST\CMakeFiles\clangAST.dir\ASTContext.cpp.obj
> /Fdtools\clang\lib\AST\CMakeFiles\clangAST.dir\ /FS -c
> W:\rec\llvm\tools\clang\lib\AST\ASTContext.cpp
> w:\rec\llvm\tools\clang\lib\ast\astcontext.cpp(334) : fatal error C1001:
> An internal error has occurred in the compiler.
> (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 246)
>  To work around this problem, try simplifying or changing the program near
> the locations listed above.
> Please choose the Technical Support command on the Visual C++
>  Help menu, or open the Technical Support help file for more information
>
> INTERNAL COMPILER ERROR in 'C:\PROGRA~2\MI0E91~1.0\VC\bin\cl.exe'
> Please choose the Technical Support command on the Visual C++
> Help menu, or open the Technical Support help file for more information
>
>
> Did anyone find a non-invasive workaround or is the patch still the way to
> go?
>
> Thanks,
> Will.
>
> On 5 October 2015 at 13:39, Manuel Klimek via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> klimek added a comment.
>>
>> Note: with VS Professional 14.0.23107.0 D14REL I do not get this error.
>>
>>
>> http://reviews.llvm.org/D13203
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
>
> --
> *Indefiant *: http://www.indefiant.com
> Home of Recode : Runtime C++ Editing for VS
>



-- 
*Indefiant *: http://www.indefiant.com
Home of Recode : Runtime C++ Editing for VS


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


r251415 - [MSVC] Workaround for ICE in cl.exe when compiling ASTContext.cpp in Release Win32

2015-10-27 Thread Will Wilson via cfe-commits
Author: lantictac
Date: Tue Oct 27 12:01:10 2015
New Revision: 251415

URL: http://llvm.org/viewvc/llvm-project?rev=251415=rev
Log:
[MSVC] Workaround for ICE in cl.exe when compiling ASTContext.cpp in Release 
Win32

Microsoft connect bug: 
https://connect.microsoft.com/VisualStudio/feedback/details/1741530

Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=251415=251414=251415=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Oct 27 12:01:10 2015
@@ -366,8 +366,10 @@ const RawComment *ASTContext::getRawComm
   OriginalDeclForRC = I;
   RawCommentAndCacheFlags Raw;
   if (RC) {
-Raw.setRaw(RC);
+// Call order swapped to work around ICE in VS2015 RTM (Release Win32)
+// https://connect.microsoft.com/VisualStudio/feedback/details/1741530
 Raw.setKind(RawCommentAndCacheFlags::FromDecl);
+Raw.setRaw(RC);
   } else
 Raw.setKind(RawCommentAndCacheFlags::NoCommentInDecl);
   Raw.setOriginalDecl(I);


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


Re: [PATCH] D13203: [Clang] - Massaging code to fix MSVS 2015 win32-release configuration

2015-10-27 Thread Will Wilson via cfe-commits
Thanks David,

Committed as r251415.

On 27 October 2015 at 17:01, David Majnemer <david.majne...@gmail.com>
wrote:

> Looks fine Will, please commit but keep a comment and a link to the
> connect bug.  We don't want somebody to accidentally "clean-up" the code
> and break things again.
>
> On Tue, Oct 27, 2015 at 7:49 AM, Will Wilson via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> I've ended up using the simplified fix described on the MS connect bug
>> report for this issue:
>>
>> https://connect.microsoft.com/VisualStudio/feedback/details/1741530
>>
>> I’ve been able to work around this by changing ASTContext.cpp:368 from
>>
>> if (RC) {
>> Raw.setRaw(RC);
>> Raw.setKind(RawCommentAndCacheFlags::FromDecl);
>> } else
>>
>> to
>>
>> if (RC) {
>> Raw.setKind(RawCommentAndCacheFlags::FromDecl);
>> Raw.setRaw(RC);
>> } else
>>
>>
>> Since this simply swaps two orthogonal calls I've checked it passes the
>> tests and attached the patch.
>>
>> Let me know if it's okay to commit.
>>
>> Thanks,
>> Will.
>>
>> On 27 October 2015 at 11:42, Will Wilson <w...@indefiant.com> wrote:
>>
>>> Building latest HEAD using:
>>>
>>> cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
>>> -DLLVM_USE_CRT_RELWITHDEBINFO=MT -DLLVM_BUILD_TOOLS=OFF
>>> -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_ENABLE_ASSERTIONS=OFF
>>> LLVM_BUILD_32_BITS=ON ..\llvm
>>>
>>>
>>> VC++ version: Microsoft (R) C/C++ Optimizing Compiler Version
>>> 19.00.23026 for x86
>>>
>>> Also produces the ICE mentioned before by grimar:
>>>
>>> [1003/1049] Building CXX object
>>> tools\...eFiles\clangAST.dir\ASTContext.cpp.obj
>>> FAILED: C:\PROGRA~2\MI0E91~1.0\VC\bin\cl.exe   /nologo /TP /DWIN32
>>> /D_WINDOWS -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345
>>> -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722
>>> -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245
>>> -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577
>>> -wd4091 -wd4324 -w14062 -we4238 /W4 /Zc:inline /Zc:sizedDealloc- /MT /Zi
>>> /O2 /Ob1 /D NDEBUG -Itools\clang\lib\AST -IW:\rec\llvm\tools\clang\lib\AST
>>> -IW:\rec\llvm\tools\clang\include -Itools\clang\include -Iinclude
>>> -IW:\rec\llvm\include /EHs-c- /GR- /showIncludes -DCLANG_ENABLE_ARCMT
>>> -DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER
>>> -DGTEST_HAS_RTTI=0 -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
>>> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE
>>> -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
>>> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
>>> /Fotools\clang\lib\AST\CMakeFiles\clangAST.dir\ASTContext.cpp.obj
>>> /Fdtools\clang\lib\AST\CMakeFiles\clangAST.dir\ /FS -c
>>> W:\rec\llvm\tools\clang\lib\AST\ASTContext.cpp
>>> w:\rec\llvm\tools\clang\lib\ast\astcontext.cpp(334) : fatal error C1001:
>>> An internal error has occurred in the compiler.
>>> (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 246)
>>>  To work around this problem, try simplifying or changing the program
>>> near the locations listed above.
>>> Please choose the Technical Support command on the Visual C++
>>>  Help menu, or open the Technical Support help file for more information
>>>
>>> INTERNAL COMPILER ERROR in 'C:\PROGRA~2\MI0E91~1.0\VC\bin\cl.exe'
>>> Please choose the Technical Support command on the Visual C++
>>> Help menu, or open the Technical Support help file for more
>>> information
>>>
>>>
>>> Did anyone find a non-invasive workaround or is the patch still the way
>>> to go?
>>>
>>> Thanks,
>>> Will.
>>>
>>> On 5 October 2015 at 13:39, Manuel Klimek via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>> klimek added a comment.
>>>>
>>>> Note: with VS Professional 14.0.23107.0 D14REL I do not get this error.
>>>>
>>>>
>>>> http://reviews.llvm.org/D13203
>>>>
>>>>
>>>>
>>>> ___
>>>> cfe-commits mailing list
>>>> cfe-commits@lists.llvm.org
>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>>
>>>
>>>
>>>
>>> --
>>> *Indefiant *: http://www.indefiant.com
>>> Home of Recode : Runtime C++ Editing for VS
>>>
>>
>>
>>
>> --
>> *Indefiant *: http://www.indefiant.com
>> Home of Recode : Runtime C++ Editing for VS
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>


-- 
*Indefiant *: http://www.indefiant.com
Home of Recode : Runtime C++ Editing for VS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D7639: Add readability-redundant-void-arg check to clang-tidy

2015-10-27 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

In http://reviews.llvm.org/D7639#275504, @sbenza wrote:

> Just fyi, I am looking at this diff. It is very large with a lot of rounds of 
> comments and I didn't have the context.
>  I don't know if I should giving comments at this point of the change, but 
> here it is.
>  Have you considered matching on typeLoc() instead of having a large list of 
> different cases?
>  For example, if you match `typeLoc(loc(functionType()))` it will match all 
> the places where a function type is mentioned, including things like 
> `static_cast`, variable declarations, lambda return type declarations, 
> etc. Might help remove redundancy in the check.


That occurred to me and I did an experiment and it didn't work out.  I forget 
the exact details now as it was months ago and this review has been sitting 
here languishing with a correct implementation as-is.  I really just want to 
get this committed and make incremental improvement, instead of re-evaluating 
the entire thing from scratch at this time.


http://reviews.llvm.org/D7639



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


Re: [PATCH] D7639: Add readability-redundant-void-arg check to clang-tidy

2015-10-27 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

I mean, look at this review.  I created it on Feb 13th 2015.  It's been getting 
ground through the review process for 8 months.  Why can't we move forward?


http://reviews.llvm.org/D7639



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


Re: [PATCH] D7639: Add readability-redundant-void-arg check to clang-tidy

2015-10-23 Thread Richard via cfe-commits
LegalizeAdulthood marked 17 inline comments as done.
LegalizeAdulthood added a comment.

Can we get this committed?  I've addressed all comments.


http://reviews.llvm.org/D7639



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


Re: [PATCH] D13931: [Tooling] Add a utility function to replace one nested name with another.

2015-10-22 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251022: [Tooling] Add a utility function to replace one 
nested name with another. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D13931?vs=38130=38131#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13931

Files:
  cfe/trunk/include/clang/Tooling/Core/Lookup.h
  cfe/trunk/lib/Tooling/Core/CMakeLists.txt
  cfe/trunk/lib/Tooling/Core/Lookup.cpp
  cfe/trunk/unittests/Tooling/CMakeLists.txt
  cfe/trunk/unittests/Tooling/LookupTest.cpp

Index: cfe/trunk/unittests/Tooling/CMakeLists.txt
===
--- cfe/trunk/unittests/Tooling/CMakeLists.txt
+++ cfe/trunk/unittests/Tooling/CMakeLists.txt
@@ -6,6 +6,7 @@
 add_clang_unittest(ToolingTests
   CommentHandlerTest.cpp
   CompilationDatabaseTest.cpp
+  LookupTest.cpp
   ToolingTest.cpp
   RecursiveASTVisitorTest.cpp
   RecursiveASTVisitorTestCallVisitor.cpp
Index: cfe/trunk/unittests/Tooling/LookupTest.cpp
===
--- cfe/trunk/unittests/Tooling/LookupTest.cpp
+++ cfe/trunk/unittests/Tooling/LookupTest.cpp
@@ -0,0 +1,108 @@
+//===- unittest/Tooling/LookupTest.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TestVisitor.h"
+#include "clang/Tooling/Core/Lookup.h"
+using namespace clang;
+
+namespace {
+struct GetDeclsVisitor : TestVisitor {
+  std::function OnCall;
+  SmallVector DeclStack;
+
+  bool VisitCallExpr(CallExpr *Expr) {
+OnCall(Expr);
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) {
+DeclStack.push_back(D);
+bool Ret = TestVisitor::TraverseDecl(D);
+DeclStack.pop_back();
+return Ret;
+  }
+};
+
+TEST(LookupTest, replaceNestedName) {
+  GetDeclsVisitor Visitor;
+
+  auto replaceCallExpr = [&](const CallExpr *Expr,
+ StringRef ReplacementString) {
+const auto *Callee = cast(Expr->getCallee()->IgnoreImplicit());
+const ValueDecl *FD = Callee->getDecl();
+return tooling::replaceNestedName(
+Callee->getQualifier(), Visitor.DeclStack.back()->getDeclContext(), FD,
+ReplacementString);
+  };
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace a { void f() { foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace a { void f() { foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace b { void f() { a::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\n"
+  "namespace b { namespace a { void foo(); }\n"
+  "void f() { a::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("c::bar", replaceCallExpr(Expr, "::a::c::bar"));
+  };
+  Visitor.runOver("namespace a { namespace b { void foo(); }\n"
+  "void f() { b::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { namespace b { void foo(); }\n"
+  "void f() { b::foo(); } }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::bar"));
+  };
+  Visitor.runOver("void foo(); void f() { foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("::bar", replaceCallExpr(Expr, "::bar"));
+  };
+  Visitor.runOver("void foo(); void f() { ::foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { void foo(); }\nvoid f() { a::foo(); }\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver("namespace a { int foo(); }\nauto f = a::foo();\n");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("bar", replaceCallExpr(Expr, "::a::bar"));
+  };
+  Visitor.runOver(
+  "namespace a { int foo(); }\nusing a::foo;\nauto f = foo();\n");
+}
+
+} // end anonymous namespace
Index: cfe/trunk/include/clang/Tooling/Core/Lookup.h
===
--- cfe/trunk/include/clang/Tooling/Core/Lookup.h
+++ 

[PATCH] D14548: Make test/Driver/biarch.c use FileCheck instead of grep

2015-11-10 Thread A. Skrobov via cfe-commits
tyomitch created this revision.
tyomitch added reviewers: joerg, rengolin, dougk, yaron.keren.
tyomitch added a subscriber: cfe-commits.

For clarity and ease of maintenance, I suggest porting this test
to use the same tooling as the rest of the tests.

http://reviews.llvm.org/D14548

Files:
  test/Driver/biarch.c

Index: test/Driver/biarch.c
===
--- test/Driver/biarch.c
+++ test/Driver/biarch.c
@@ -1,44 +1,32 @@
-// RUN: %clang -target i386--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t
+// RUN: %clang -target i386--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=I386 %s
+// RUN: %clang -target x86_64--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=I386 %s
+// I386: "-cc1" "-triple" "i386--netbsd"
 
-// RUN: %clang -target i386--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "x86_64--netbsd"' %t
+// RUN: %clang -target i386--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=X86_64 %s
+// RUN: %clang -target x86_64--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=X86_64 %s
+// X86_64: "-cc1" "-triple" "x86_64--netbsd"
 
-// RUN: %clang -target x86_64--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t
+// RUN: %clang -target armv6--netbsd-eabihf -m32 %s -### 2>&1 | FileCheck 
-check-prefix=ARMV6 %s
+// ARMV6: "-cc1" "-triple" "armv6k--netbsd-eabihf"
 
-// RUN: %clang -target x86_64--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "x86_64--netbsd"' %t
+// RUN: %clang -target sparcv9--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=SPARC %s
+// RUN: %clang -target sparc--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=SPARC %s
+// SPARC: "-cc1" "-triple" "sparc--netbsd"
 
-// RUN: %clang -target armv6--netbsd-eabihf -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "armv6k--netbsd-eabihf"' %t
+// RUN: %clang -target sparcv9--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=SPARCV9 %s
+// RUN: %clang -target sparc--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=SPARCV9 %s
+// SPARCV9: "-cc1" "-triple" "sparcv9--netbsd"
 
-// RUN: %clang -target sparcv9--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "sparc--netbsd"' %t
+// RUN: %clang -target sparc64--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=SPARC64 %s
+// SPARC64: "-cc1" "-triple" "sparc64--netbsd"
 
-// RUN: %clang -target sparcv9--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "sparcv9--netbsd"' %t
+// RUN: %clang -target sparcel -o foo %s -### 2>&1 | FileCheck 
-check-prefix=SPARCEL %s
+// SPARCEL: gcc{{(\.exe)?}}" "-EL" "-o" "foo"
 
-// RUN: %clang -target sparc64--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "sparc64--netbsd"' %t
+// RUN: %clang -target mips64--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=MIPS %s
+// RUN: %clang -target mips--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=MIPS %s
+// MIPS: "-cc1" "-triple" "mips--netbsd"
 
-// RUN: %clang -target sparc--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "sparc--netbsd"' %t
-
-// RUN: %clang -target sparc--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "sparcv9--netbsd"' %t
-
-// RUN: %clang -target sparcel -o foo %s -### 2> %t
-// RUN: grep 'gcc\(\.exe\)\?" "-EL" "-o" "foo"' %t
-
-// RUN: %clang -target mips64--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "mips--netbsd"' %t
-
-// RUN: %clang -target mips64--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "mips64--netbsd"' %t
-
-// RUN: %clang -target mips--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "mips--netbsd"' %t
-
-// RUN: %clang -target mips--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "mips64--netbsd"' %t
+// RUN: %clang -target mips64--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=MIPS64 %s
+// RUN: %clang -target mips--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=MIPS64 %s
+// MIPS64: "-cc1" "-triple" "mips64--netbsd"


Index: test/Driver/biarch.c
===
--- test/Driver/biarch.c
+++ test/Driver/biarch.c
@@ -1,44 +1,32 @@
-// RUN: %clang -target i386--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t
+// RUN: %clang -target i386--netbsd -m32 %s -### 2>&1 | FileCheck -check-prefix=I386 %s
+// RUN: %clang -target x86_64--netbsd -m32 %s -### 2>&1 | FileCheck -check-prefix=I386 %s
+// I386: "-cc1" "-triple" "i386--netbsd"
 
-// RUN: %clang -target i386--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "x86_64--netbsd"' %t
+// RUN: %clang -target i386--netbsd -m64 %s -### 2>&1 | FileCheck -check-prefix=X86_64 %s
+// RUN: %clang -target x86_64--netbsd -m64 %s -### 2>&1 | FileCheck -check-prefix=X86_64 %s
+// X86_64: "-cc1" "-triple" "x86_64--netbsd"
 
-// RUN: %clang -target x86_64--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t
+// RUN: %clang -target armv6--netbsd-eabihf -m32 %s -### 2>&1 | 

Re: [PATCH] D14548: Make test/Driver/biarch.c use FileCheck instead of grep

2015-11-11 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252720: Make test/Driver/biarch.c use FileCheck instead of 
grep (authored by askrobov).

Changed prior to commit:
  http://reviews.llvm.org/D14548?vs=39840=39889#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14548

Files:
  cfe/trunk/test/Driver/biarch.c

Index: cfe/trunk/test/Driver/biarch.c
===
--- cfe/trunk/test/Driver/biarch.c
+++ cfe/trunk/test/Driver/biarch.c
@@ -1,44 +1,32 @@
-// RUN: %clang -target i386--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t
-
-// RUN: %clang -target i386--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "x86_64--netbsd"' %t
-
-// RUN: %clang -target x86_64--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t
-
-// RUN: %clang -target x86_64--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "x86_64--netbsd"' %t
-
-// RUN: %clang -target armv6--netbsd-eabihf -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "armv6k--netbsd-eabihf"' %t
-
-// RUN: %clang -target sparcv9--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "sparc--netbsd"' %t
-
-// RUN: %clang -target sparcv9--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "sparcv9--netbsd"' %t
-
-// RUN: %clang -target sparc64--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "sparc64--netbsd"' %t
-
-// RUN: %clang -target sparc--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "sparc--netbsd"' %t
-
-// RUN: %clang -target sparc--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "sparcv9--netbsd"' %t
-
-// RUN: %clang -target sparcel -o foo %s -### 2> %t
-// RUN: grep 'gcc\(\.exe\)\?" "-EL" "-o" "foo"' %t
-
-// RUN: %clang -target mips64--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "mips--netbsd"' %t
-
-// RUN: %clang -target mips64--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "mips64--netbsd"' %t
-
-// RUN: %clang -target mips--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "mips--netbsd"' %t
-
-// RUN: %clang -target mips--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "mips64--netbsd"' %t
+// RUN: %clang -target i386--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=I386 %s
+// RUN: %clang -target x86_64--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=I386 %s
+// I386: "-cc1" "-triple" "i386--netbsd"
+
+// RUN: %clang -target i386--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=X86_64 %s
+// RUN: %clang -target x86_64--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=X86_64 %s
+// X86_64: "-cc1" "-triple" "x86_64--netbsd"
+
+// RUN: %clang -target armv6--netbsd-eabihf -m32 %s -### 2>&1 | FileCheck 
-check-prefix=ARMV6 %s
+// ARMV6: "-cc1" "-triple" "armv6k--netbsd-eabihf"
+
+// RUN: %clang -target sparcv9--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=SPARC %s
+// RUN: %clang -target sparc--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=SPARC %s
+// SPARC: "-cc1" "-triple" "sparc--netbsd"
+
+// RUN: %clang -target sparcv9--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=SPARCV9 %s
+// RUN: %clang -target sparc--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=SPARCV9 %s
+// SPARCV9: "-cc1" "-triple" "sparcv9--netbsd"
+
+// RUN: %clang -target sparc64--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=SPARC64 %s
+// SPARC64: "-cc1" "-triple" "sparc64--netbsd"
+
+// RUN: %clang -target sparcel -o foo %s -### 2>&1 | FileCheck 
-check-prefix=SPARCEL %s
+// SPARCEL: gcc{{(\.exe)?}}" "-EL" "-o" "foo"
+
+// RUN: %clang -target mips64--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=MIPS %s
+// RUN: %clang -target mips--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=MIPS %s
+// MIPS: "-cc1" "-triple" "mips--netbsd"
+
+// RUN: %clang -target mips64--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=MIPS64 %s
+// RUN: %clang -target mips--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=MIPS64 %s
+// MIPS64: "-cc1" "-triple" "mips64--netbsd"


Index: cfe/trunk/test/Driver/biarch.c
===
--- cfe/trunk/test/Driver/biarch.c
+++ cfe/trunk/test/Driver/biarch.c
@@ -1,44 +1,32 @@
-// RUN: %clang -target i386--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t
-
-// RUN: %clang -target i386--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "x86_64--netbsd"' %t
-
-// RUN: %clang -target x86_64--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "i386--netbsd"' %t
-
-// RUN: %clang -target x86_64--netbsd -m64 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "x86_64--netbsd"' %t
-
-// RUN: %clang -target armv6--netbsd-eabihf -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "armv6k--netbsd-eabihf"' %t
-
-// RUN: %clang -target sparcv9--netbsd -m32 %s -### 2> %t
-// RUN: grep '"-cc1" "-triple" "sparc--netbsd"' %t
-
-// RUN: %clang -target sparcv9--netbsd -m64 %s -### 

[PATCH] D14570: Handle ARMv6KZ naming

2015-11-11 Thread A. Skrobov via cfe-commits
tyomitch created this revision.
tyomitch added reviewers: rengolin, joerg, bogden.
tyomitch added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

Update for clang tests for D14568

http://reviews.llvm.org/D14570

Files:
  test/Driver/arm-cortex-cpus.c
  test/Driver/biarch.c

Index: test/Driver/biarch.c
===
--- test/Driver/biarch.c
+++ test/Driver/biarch.c
@@ -6,8 +6,9 @@
 // RUN: %clang -target x86_64--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=X86_64 %s
 // X86_64: "-cc1" "-triple" "x86_64--netbsd"
 
+// r196538 set arm1176jzf-s as default CPU for ARMv6 on NetBSD
 // RUN: %clang -target armv6--netbsd-eabihf -m32 %s -### 2>&1 | FileCheck 
-check-prefix=ARMV6 %s
-// ARMV6: "-cc1" "-triple" "armv6k--netbsd-eabihf"
+// ARMV6: "-cc1" "-triple" "armv6kz--netbsd-eabihf"
 
 // RUN: %clang -target sparcv9--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=SPARC %s
 // RUN: %clang -target sparc--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=SPARC %s
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -73,11 +73,11 @@
 
 // RUN: %clang -target armv6k -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K %s
 // RUN: %clang -target arm -march=armv6k -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K %s
-// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" 
"arm1176jzf-s"
+// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" "arm1176j-s"
 
 // RUN: %clang -target armv6k -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K-THUMB %s
 // RUN: %clang -target arm -march=armv6k -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K-THUMB %s
-// CHECK-V6K-THUMB: "-cc1"{{.*}} "-triple" "thumbv6k-{{.*}} "-target-cpu" 
"arm1176jzf-s"
+// CHECK-V6K-THUMB: "-cc1"{{.*}} "-triple" "thumbv6k-{{.*}} "-target-cpu" 
"arm1176j-s"
 
 // RUN: %clang -target armv6t2 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6T2 %s
 // RUN: %clang -target arm -march=armv6t2 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6T2 %s
@@ -249,12 +249,14 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=arm1136jf-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6 %s
 // CHECK-CPUV6: "-cc1"{{.*}} "-triple" "armv6-{{.*}}
 
-// RUN: %clang -target arm-linux-gnueabi -mcpu=arm1176jz-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6K %s
-// RUN: %clang -target arm-linux-gnueabi -mcpu=arm1176jzf-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6K %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=mpcore -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6K %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=mpcorenovfp -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6K %s
 // CHECK-CPUV6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}}
 
+// RUN: %clang -target arm-linux-gnueabi -mcpu=arm1176jz-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6KZ %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=arm1176jzf-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6KZ %s
+// CHECK-CPUV6KZ: "-cc1"{{.*}} "-triple" "armv6kz-{{.*}}
+
 // RUN: %clang -target arm-linux-gnueabi -mcpu=arm1156t2-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6T2 %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=arm1156t2f-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6T2 %s
 // CHECK-CPUV6T2: "-cc1"{{.*}} "-triple" "armv6t2-{{.*}}


Index: test/Driver/biarch.c
===
--- test/Driver/biarch.c
+++ test/Driver/biarch.c
@@ -6,8 +6,9 @@
 // RUN: %clang -target x86_64--netbsd -m64 %s -### 2>&1 | FileCheck -check-prefix=X86_64 %s
 // X86_64: "-cc1" "-triple" "x86_64--netbsd"
 
+// r196538 set arm1176jzf-s as default CPU for ARMv6 on NetBSD
 // RUN: %clang -target armv6--netbsd-eabihf -m32 %s -### 2>&1 | FileCheck -check-prefix=ARMV6 %s
-// ARMV6: "-cc1" "-triple" "armv6k--netbsd-eabihf"
+// ARMV6: "-cc1" "-triple" "armv6kz--netbsd-eabihf"
 
 // RUN: %clang -target sparcv9--netbsd -m32 %s -### 2>&1 | FileCheck -check-prefix=SPARC %s
 // RUN: %clang -target sparc--netbsd -m32 %s -### 2>&1 | FileCheck -check-prefix=SPARC %s
Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -73,11 +73,11 @@
 
 // RUN: %clang -target armv6k -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6K %s
 // RUN: %clang -target arm -march=armv6k -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6K %s
-// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" "arm1176jzf-s"
+// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" "arm1176j-s"
 
 // RUN: %clang -target armv6k -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6K-THUMB %s
 // RUN: %clang -target arm -march=armv6k -mthumb -### -c %s 2>&1 | FileCheck 

Re: [PATCH] D14484: Formatting constructor initializer lists by putting them always on different lines

2015-11-08 Thread JVApen via cfe-commits
JVApen added a comment.

In http://reviews.llvm.org/D14484#284767, @djasper wrote:

> Please read
>  
> http://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options
>
> Does your style option qualify?




- Is it used by a project of significant size? Yes, we use the same style at 
work, where I try to get this used by about 70 developers. (Which I consider 
already dozens of contributors) Though it is also the same style I learned at 
school.
- Does it have a publicly accessible style guide? Yes, it's both an accepted by 
the Google Style guide 

 as Ubuntu Unity 
,
 which do not state that you have to use the compact form. Further more the 
graphisoft 

 styleguide doesn't appear to allow the condensed form.
- Does it have a person willing to contribute and maintain patches? Maybe, I 
currently don't believe I'm familiar enough with the code to maintain it. 
Though without putting it out here (e.g. LLVM community) the answer will 
definitely be no. Furthermore, beside the 2 lines in TokenAnnotator.cpp, this 
style does not differentiate from the current implementation.

Though since you are the/a maintainer of this code, you are more qualified to 
give a final answer on this question.

Regardless, even if you don't want this patch upstreamed, I like to understand 
the codebase better as well as the considerations which lead to certain 
decisions for code changes. (See also the uncertainties I listed in the 
original post) Which at least will make my local changes similar to what they 
would be in case you would allow an upstream of them.


Repository:
  rL LLVM

http://reviews.llvm.org/D14484



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


Re: [PATCH] D14570: Handle ARMv6KZ naming

2015-11-16 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253207: Handle ARMv6KZ naming (authored by askrobov).

Changed prior to commit:
  http://reviews.llvm.org/D14570?vs=39901=40280#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14570

Files:
  cfe/trunk/test/Driver/arm-cortex-cpus.c
  cfe/trunk/test/Driver/biarch.c

Index: cfe/trunk/test/Driver/arm-cortex-cpus.c
===
--- cfe/trunk/test/Driver/arm-cortex-cpus.c
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c
@@ -73,11 +73,11 @@
 
 // RUN: %clang -target armv6k -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K %s
 // RUN: %clang -target arm -march=armv6k -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K %s
-// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" 
"arm1176jzf-s"
+// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" "arm1176j-s"
 
 // RUN: %clang -target armv6k -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K-THUMB %s
 // RUN: %clang -target arm -march=armv6k -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6K-THUMB %s
-// CHECK-V6K-THUMB: "-cc1"{{.*}} "-triple" "thumbv6k-{{.*}} "-target-cpu" 
"arm1176jzf-s"
+// CHECK-V6K-THUMB: "-cc1"{{.*}} "-triple" "thumbv6k-{{.*}} "-target-cpu" 
"arm1176j-s"
 
 // RUN: %clang -target armv6t2 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6T2 %s
 // RUN: %clang -target arm -march=armv6t2 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6T2 %s
@@ -249,12 +249,14 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=arm1136jf-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6 %s
 // CHECK-CPUV6: "-cc1"{{.*}} "-triple" "armv6-{{.*}}
 
-// RUN: %clang -target arm-linux-gnueabi -mcpu=arm1176jz-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6K %s
-// RUN: %clang -target arm-linux-gnueabi -mcpu=arm1176jzf-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6K %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=mpcore -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6K %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=mpcorenovfp -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6K %s
 // CHECK-CPUV6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}}
 
+// RUN: %clang -target arm-linux-gnueabi -mcpu=arm1176jz-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6KZ %s
+// RUN: %clang -target arm-linux-gnueabi -mcpu=arm1176jzf-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6KZ %s
+// CHECK-CPUV6KZ: "-cc1"{{.*}} "-triple" "armv6kz-{{.*}}
+
 // RUN: %clang -target arm-linux-gnueabi -mcpu=arm1156t2-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6T2 %s
 // RUN: %clang -target arm-linux-gnueabi -mcpu=arm1156t2f-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6T2 %s
 // CHECK-CPUV6T2: "-cc1"{{.*}} "-triple" "armv6t2-{{.*}}
Index: cfe/trunk/test/Driver/biarch.c
===
--- cfe/trunk/test/Driver/biarch.c
+++ cfe/trunk/test/Driver/biarch.c
@@ -6,8 +6,9 @@
 // RUN: %clang -target x86_64--netbsd -m64 %s -### 2>&1 | FileCheck 
-check-prefix=X86_64 %s
 // X86_64: "-cc1" "-triple" "x86_64--netbsd"
 
+// r196538 set arm1176jzf-s as default CPU for ARMv6 on NetBSD
 // RUN: %clang -target armv6--netbsd-eabihf -m32 %s -### 2>&1 | FileCheck 
-check-prefix=ARMV6 %s
-// ARMV6: "-cc1" "-triple" "armv6k--netbsd-eabihf"
+// ARMV6: "-cc1" "-triple" "armv6kz--netbsd-eabihf"
 
 // RUN: %clang -target sparcv9--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=SPARC %s
 // RUN: %clang -target sparc--netbsd -m32 %s -### 2>&1 | FileCheck 
-check-prefix=SPARC %s


Index: cfe/trunk/test/Driver/arm-cortex-cpus.c
===
--- cfe/trunk/test/Driver/arm-cortex-cpus.c
+++ cfe/trunk/test/Driver/arm-cortex-cpus.c
@@ -73,11 +73,11 @@
 
 // RUN: %clang -target armv6k -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6K %s
 // RUN: %clang -target arm -march=armv6k -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6K %s
-// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" "arm1176jzf-s"
+// CHECK-V6K: "-cc1"{{.*}} "-triple" "armv6k-{{.*}} "-target-cpu" "arm1176j-s"
 
 // RUN: %clang -target armv6k -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6K-THUMB %s
 // RUN: %clang -target arm -march=armv6k -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6K-THUMB %s
-// CHECK-V6K-THUMB: "-cc1"{{.*}} "-triple" "thumbv6k-{{.*}} "-target-cpu" "arm1176jzf-s"
+// CHECK-V6K-THUMB: "-cc1"{{.*}} "-triple" "thumbv6k-{{.*}} "-target-cpu" "arm1176j-s"
 
 // RUN: %clang -target armv6t2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6T2 %s
 // RUN: %clang -target arm -march=armv6t2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6T2 %s
@@ -249,12 +249,14 @@
 // RUN: %clang -target arm-linux-gnueabi -mcpu=arm1136jf-s -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV6 %s
 // CHECK-CPUV6: "-cc1"{{.*}} "-triple" "armv6-{{.*}}
 
-// RUN: 

Re: [PATCH] D14578: Cull non-standard variants of ARM architectures (NFC)

2015-11-12 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252904: Cull non-standard variants of ARM architectures 
(NFC) (authored by askrobov).

Changed prior to commit:
  http://reviews.llvm.org/D14578?vs=39943=40052#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14578

Files:
  cfe/trunk/lib/Basic/Targets.cpp

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4366,15 +4366,10 @@
 default:
   return llvm::ARM::getCPUAttr(ArchKind);
 case llvm::ARM::AK_ARMV6M:
-case llvm::ARM::AK_ARMV6SM:
-case llvm::ARM::AK_ARMV6HL:
   return "6M";
 case llvm::ARM::AK_ARMV7S:
   return "7S";
-case llvm::ARM::AK_ARMV7:
 case llvm::ARM::AK_ARMV7A:
-case llvm::ARM::AK_ARMV7L:
-case llvm::ARM::AK_ARMV7HL:
   return "7A";
 case llvm::ARM::AK_ARMV7R:
   return "7R";


Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4366,15 +4366,10 @@
 default:
   return llvm::ARM::getCPUAttr(ArchKind);
 case llvm::ARM::AK_ARMV6M:
-case llvm::ARM::AK_ARMV6SM:
-case llvm::ARM::AK_ARMV6HL:
   return "6M";
 case llvm::ARM::AK_ARMV7S:
   return "7S";
-case llvm::ARM::AK_ARMV7:
 case llvm::ARM::AK_ARMV7A:
-case llvm::ARM::AK_ARMV7L:
-case llvm::ARM::AK_ARMV7HL:
   return "7A";
 case llvm::ARM::AK_ARMV7R:
   return "7R";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14570: Handle ARMv6KZ naming

2015-11-12 Thread A. Skrobov via cfe-commits
tyomitch added a comment.

In http://reviews.llvm.org/D14570#288022, @joerg wrote:

> The specific CPU was only chosen to match what the backend supported at the 
> time. As long as the feature set is identical, it doesn't really matter.


The feature set isn't quite identical; default ARMv6 CPU for non-NetBSD targets 
is "arm1136jf-s", which differs from "arm1176jzf-s" by not having the HasV6KOps 
and FeatureTrustZone backend features.

I don't understand why NetBSD is special in this respect; but anyway, my patch 
preserves its special handling.


http://reviews.llvm.org/D14570



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


[PATCH] D14578: Cull non-standard variants of ARM architectures (NFC)

2015-11-11 Thread A. Skrobov via cfe-commits
tyomitch created this revision.
tyomitch added a reviewer: rengolin.
tyomitch added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

Clang-side update, corresponding to D14577

http://reviews.llvm.org/D14578

Files:
  lib/Basic/Targets.cpp

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4366,15 +4366,10 @@
 default:
   return llvm::ARM::getCPUAttr(ArchKind);
 case llvm::ARM::AK_ARMV6M:
-case llvm::ARM::AK_ARMV6SM:
-case llvm::ARM::AK_ARMV6HL:
   return "6M";
 case llvm::ARM::AK_ARMV7S:
   return "7S";
-case llvm::ARM::AK_ARMV7:
 case llvm::ARM::AK_ARMV7A:
-case llvm::ARM::AK_ARMV7L:
-case llvm::ARM::AK_ARMV7HL:
   return "7A";
 case llvm::ARM::AK_ARMV7R:
   return "7R";


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4366,15 +4366,10 @@
 default:
   return llvm::ARM::getCPUAttr(ArchKind);
 case llvm::ARM::AK_ARMV6M:
-case llvm::ARM::AK_ARMV6SM:
-case llvm::ARM::AK_ARMV6HL:
   return "6M";
 case llvm::ARM::AK_ARMV7S:
   return "7S";
-case llvm::ARM::AK_ARMV7:
 case llvm::ARM::AK_ARMV7A:
-case llvm::ARM::AK_ARMV7L:
-case llvm::ARM::AK_ARMV7HL:
   return "7A";
 case llvm::ARM::AK_ARMV7R:
   return "7R";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14311: [Clang] Fix some Clang-tidy modernize warnings, other minor fixes

2015-11-04 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252081: Fix some Clang-tidy modernize warnings, other minor 
fixes. (authored by eugenezelenko).

Changed prior to commit:
  http://reviews.llvm.org/D14311?vs=39134=39252#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14311

Files:
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Driver/Tools.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/LoopWidening.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/LoopWidening.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/LoopWidening.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/LoopWidening.cpp
@@ -23,7 +23,7 @@
 static const Expr *getLoopCondition(const Stmt *LoopStmt) {
   switch (LoopStmt->getStmtClass()) {
   default:
-return NULL;
+return nullptr;
   case Stmt::ForStmtClass:
 return cast(LoopStmt)->getCond();
   case Stmt::WhileStmtClass:
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -32,9 +32,9 @@
   LockState(Kind K) : K(K) {}
 
 public:
-  static LockState getLocked(void) { return LockState(Locked); }
-  static LockState getUnlocked(void) { return LockState(Unlocked); }
-  static LockState getDestroyed(void) { return LockState(Destroyed); }
+  static LockState getLocked() { return LockState(Locked); }
+  static LockState getUnlocked() { return LockState(Unlocked); }
+  static LockState getDestroyed() { return LockState(Destroyed); }
 
   bool operator==(const LockState ) const {
 return K == X.K;
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -1,4 +1,4 @@
-//===--- Tools.cpp - Tools Implementations ===//
+//===--- Tools.cpp - Tools Implementations --*- C++ -*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -10107,7 +10107,7 @@
 
   if (!Args.hasArg(options::OPT_nostdlib) &&
   !Args.hasArg(options::OPT_nostartfiles)) {
-const char *crt1 = NULL;
+const char *crt1 = nullptr;
 if (!Args.hasArg(options::OPT_shared)) {
   if (Args.hasArg(options::OPT_pg))
 crt1 = "gcrt1.o";
@@ -10121,7 +10121,7 @@
 
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
 
-const char *crtbegin = NULL;
+const char *crtbegin = nullptr;
 if (Args.hasArg(options::OPT_static))
   crtbegin = "crtbeginT.o";
 else if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -255,7 +255,7 @@
 
 void appendEBLinkFlags(const llvm::opt::ArgList , ArgStringList ,
const llvm::Triple );
-}
+} // end namespace arm
 
 namespace mips {
 typedef enum { NanLegacy = 1, Nan2008 = 2 } NanEncoding;
@@ -278,11 +278,11 @@
 bool shouldUseFPXX(const llvm::opt::ArgList , const llvm::Triple ,
StringRef CPUName, StringRef ABIName,
mips::FloatABI FloatABI);
-}
+} // end namespace mips
 
 namespace ppc {
 bool hasPPCAbiArg(const llvm::opt::ArgList , const char *Value);
-}
+} // end namespace ppc
 
 /// cloudabi -- Directly call GNU Binutils linker
 namespace cloudabi {
@@ -396,7 +396,7 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
-}
+} // end namespace darwin
 
 /// openbsd -- Directly call GNU Binutils assembler and linker
 namespace openbsd {
@@ -412,6 +412,7 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
+
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
   Linker(const ToolChain ) : GnuTool("openbsd::Linker", "linker", TC) {}
@@ -440,6 +441,7 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
+
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
   Linker(const ToolChain ) : GnuTool("bitrig::Linker", "linker", TC) {}
@@ -468,6 +470,7 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
+
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
   Linker(const ToolChain ) : GnuTool("freebsd::Linker", "linker", TC) {}
@@ -485,7 +488,6 @@
 /// netbsd -- Directly call GNU Binutils assembler and linker
 namespace netbsd {
 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
-
 public:
   Assembler(const 

Re: [PATCH] D14384: [ARM] Clang gives unintended warning message for 'mthumb' + M-profiles

2015-11-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252175: [ARM] Clang gives unintended warning message for 
'mthumb' + M-profiles: (authored by alelab01).

Changed prior to commit:
  http://reviews.llvm.org/D14384?vs=39370=39373#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14384

Files:
  cfe/trunk/lib/Driver/ToolChain.cpp

Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -481,9 +481,8 @@
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
-if (IsMProfile || (InputType != types::TY_PP_Asm &&
- Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, 
ThumbDefault)))
-{
+if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else


Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -481,9 +481,8 @@
   ArchName = "arm";
 
 // Assembly files should start in ARM mode, unless arch is M-profile.
-if (IsMProfile || (InputType != types::TY_PP_Asm &&
- Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, ThumbDefault)))
-{
+if ((InputType != types::TY_PP_Asm && Args.hasFlag(options::OPT_mthumb,
+ options::OPT_mno_thumb, ThumbDefault)) || IsMProfile) {
   if (IsBigEndian)
 ArchName = "thumbeb";
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14484: Formatting constructor initializer lists by putting them always on different lines

2015-11-08 Thread JVApen via cfe-commits
JVApen created this revision.
JVApen added a reviewer: djasper.
JVApen added a subscriber: cfe-commits.
JVApen set the repository for this revision to rL LLVM.
Herald added a subscriber: klimek.

Hi all,

I've been playing around with the clang for a while now and really enjoy it. 
Unfortunately clang-format does not yet do what I like it to do, so I started 
hacking it. So here is my first successful attempt to get something working.

The issue: ConstructorInitializerAllOnOneLineOrOnePerLine only works if 'If the 
constructor initializers don’t fit on a line', while I prefer it to always 
work. In other words, I use the following formatting:

```
Constructor()
  : a(a)
  , b(b)
```

Since everyone can benefit from upstreaming, I like to share my changes and get 
some feedback.
Here is already some of the stuff which I was uncertain about:

  - Should I keep ConstructorInitializerAllOnOneLineOrOnePerLine or rename it 
(currently the second one)
  - How to name the values, currently: Compact (old: false), BestFit (old: 
true), OnePerLine (new)
  - Is the back-ward compatibility in ScalarEnumerationTraits a good idea? (On 
rename most likely not)

JVApen



Repository:
  rL LLVM

http://reviews.llvm.org/D14484

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -3586,8 +3586,51 @@
"  aaa(aaa),\n"
"  at() {}");

+  FormatStyle BestFit = getLLVMStyle();
+  BestFit.ConstructorInitializer = FormatStyle::CI_BestFit;
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a(aa),\n"
+   "  a(aa),\n"
+   "  a(aa) {}",
+   BestFit);
+  verifyFormat("SomeClass::Constructor()\n"
+   ": a(aa), // Some comment\n"
+   "  a(aa),\n"
+   "  a(aa) {}",
+   BestFit);
+  verifyFormat("MyClass::MyClass(int var)\n"
+   ": some_var_(var),// 4 space indent\n"
+   "  some_other_var_(var + 1) { // lined up\n"
+   "}",
+   BestFit);
+  verifyFormat("Constructor() : a(a), a(a) {}\n",
+   BestFit);
+  verifyFormat("Constructor()\n"
+   ": a(aa),\n"
+   "  a(aa),\n"
+   "  a(aa),\n"
+   "  a(aa),\n"
+   "  a(aa) {}",
+   BestFit);
+  verifyFormat("Constructor()\n"
+   ": a(aa, aa,\n"
+   "aa) {}",
+   BestFit);
+  BestFit.ColumnLimit = 60;
+  verifyFormat("Constructor()\n"
+   ": (a),\n"
+   "  (b) {}",
+   BestFit);
+
+  EXPECT_EQ("Constructor()\n"
+": // Comment forcing unwanted break.\n"
+"  () {}",
+format("Constructor() :\n"
+   "// Comment forcing unwanted break.\n"
+   "() {}"));
+
   FormatStyle OnePerLine = getLLVMStyle();
-  OnePerLine.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
+  OnePerLine.ConstructorInitializer = FormatStyle::CI_OnePerLine;
   verifyFormat("SomeClass::Constructor()\n"
": a(aa),\n"
"  a(aa),\n"
@@ -3604,6 +3647,10 @@
"}",
OnePerLine);
   verifyFormat("Constructor()\n"
+   ": a(a),\n"
+   "  a(a) {}",
+   OnePerLine);
+  verifyFormat("Constructor()\n"
": a(aa),\n"
"  a(aa),\n"
"  a(aa),\n"
@@ -3696,7 +3743,7 @@

   // This test takes VERY long when memoization is broken.
   FormatStyle OnePerLine = getLLVMStyle();
-  OnePerLine.ConstructorInitializerAllOnOneLineOrOnePerLine = true;
+  OnePerLine.ConstructorInitializer = FormatStyle::CI_BestFit;
   OnePerLine.BinPackParameters = false;
   std::string input = "Constructor()\n"
   ": (a,\n";
@@ -9560,7 +9607,6 @@
   CHECK_PARSE_BOOL(BinPackParameters);
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakConstructorInitializersBeforeComma);
-  CHECK_PARSE_BOOL(ConstructorInitializerAllOnOneLineOrOnePerLine);
   CHECK_PARSE_BOOL(DerivePointerAlignment);
   

Re: [PATCH] D14205: [x86] Front-end part of MCU psABI support

2015-11-02 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251786: [x86] Front-end part of MCU psABI support (authored 
by asbokhan).

Changed prior to commit:
  http://reviews.llvm.org/D14205?vs=38814=38878#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14205

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c
  cfe/trunk/test/Preprocessor/elfiamcu-predefines.c

Index: cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c
===
--- cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c
+++ cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c
@@ -56,3 +56,7 @@
 // insane.
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
+
+// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+long double longDoubleArg(long double ld1) { return ld1; }
+
Index: cfe/trunk/test/Preprocessor/elfiamcu-predefines.c
===
--- cfe/trunk/test/Preprocessor/elfiamcu-predefines.c
+++ cfe/trunk/test/Preprocessor/elfiamcu-predefines.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
+
+// CHECK: #define __iamcu
+// CHECK: #define __iamcu__
+
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -2335,7 +2335,8 @@
 public:
   X86TargetInfo(const llvm::Triple ) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = ::APFloat::x87DoubleExtended;
+LongDoubleFormat = Triple.isOSIAMCU() ? ::APFloat::IEEEdouble
+  : ::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3370,6 +3371,11 @@
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+
+  if (getTriple().isOSIAMCU()) {
+Builder.defineMacro("__iamcu");
+Builder.defineMacro("__iamcu__");
+  }
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {


Index: cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c
===
--- cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c
+++ cfe/trunk/test/CodeGen/x86_32-arguments-iamcu.c
@@ -56,3 +56,7 @@
 // insane.
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
+
+// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+long double longDoubleArg(long double ld1) { return ld1; }
+
Index: cfe/trunk/test/Preprocessor/elfiamcu-predefines.c
===
--- cfe/trunk/test/Preprocessor/elfiamcu-predefines.c
+++ cfe/trunk/test/Preprocessor/elfiamcu-predefines.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -E -dM -triple i586-intel-elfiamcu | FileCheck %s
+
+// CHECK: #define __iamcu
+// CHECK: #define __iamcu__
+
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -2335,7 +2335,8 @@
 public:
   X86TargetInfo(const llvm::Triple ) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = ::APFloat::x87DoubleExtended;
+LongDoubleFormat = Triple.isOSIAMCU() ? ::APFloat::IEEEdouble
+  : ::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3370,6 +3371,11 @@
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+
+  if (getTriple().isOSIAMCU()) {
+Builder.defineMacro("__iamcu");
+Builder.defineMacro("__iamcu__");
+  }
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13959: Fix crash in EmitDeclMetadata mode

2015-11-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252229: Fix crash in EmitDeclMetadata mode (authored by 
kfischer).

Changed prior to commit:
  http://reviews.llvm.org/D13959?vs=38049=39426#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13959

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -3707,10 +3707,12 @@
 void CodeGenModule::EmitDeclMetadata() {
   llvm::NamedMDNode *GlobalMetadata = nullptr;
 
-  // StaticLocalDeclMap
   for (auto  : MangledDeclNames) {
 llvm::GlobalValue *Addr = getModule().getNamedValue(I.second);
-EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
+// Some mangled names don't necessarily have an associated GlobalValue
+// in this module, e.g. if we mangled it for DebugInfo.
+if (Addr)
+  EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
   }
 }
 


Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -3707,10 +3707,12 @@
 void CodeGenModule::EmitDeclMetadata() {
   llvm::NamedMDNode *GlobalMetadata = nullptr;
 
-  // StaticLocalDeclMap
   for (auto  : MangledDeclNames) {
 llvm::GlobalValue *Addr = getModule().getNamedValue(I.second);
-EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
+// Some mangled names don't necessarily have an associated GlobalValue
+// in this module, e.g. if we mangled it for DebugInfo.
+if (Addr)
+  EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14440: [tsan] Add Clang frontend support for TSan on OS X

2015-11-06 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252310: [tsan] Add Clang frontend support for TSan on OS X 
(authored by kuba.brecka).

Changed prior to commit:
  http://reviews.llvm.org/D14440?vs=39524=39526#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14440

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp

Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -389,6 +389,8 @@
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+  if (Sanitize.needsTsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
 
   // Otherwise link libSystem, then the dynamic runtime library, and finally 
any
   // target specific static runtime library.
@@ -1199,6 +1201,7 @@
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -389,6 +389,8 @@
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+  if (Sanitize.needsTsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
 
   // Otherwise link libSystem, then the dynamic runtime library, and finally any
   // target specific static runtime library.
@@ -1199,6 +1201,7 @@
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D7639: Add readability-redundant-void-arg check to clang-tidy

2015-10-18 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

In http://reviews.llvm.org/D7639#266332, @Eugene.Zelenko wrote:

> What is preventing to add this check to Clang-tidy? Just found another piece 
> of fresh C++ code in LLDB with (void) as argument list...


To be honest, I don't know.  This review had taken SO long to get 
approved.  At this point, the code is correct and I'd really like to get it 
committed and available for use instead of fussing with it any longer.


http://reviews.llvm.org/D7639



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


Re: [PATCH] D7639: Add readability-redundant-void-arg check to clang-tidy

2015-10-18 Thread Richard via cfe-commits
LegalizeAdulthood updated this revision to Diff 37717.

http://reviews.llvm.org/D7639

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantVoidArgCheck.cpp
  clang-tidy/readability/RedundantVoidArgCheck.h
  test/clang-tidy/readability-redundant-void-arg.c
  test/clang-tidy/readability-redundant-void-arg.cpp

Index: test/clang-tidy/readability-redundant-void-arg.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-void-arg.cpp
@@ -0,0 +1,419 @@
+// RUN: %python %S/check_clang_tidy.py %s readability-redundant-void-arg %t
+
+#include 
+
+int foo();
+
+void bar();
+
+void bar2();
+
+extern "C" void ecfoo(void);
+
+extern "C" void ecfoo(void) {
+}
+
+extern int i;
+
+int j = 1;
+
+int foo(void) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant void argument list in function definition [readability-redundant-void-arg]
+// CHECK-FIXES: {{^}}int foo() {{{$}}
+return 0;
+}
+
+typedef unsigned int my_uint;
+
+typedef void my_void;
+
+// A function taking void and returning a pointer to function taking void
+// and returning int.
+int (*returns_fn_void_int(void))(void);
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}} in function declaration
+// CHECK-MESSAGES: :[[@LINE-2]]:34: warning: {{.*}} in function declaration
+// CHECK-FIXES: {{^}}int (*returns_fn_void_int())();{{$}}
+
+typedef int (*returns_fn_void_int_t(void))(void);
+// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: {{.*}} in typedef
+// CHECK-MESSAGES: :[[@LINE-2]]:44: warning: {{.*}} in typedef
+// CHECK-FIXES: {{^}}typedef int (*returns_fn_void_int_t())();{{$}}
+
+int (*returns_fn_void_int(void))(void) {
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}} in function definition
+// CHECK-MESSAGES: :[[@LINE-2]]:34: warning: {{.*}} in function definition
+// CHECK-FIXES: {{^}}int (*returns_fn_void_int())() {{{$}}
+  return nullptr;
+}
+
+// A function taking void and returning a pointer to a function taking void
+// and returning a pointer to a function taking void and returning void.
+void (*(*returns_fn_returns_fn_void_void(void))(void))(void);
+// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: {{.*}} in function declaration
+// CHECK-MESSAGES: :[[@LINE-2]]:49: warning: {{.*}} in function declaration
+// CHECK-MESSAGES: :[[@LINE-3]]:56: warning: {{.*}} in function declaration
+// CHECK-FIXES: {{^}}void (*(*returns_fn_returns_fn_void_void())())();{{$}}
+
+typedef void (*(*returns_fn_returns_fn_void_void_t(void))(void))(void);
+// CHECK-MESSAGES: :[[@LINE-1]]:52: warning: {{.*}} in typedef
+// CHECK-MESSAGES: :[[@LINE-2]]:59: warning: {{.*}} in typedef
+// CHECK-MESSAGES: :[[@LINE-3]]:66: warning: {{.*}} in typedef
+// CHECK-FIXES: {{^}}typedef void (*(*returns_fn_returns_fn_void_void_t())())();{{$}}
+
+void (*(*returns_fn_returns_fn_void_void(void))(void))(void) {
+// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: {{.*}} in function definition
+// CHECK-MESSAGES: :[[@LINE-2]]:49: warning: {{.*}} in function definition
+// CHECK-MESSAGES: :[[@LINE-3]]:56: warning: {{.*}} in function definition
+// CHECK-FIXES: {{^}}void (*(*returns_fn_returns_fn_void_void())())() {{{$}}
+return nullptr;
+}
+
+void bar(void) {
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: {{.*}} in function definition
+// CHECK-FIXES: {{^}}void bar() {{{$}}
+}
+
+void op_fn(int i) {
+}
+
+class gronk {
+public:
+  gronk();
+  ~gronk();
+
+void foo();
+void bar();
+void bar2
+();
+void operation(int i) { }
+
+private:
+int m_i;
+int *m_pi;
+float m_f;
+float *m_pf;
+double m_d;
+double *m_pd;
+
+void (*f1)(void);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*}} in field declaration
+// CHECK-FIXES: {{^}}void (*f1)();{{$}}
+
+  void (*op)(int i);
+
+  void (gronk::*p1)(void);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in field declaration
+  // CHECK-FIXES: {{^  }}void (gronk::*p1)();{{$}}
+
+  int (gronk::*p_mi);
+
+  void (gronk::*p2)(int);
+
+  void (*(*returns_fn_returns_fn_void_void(void))(void))(void);
+  // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: {{.*}} in function declaration
+  // CHECK-MESSAGES: :[[@LINE-2]]:51: warning: {{.*}} in function declaration
+  // CHECK-MESSAGES: :[[@LINE-3]]:58: warning: {{.*}} in function declaration
+  // CHECK-FIXES: {{^}}  void (*(*returns_fn_returns_fn_void_void())())();{{$}}
+
+  void (*(*(gronk::*returns_fn_returns_fn_void_void_mem)(void))(void))(void);
+  // CHECK-MESSAGES: :[[@LINE-1]]:58: warning: {{.*}} in field declaration
+  // CHECK-MESSAGES: :[[@LINE-2]]:65: warning: {{.*}} in field declaration
+  // CHECK-MESSAGES: :[[@LINE-3]]:72: warning: {{.*}} in field declaration
+  // CHECK-FIXES: {{^}}  void (*(*(gronk::*returns_fn_returns_fn_void_void_mem)())())();{{$}}
+};
+
+int i;
+int *pi;
+void *pv = (void *) pi;
+float f;
+float *fi;
+double d;
+double *pd;
+
+void (*f1)(void);
+// CHECK-MESSAGES: 

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

2015-10-08 Thread via cfe-commits
> I think this actually makes it less general. You would presumably perform
> different inlining for:
>
>   throw f(x, y);
>
> versus
>
>   auto k = f(x, y);
>   throw k;

We need to differentiate between these two. For the second case, we should
not add any attribute because it’s not invoked in the EH region and it
could have any other purposes other than exception handling. I believe we
need to specifically handle only the case where we can guarantee that the
call is invoked only in exception handling context.


> That's not something we can really do from the frontend, because small
> constructors often don't look small until they themselves have been
> optimized.

I agree. If we need to add check for callee size, doing this in frontend
may not be the good idea. But it should be done before inliner.


> Would it be sufficient to mark just the invocation of __cxa_throw (or its
> equivalent) as cold? If the optimizer can't infer from that that the code
> leading up to the call is also cold, we should fix that in the LLVM-side
> analysis rather than working around it in the frontend.

Basically, current Inliner doesn't have any impact with Attribute::Cold
because ColdThreshold and InlineLimit are the same by default. I
understand noinline looks somewhat strong decision. But, even with
noinline, I believe we could expect more pros than cons.

In performance perspective, by avoiding inlining in throw statement, we
could open up more inline opportunities for functions containing throw
statements. For example, below small function could not be inlined in its
many callsites if the constructor of IndexOutOfBoundsException is
non-trivial and inlined first in elementAt().

  int elementAt(int idx) {
if (idx >= limit)
  throw IndexOutOfBoundsException(idx, limit);
return Array[idx];
  }
Pretty much same thing could actually happen in many c++ programs, and I
found the actual cases in spec2006/xalancbmk.

In most case we also don't need to increase code size by inlining
constructors invoked in throw statement, especially when there is a
hierarchy of exception handling classes.

The only downsides I can think of is the case where the constructor is
very small so that inlining it is profitable for size. My suggestion for
this is to move this implementation back to PruneEH.cpp so that we can
check the callee size right before the inliner. I may add the noinline
only when the constructor is large enough.




> On Wed, Oct 7, 2015 at 3:10 PM, Jun Bum Lim via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> junbuml added a comment.
>>
>> Thanks Richard for the comment.
>>
>> Initially, I intended to implement this in inliner by checking if a
>> callsite is in exception handling regions. However, I decided not to
>> implement this in inliner because this kind of check should be performed
>> for all callsites if we implement it in inliner.
>>
>> Instead of directly adding complexity in inliner, I implemented this in
>> PruneEH.cpp (http://reviews.llvm.org/D12979) because this is very
>> specific to exception handling regions. In this patch, I tried to mark
>> all
>> callsites invoked from throw statements as cold (noinline) by looking up
>> users of __cxa_throw() and __cxa_allocate_exception(). We had many
>> discussions and finally ended up to implement the same thing in clang to
>> be
>> more general and simpler as Hal suggested in
>> http://reviews.llvm.org/D12979.
>>
>
> I think this actually makes it less general. You would presumably perform
> different inlining for:
>
>   throw f(x, y);
>
> versus
>
>   auto k = f(x, y);
>   throw k;
>
> which doesn't really seem defensible.
>
>
>> As you point out, it should be done by influencing inline cost heurisic,
>> so I believe Attribute::Cold is the right attribute to be added here.
>> However, as I FIXMEed, the current ColdThreshold is not tuned yet
>> (r200898). So for now, I add both cold and noinline.
>>
>> Regarding code size, I believe not inlining contractor calls in throw
>> statements could be potentially more helpful for code size in many
>> cases.
>> If inlining very small callsites in throw statements could be issue,
>> then
>> we may be able to  check if callee is smaller than some threshold to
>> avoid
>> adding the attributes (cold and noinline).
>
>
> That's not something we can really do from the frontend, because small
> constructors often don't look small until they themselves have been
> optimized.
>
> Would it be sufficient to mark just the invocation of __cxa_throw (or its
> equivalent) as cold? If the optimizer can't infer from that that the code
> leading up to the call is also cold, we should fix that in the LLVM-side
> analysis rather than working around it in the frontend.
>

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


Re: [PATCH] D13861: [x86] fix wrong maskload/store intrinsic definitions in avxintrin.h (follow up of D13776).

2015-10-20 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL250816: [x86] Fix maskload/store intrinsic definitions in 
avxintrin.h (authored by adibiagio).

Changed prior to commit:
  http://reviews.llvm.org/D13861?vs=37741=37852#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13861

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/lib/Headers/avxintrin.h
  cfe/trunk/test/CodeGen/builtins-x86.c

Index: cfe/trunk/lib/Headers/avxintrin.h
===
--- cfe/trunk/lib/Headers/avxintrin.h
+++ cfe/trunk/lib/Headers/avxintrin.h
@@ -835,53 +835,53 @@
 
 /* Conditional load ops */
 static __inline __m128d __DEFAULT_FN_ATTRS
-_mm_maskload_pd(double const *__p, __m128d __m)
+_mm_maskload_pd(double const *__p, __m128i __m)
 {
-  return (__m128d)__builtin_ia32_maskloadpd((const __v2df *)__p, (__v2df)__m);
+  return (__m128d)__builtin_ia32_maskloadpd((const __v2df *)__p, (__v2di)__m);
 }
 
 static __inline __m256d __DEFAULT_FN_ATTRS
-_mm256_maskload_pd(double const *__p, __m256d __m)
+_mm256_maskload_pd(double const *__p, __m256i __m)
 {
   return (__m256d)__builtin_ia32_maskloadpd256((const __v4df *)__p,
-   (__v4df)__m);
+   (__v4di)__m);
 }
 
 static __inline __m128 __DEFAULT_FN_ATTRS
-_mm_maskload_ps(float const *__p, __m128 __m)
+_mm_maskload_ps(float const *__p, __m128i __m)
 {
-  return (__m128)__builtin_ia32_maskloadps((const __v4sf *)__p, (__v4sf)__m);
+  return (__m128)__builtin_ia32_maskloadps((const __v4sf *)__p, (__v4si)__m);
 }
 
 static __inline __m256 __DEFAULT_FN_ATTRS
-_mm256_maskload_ps(float const *__p, __m256 __m)
+_mm256_maskload_ps(float const *__p, __m256i __m)
 {
-  return (__m256)__builtin_ia32_maskloadps256((const __v8sf *)__p, (__v8sf)__m);
+  return (__m256)__builtin_ia32_maskloadps256((const __v8sf *)__p, (__v8si)__m);
 }
 
 /* Conditional store ops */
 static __inline void __DEFAULT_FN_ATTRS
-_mm256_maskstore_ps(float *__p, __m256 __m, __m256 __a)
+_mm256_maskstore_ps(float *__p, __m256i __m, __m256 __a)
 {
-  __builtin_ia32_maskstoreps256((__v8sf *)__p, (__v8sf)__m, (__v8sf)__a);
+  __builtin_ia32_maskstoreps256((__v8sf *)__p, (__v8si)__m, (__v8sf)__a);
 }
 
 static __inline void __DEFAULT_FN_ATTRS
-_mm_maskstore_pd(double *__p, __m128d __m, __m128d __a)
+_mm_maskstore_pd(double *__p, __m128i __m, __m128d __a)
 {
-  __builtin_ia32_maskstorepd((__v2df *)__p, (__v2df)__m, (__v2df)__a);
+  __builtin_ia32_maskstorepd((__v2df *)__p, (__v2di)__m, (__v2df)__a);
 }
 
 static __inline void __DEFAULT_FN_ATTRS
-_mm256_maskstore_pd(double *__p, __m256d __m, __m256d __a)
+_mm256_maskstore_pd(double *__p, __m256i __m, __m256d __a)
 {
-  __builtin_ia32_maskstorepd256((__v4df *)__p, (__v4df)__m, (__v4df)__a);
+  __builtin_ia32_maskstorepd256((__v4df *)__p, (__v4di)__m, (__v4df)__a);
 }
 
 static __inline void __DEFAULT_FN_ATTRS
-_mm_maskstore_ps(float *__p, __m128 __m, __m128 __a)
+_mm_maskstore_ps(float *__p, __m128i __m, __m128 __a)
 {
-  __builtin_ia32_maskstoreps((__v4sf *)__p, (__v4sf)__m, (__v4sf)__a);
+  __builtin_ia32_maskstoreps((__v4sf *)__p, (__v4si)__m, (__v4sf)__a);
 }
 
 /* Cacheability support ops */
Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -503,14 +503,14 @@
 TARGET_BUILTIN(__builtin_ia32_movntdq256, "vV4LLi*V4LLi", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_movntpd256, "vd*V4d", "", "avx")
 TARGET_BUILTIN(__builtin_ia32_movntps256, "vf*V8f", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_maskloadpd, "V2dV2dC*V2d", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_maskloadps, "V4fV4fC*V4f", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_maskloadpd256, "V4dV4dC*V4d", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_maskloadps256, "V8fV8fC*V8f", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_maskstorepd, "vV2d*V2dV2d", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_maskstoreps, "vV4f*V4fV4f", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_maskstorepd256, "vV4d*V4dV4d", "", "avx")
-TARGET_BUILTIN(__builtin_ia32_maskstoreps256, "vV8f*V8fV8f", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_maskloadpd, "V2dV2dC*V2LLi", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_maskloadps, "V4fV4fC*V4i", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_maskloadpd256, "V4dV4dC*V4LLi", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_maskloadps256, "V8fV8fC*V8i", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_maskstorepd, "vV2d*V2LLiV2d", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_maskstoreps, "vV4f*V4iV4f", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_maskstorepd256, "vV4d*V4LLiV4d", "", "avx")
+TARGET_BUILTIN(__builtin_ia32_maskstoreps256, "vV8f*V8iV8f", "", "avx")
 
 // AVX2
 TARGET_BUILTIN(__builtin_ia32_mpsadbw256, "V32cV32cV32cIc", "", "avx2")
Index: cfe/trunk/test/CodeGen/builtins-x86.c

Re: [PATCH] D13474: [VFS] Port tooling to use the in-memory file system.

2015-10-09 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249815: [VFS] Port tooling to use the in-memory file system. 
(authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D13474?vs=36632=36929#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13474

Files:
  cfe/trunk/include/clang/Tooling/Tooling.h
  cfe/trunk/lib/Tooling/Tooling.cpp
  cfe/trunk/unittests/Tooling/ToolingTest.cpp

Index: cfe/trunk/include/clang/Tooling/Tooling.h
===
--- cfe/trunk/include/clang/Tooling/Tooling.h
+++ cfe/trunk/include/clang/Tooling/Tooling.h
@@ -243,6 +243,7 @@
   ///
   /// \param FilePath The path at which the content will be mapped.
   /// \param Content A null terminated buffer of the file's content.
+  // FIXME: remove this when all users have migrated!
   void mapVirtualFile(StringRef FilePath, StringRef Content);
 
   /// \brief Run the clang invocation.
@@ -331,9 +332,12 @@
   std::vector SourcePaths;
   std::shared_ptr PCHContainerOps;
 
+  llvm::IntrusiveRefCntPtr OverlayFileSystem;
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem;
   llvm::IntrusiveRefCntPtr Files;
   // Contains a list of pairs (, ).
   std::vector< std::pair > MappedFileContents;
+  llvm::StringSet<> SeenWorkingDirectories;
 
   ArgumentsAdjuster ArgsAdjuster;
 
Index: cfe/trunk/lib/Tooling/Tooling.cpp
===
--- cfe/trunk/lib/Tooling/Tooling.cpp
+++ cfe/trunk/lib/Tooling/Tooling.cpp
@@ -32,13 +32,6 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/raw_ostream.h"
 
-// For chdir, see the comment in ClangTool::run for more information.
-#ifdef LLVM_ON_WIN32
-#  include 
-#else
-#  include 
-#endif
-
 #define DEBUG_TYPE "clang-tooling"
 
 namespace clang {
@@ -131,18 +124,25 @@
 
   SmallString<16> FileNameStorage;
   StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage);
+  llvm::IntrusiveRefCntPtr OverlayFileSystem(
+  new vfs::OverlayFileSystem(vfs::getRealFileSystem()));
+  llvm::IntrusiveRefCntPtr InMemoryFileSystem(
+  new vfs::InMemoryFileSystem);
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
   llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions()));
+  new FileManager(FileSystemOptions(), OverlayFileSystem));
   ToolInvocation Invocation(getSyntaxOnlyToolArgs(Args, FileNameRef),
 ToolAction, Files.get(), PCHContainerOps);
 
   SmallString<1024> CodeStorage;
-  Invocation.mapVirtualFile(FileNameRef,
-Code.toNullTerminatedStringRef(CodeStorage));
+  InMemoryFileSystem->addFile(FileNameRef, 0,
+  llvm::MemoryBuffer::getMemBuffer(
+  Code.toNullTerminatedStringRef(CodeStorage)));
 
   for (auto  : VirtualMappedFiles) {
-Invocation.mapVirtualFile(FilenameWithContent.first,
-  FilenameWithContent.second);
+InMemoryFileSystem->addFile(
+FilenameWithContent.first, 0,
+llvm::MemoryBuffer::getMemBuffer(FilenameWithContent.second));
   }
 
   return Invocation.run();
@@ -250,6 +250,7 @@
   }
   std::unique_ptr Invocation(
   newInvocation(, *CC1Args));
+  // FIXME: remove this when all users have migrated!
   for (const auto  : MappedFileContents) {
 // Inject the code as the given file name into the preprocessor options.
 std::unique_ptr Input =
@@ -308,7 +309,11 @@
  std::shared_ptr PCHContainerOps)
 : Compilations(Compilations), SourcePaths(SourcePaths),
   PCHContainerOps(PCHContainerOps),
-  Files(new FileManager(FileSystemOptions())), DiagConsumer(nullptr) {
+  OverlayFileSystem(new vfs::OverlayFileSystem(vfs::getRealFileSystem())),
+  InMemoryFileSystem(new vfs::InMemoryFileSystem),
+  Files(new FileManager(FileSystemOptions(), OverlayFileSystem)),
+  DiagConsumer(nullptr) {
+  OverlayFileSystem->pushOverlay(InMemoryFileSystem);
   appendArgumentsAdjuster(getClangStripOutputAdjuster());
   appendArgumentsAdjuster(getClangSyntaxOnlyAdjuster());
 }
@@ -346,6 +351,16 @@
   if (std::error_code EC = llvm::sys::fs::current_path(InitialDirectory))
 llvm::report_fatal_error("Cannot detect current path: " +
  Twine(EC.message()));
+
+  // First insert all absolute paths into the in-memory VFS. These are global
+  // for all compile commands.
+  if (SeenWorkingDirectories.insert("/").second)
+for (const auto  : MappedFileContents)
+  if (llvm::sys::path::is_absolute(MappedFile.first))
+InMemoryFileSystem->addFile(
+MappedFile.first, 0,
+llvm::MemoryBuffer::getMemBuffer(MappedFile.second));
+
   bool ProcessingFailed = false;
   for (const auto  : SourcePaths) {
 std::string File(getAbsolutePath(SourcePath));
@@ -376,9 +391,21 @@
   // difference for example on network 

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

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

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

Repository:
  rL LLVM

http://reviews.llvm.org/D13658

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

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

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

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

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

Repository:
  rL LLVM

http://reviews.llvm.org/D13399

Files:
  cfe/trunk/runtime/CMakeLists.txt

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

Re: [PATCH] D11433: [Static Analyzer] Make NonNullParamChecker emit implicit null dereference events.

2015-08-27 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246182: [Static Analyzer] Make NonNullParamChecker emit 
implicit null dereference… (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D11433?vs=5id=33344#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11433

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  cfe/trunk/test/Analysis/nullability.mm

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/Checker.h
@@ -514,6 +514,10 @@
   bool IsLoad;
   ExplodedNode *SinkNode;
   BugReporter *BR;
+  // When true, the dereference is in the source code directly. When false, the
+  // dereference might happen later (for example pointer passed to a parameter
+  // that is marked with nonnull attribute.)
+  bool IsDirectDereference;
 };
 
 /// \brief A helper class which wraps a boolean value set to false by default.
Index: cfe/trunk/test/Analysis/nullability.mm
===
--- cfe/trunk/test/Analysis/nullability.mm
+++ cfe/trunk/test/Analysis/nullability.mm
@@ -50,6 +50,8 @@
 
 template typename T T *eraseNullab(T *p) { return p; }
 
+void takesAttrNonnull(Dummy *p) __attribute((nonnull(1)));
+
 void testBasicRules() {
   Dummy *p = returnsNullable();
   int *ptr = returnsNullableInt();
@@ -73,10 +75,8 @@
 Dummy dd(d);
 break;
   }
-  // Here the copy constructor is called, so a reference is initialized with the
-  // value of p. No ImplicitNullDereference event will be dispatched for this
-  // case. A followup patch is expected to fix this in NonNullParamChecker.
-  default: { Dummy d = *p; } break; // No warning.
+  case 5: takesAttrNonnull(p); break; // expected-warning {{Nullable pointer is passed to}}
+  default: { Dummy d = *p; } break; // expected-warning {{Nullable pointer is dereferenced}}
   }
   if (p) {
 takesNonnull(p);
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -28,7 +28,7 @@
 
 namespace {
 class NonNullParamChecker
-  : public Checker check::PreCall  {
+  : public Checker check::PreCall, EventDispatcherImplicitNullDerefEvent  {
   mutable std::unique_ptrBugType BTAttrNonNull;
   mutable std::unique_ptrBugType BTNullRefArg;
 
@@ -139,26 +139,34 @@
 ProgramStateRef stateNotNull, stateNull;
 std::tie(stateNotNull, stateNull) = CM.assumeDual(state, *DV);
 
-if (stateNull  !stateNotNull) {
-  // Generate an error node.  Check for a null node in case
-  // we cache out.
-  if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
-
-std::unique_ptrBugReport R;
-if (haveAttrNonNull)
-  R = genReportNullAttrNonNull(errorNode, ArgE);
-else if (haveRefTypeParam)
-  R = genReportReferenceToNullPointer(errorNode, ArgE);
+if (stateNull) {
+  if (!stateNotNull) {
+// Generate an error node.  Check for a null node in case
+// we cache out.
+if (ExplodedNode *errorNode = C.generateSink(stateNull)) {
+
+  std::unique_ptrBugReport R;
+  if (haveAttrNonNull)
+R = genReportNullAttrNonNull(errorNode, ArgE);
+  else if (haveRefTypeParam)
+R = genReportReferenceToNullPointer(errorNode, ArgE);
+
+  // Highlight the range of the argument that was null.
+  R-addRange(Call.getArgSourceRange(idx));
+
+  // Emit the bug report.
+  C.emitReport(std::move(R));
+}
 
-// Highlight the range of the argument that was null.
-R-addRange(Call.getArgSourceRange(idx));
-
-// Emit the bug report.
-C.emitReport(std::move(R));
+// Always return.  Either we cached out or we just emitted an error.
+return;
+  }
+  if (ExplodedNode *N = C.generateSink(stateNull)) {
+ImplicitNullDerefEvent event = {
+V, false, N, C.getBugReporter(),
+/*IsDirectDereference=*/haveRefTypeParam};
+dispatchEvent(event);
   }
-
-  // Always return.  Either we cached out or we just emitted an error.
-  return;
 }
 
 // If a pointer value passed the check we should assume that it is
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ 

Re: [PATCH] D11468: [Static Analyzer] The first implementation of nullability checker.

2015-08-26 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246105: [Static Analyzer] Checks to catch nullability 
related issues. (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D11468?vs=33239id=33267#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11468

Files:
  cfe/trunk/docs/analyzer/nullability.rst
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  cfe/trunk/test/Analysis/nullability.mm

Index: cfe/trunk/docs/analyzer/nullability.rst
===
--- cfe/trunk/docs/analyzer/nullability.rst
+++ cfe/trunk/docs/analyzer/nullability.rst
@@ -0,0 +1,92 @@
+
+Nullability Checks
+
+
+This document is a high level description of the nullablility checks.
+These checks intended to use the annotations that is described in this
+RFC: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2015-March/041798.html.
+
+Let's consider the following 2 categories:
+
+1) nullable
+
+
+If a pointer 'p' has a nullable annotation and no explicit null check or assert, we should warn in the following cases:
+- 'p' gets implicitly converted into nonnull pointer, for example, we are passing it to a function that takes a nonnull parameter.
+- 'p' gets dereferenced
+
+Taking a branch on nullable pointers are the same like taking branch on null unspecified pointers.
+
+Explicit cast from nullable to nonnul::
+
+__nullable id foo;
+id bar = foo;
+takesNonNull((_nonnull) bar); — should not warn here (backward compatibility hack)
+anotherTakesNonNull(bar); — would be great to warn here, but not necessary(*)
+
+Because bar corresponds to the same symbol all the time it is not easy to implement the checker that way the cast only suppress the first call but not the second. For this reason in the first implementation after a contradictory cast happens, I will treat bar as nullable unspecified, this way all of the warnings will be suppressed. Treating the symbol as nullable unspecified also has an advantage that in case the takesNonNull function body is being inlined, the will be no warning, when the symbol is dereferenced. In case I have time after the initial version I might spend additional time to try to find a more sophisticated solution, in which we would produce the second warning (*).
+ 
+2) nonnull
+
+
+- Dereferencing a nonnull, or sending message to it is ok.
+- Converting nonnull to nullable is Ok.
+- When there is an explicit cast from nonnull to nullable I will trust the cast (it is probable there for a reason, because this cast does not suppress any warnings or errors).
+- But what should we do about null checks?::
+
+__nonnull id takesNonnull(__nonnull id x) {
+if (x == nil) {
+// Defensive backward compatible code:
+
+return nil; - Should the analyzer cover this piece of code? Should we require the cast (__nonnull)nil?
+}
+
+}
+
+There are these directions:
+- We can either take the branch; this way the branch is analyzed
+	- Should we not warn about any nullability issues in that branch? Probably not, it is ok to break the nullability postconditions when the nullability preconditions are violated.
+- We can assume that these pointers are not null and we lose coverage with the analyzer. (This can be implemented either in constraint solver or in the checker itself.)
+
+Other Issues to keep in mind/take care of:
+Messaging:
+- Sending a message to a nullable pointer
+	- Even though the method might return a nonnull pointer, when it was sent to a nullable pointer the return type will be nullable.
+	- The result is nullable unless the receiver is known to be non null.
+- Sending a message to a unspecified or nonnull pointer
+	- If the pointer is not assumed to be nil, we should be optimistic and use the nullability implied by the method.
+- This will not happen automatically, since the AST will have null unspecified in this case.
+
+Inlining
+
+
+A symbol may need to be treated differently inside an inlined body. For example, consider these conversions from nonnull to nullable in presence of inlining::
+
+id obj = getNonnull();
+takesNullable(obj);
+takesNonnull(obj);
+
+void takesNullable(nullable id obj) {
+   obj-ivar // we should assume obj is nullable and warn here
+}
+   
+With no special treatment, when the takesNullable is inlined the analyzer will not warn when the obj symbol is dereferenced. One solution for this is to reanalyze takesNullable as a top level function to get possible violations. The alternative method, deducing nullability information from the arguments after inlining is not robust enough (for example there might be more parameters with different nullability, but in the given path the 

Re: [PATCH] D11297: PR17829: Functions declared extern "C" with a name matching a mangled C++ function are allowed

2015-08-31 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246438: PR17829: Proper diagnostic of mangled names 
conflicts (authored by asbokhan).

Changed prior to commit:
  http://reviews.llvm.org/D11297?vs=33401=33577#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11297

Files:
  cfe/trunk/lib/CodeGen/CGCXX.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp

Index: cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp
===
--- cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp
+++ cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify -DTEST1
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify -DTEST2
+
+#ifdef TEST1
 
 // rdar://15522601
 class MyClass {
@@ -8,3 +11,34 @@
 extern "C" {
   void _ZN7MyClass4methEv() { } // expected-error {{definition with same mangled name as another definition}}
 }
+
+#elif TEST2
+
+// We expect no warnings here, as there is only declaration of _ZN1TD1Ev function, no definitions.
+extern "C" void _ZN1TD1Ev();
+struct T {
+  ~T() {}
+};
+
+void foo() {
+  _ZN1TD1Ev();
+  T t;
+}
+
+extern "C" void _ZN2T2D2Ev() {}; // expected-note {{previous definition is here}}
+
+struct T2 {
+  ~T2() {} // expected-error {{definition with same mangled name as another definition}}
+};
+
+void bar() {
+  _ZN2T2D2Ev();
+  T2 t;
+}
+
+#else
+
+#error Unknwon test
+
+#endif
+
Index: cfe/trunk/lib/CodeGen/CodeGenModule.h
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.h
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h
@@ -342,6 +342,17 @@
   typedef llvm::StringMap ReplacementsTy;
   ReplacementsTy Replacements;
 
+  /// List of global values to be replaced with something else. Used when we
+  /// want to replace a GlobalValue but can't identify it by its mangled name
+  /// anymore (because the name is already taken).
+  llvm::SmallVector
+GlobalValReplacements;
+
+  /// Set of global decls for which we already diagnosed mangled name conflict.
+  /// Required to not issue a warning (on a mangling conflict) multiple times
+  /// for the same decl.
+  llvm::DenseSet DiagnosedConflictingDefinitions;
+
   /// A queue of (optional) vtables to consider emitting.
   std::vector DeferredVTables;
 
@@ -682,18 +693,7 @@
 llvm_unreachable("unknown visibility!");
   }
 
-  llvm::Constant *GetAddrOfGlobal(GlobalDecl GD) {
-if (isa(GD.getDecl()))
-  return getAddrOfCXXStructor(cast(GD.getDecl()),
-  getFromCtorType(GD.getCtorType()));
-else if (isa(GD.getDecl()))
-  return getAddrOfCXXStructor(cast(GD.getDecl()),
-  getFromDtorType(GD.getDtorType()));
-else if (isa(GD.getDecl()))
-  return GetAddrOfFunction(GD);
-else
-  return GetAddrOfGlobalVar(cast(GD.getDecl()));
-  }
+  llvm::Constant *GetAddrOfGlobal(GlobalDecl GD, bool IsForDefinition = false);
 
   /// Will return a global variable of the given type. If a variable with a
   /// different type already exists then a new  variable with the right type
@@ -725,7 +725,8 @@
   /// function will use the specified type if it has to create it.
   llvm::Constant *GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty = 0,
 bool ForVTable = false,
-bool DontDefer = false);
+bool DontDefer = false,
+bool IsForDefinition = false);
 
   /// Get the address of the RTTI descriptor for the given type.
   llvm::Constant *GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH = false);
@@ -847,11 +848,11 @@
  StructorType Type);
 
   /// Return the address of the constructor/destructor of the given type.
-  llvm::GlobalValue *
+  llvm::Constant *
   getAddrOfCXXStructor(const CXXMethodDecl *MD, StructorType Type,
const CGFunctionInfo *FnInfo = nullptr,
llvm::FunctionType *FnType = nullptr,
-   bool DontDefer = false);
+   bool DontDefer = false, bool IsForDefinition = false);
 
   /// Given a builtin id for a function like "__builtin_fabsf", return a
   /// Function* for "fabsf".
@@ -1122,6 +1123,8 @@
 
   void addReplacement(StringRef Name, llvm::Constant *C);
 
+  void addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C);
+
   /// \brief Emit a code for threadprivate directive.
   /// \param D Threadprivate declaration.
   void EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D);
@@ -1148,7 

Re: [PATCH] D12444: [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)

2015-09-01 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246618: [Sema] Avoid crash on tag-type mismatch (Fixes 
PR24610) (authored by vedantk).

Changed prior to commit:
  http://reviews.llvm.org/D12444?vs=33623=33777#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12444

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Sema/enum.c

Index: cfe/trunk/test/Sema/enum.c
===
--- cfe/trunk/test/Sema/enum.c
+++ cfe/trunk/test/Sema/enum.c
@@ -119,3 +119,7 @@
 
 typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
 int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
+
+// PR24610
+enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
+typedef struct Color NewColor; // expected-error {{use of 'Color' with tag 
type that does not match previous declaration}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -3560,6 +3560,9 @@
 
 void Sema::setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
 TypedefNameDecl *NewTD) {
+  if (TagFromDeclSpec->isInvalidDecl())
+return;
+
   // Do nothing if the tag already has a name for linkage purposes.
   if (TagFromDeclSpec->hasNameForLinkage())
 return;


Index: cfe/trunk/test/Sema/enum.c
===
--- cfe/trunk/test/Sema/enum.c
+++ cfe/trunk/test/Sema/enum.c
@@ -119,3 +119,7 @@
 
 typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
 int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
+
+// PR24610
+enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
+typedef struct Color NewColor; // expected-error {{use of 'Color' with tag type that does not match previous declaration}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -3560,6 +3560,9 @@
 
 void Sema::setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
 TypedefNameDecl *NewTD) {
+  if (TagFromDeclSpec->isInvalidDecl())
+return;
+
   // Do nothing if the tag already has a name for linkage purposes.
   if (TagFromDeclSpec->hasNameForLinkage())
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12684: [INSTALL.txt] Fix formatting - 80 character line

2015-09-07 Thread beltex via cfe-commits
beltex created this revision.
beltex added a subscriber: cfe-commits.

http://reviews.llvm.org/D12684

Files:
  INSTALL.txt

Index: INSTALL.txt
===
--- INSTALL.txt
+++ INSTALL.txt
@@ -44,6 +44,6 @@
 compiler and header files into the prefix directory selected when LLVM was
 configured.
 
-The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc 
like command line
-interface. See the man page for clang (installed into $prefix/share/man/man1)
-for more information.
+The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc 
like
+command line interface. See the man page for clang (installed into
+$prefix/share/man/man1) for more information.


Index: INSTALL.txt
===
--- INSTALL.txt
+++ INSTALL.txt
@@ -44,6 +44,6 @@
 compiler and header files into the prefix directory selected when LLVM was
 configured.
 
-The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like command line
-interface. See the man page for clang (installed into $prefix/share/man/man1)
-for more information.
+The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like
+command line interface. See the man page for clang (installed into
+$prefix/share/man/man1) for more information.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12002: Initial WebAssembly support in clang

2015-09-03 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246814: [WebAssembly] Initial WebAssembly support in clang 
(authored by djg).

Changed prior to commit:
  http://reviews.llvm.org/D12002?vs=33637=33985#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12002

Files:
  cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
  cfe/trunk/include/clang/Basic/TargetBuiltins.h
  cfe/trunk/include/clang/Basic/TargetCXXABI.h
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/module.modulemap
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/CodeGen/align-wasm.c
  cfe/trunk/test/CodeGen/builtins-wasm.c
  cfe/trunk/test/CodeGen/target-data.c
  cfe/trunk/test/CodeGen/wasm-arguments.c
  cfe/trunk/test/CodeGen/wasm-regparm.c
  cfe/trunk/test/CodeGenCXX/constructor-destructor-return-this.cpp
  cfe/trunk/test/CodeGenCXX/member-alignment.cpp
  cfe/trunk/test/CodeGenCXX/member-function-pointers.cpp
  cfe/trunk/test/CodeGenCXX/static-init-wasm.cpp
  cfe/trunk/test/CodeGenCXX/wasm-args-returns.cpp
  cfe/trunk/test/Driver/thread-model.c
  cfe/trunk/test/Driver/wasm32-unknown-unknown.cpp
  cfe/trunk/test/Driver/wasm64-unknown-unknown.cpp
  cfe/trunk/test/Preprocessor/init.c
  cfe/trunk/test/Preprocessor/wasm-target-features.c

Index: cfe/trunk/include/clang/Basic/TargetBuiltins.h
===
--- cfe/trunk/include/clang/Basic/TargetBuiltins.h
+++ cfe/trunk/include/clang/Basic/TargetBuiltins.h
@@ -185,6 +185,17 @@
 LastTSBuiltin
 };
   }
+
+  /// \brief WebAssembly builtins
+  namespace WebAssembly {
+enum {
+  LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,
+#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
+#include "clang/Basic/BuiltinsWebAssembly.def"
+  LastTSBuiltin
+};
+  }
+
 } // end namespace clang.
 
 #endif
Index: cfe/trunk/include/clang/Basic/TargetCXXABI.h
===
--- cfe/trunk/include/clang/Basic/TargetCXXABI.h
+++ cfe/trunk/include/clang/Basic/TargetCXXABI.h
@@ -85,6 +85,21 @@
 ///   - representation of member function pointers adjusted as in ARM.
 GenericMIPS,
 
+/// The WebAssembly ABI is a modified version of the Itanium ABI.
+///
+/// The changes from the Itanium ABI are:
+///   - representation of member function pointers is adjusted, as in ARM;
+///   - member functions are not specially aligned;
+///   - constructors and destructors return 'this', as in ARM;
+///   - guard variables are 32-bit on wasm32, as in ARM;
+///   - unused bits of guard variables are reserved, as in ARM;
+///   - inline functions are never key functions, as in ARM;
+///   - C++11 POD rules are used for tail padding, as in iOS64.
+///
+/// TODO: At present the WebAssembly ABI is not considered stable, so none
+/// of these details is necessarily final yet.
+WebAssembly,
+
 /// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and
 /// compatible compilers).
 ///
@@ -121,6 +136,7 @@
 case iOS:
 case iOS64:
 case GenericMIPS:
+case WebAssembly:
   return true;
 
 case Microsoft:
@@ -138,14 +154,44 @@
 case iOS:
 case iOS64:
 case GenericMIPS:
+case WebAssembly:
   return false;
 
 case Microsoft:
   return true;
 }
 llvm_unreachable("bad ABI kind");
   }
 
+  /// \brief Are member functions differently aligned?
+  ///
+  /// Many Itanium-style C++ ABIs require member functions to be aligned, so
+  /// that a pointer to such a function is guaranteed to have a zero in the
+  /// least significant bit, so that pointers to member functions can use that
+  /// bit to distinguish between virtual and non-virtual functions. However,
+  /// some Itanium-style C++ ABIs differentiate between virtual and non-virtual
+  /// functions via other means, and consequently don't require that member
+  /// functions be aligned.
+  bool areMemberFunctionsAligned() const {
+switch (getKind()) {
+case WebAssembly:
+  // WebAssembly doesn't require any special alignment for member functions.
+  return false;
+case GenericARM:
+case GenericAArch64:
+case GenericMIPS:
+  // TODO: ARM-style pointers to member functions put the discriminator in
+  //   the this adjustment, so they don't require functions to have any
+  //   special alignment and could therefore also return false.
+case GenericItanium:
+case iOS:
+case iOS64:
+case Microsoft:
+  

Re: [PATCH] D12684: [INSTALL.txt] Fix formatting - 80 character line

2015-09-13 Thread beltex via cfe-commits
beltex added a comment.

Thanks! My first patch! :)


http://reviews.llvm.org/D12684



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


Re: [PATCH] D12684: [INSTALL.txt] Fix formatting - 80 character line

2015-09-13 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247530: [docs] NFC: Fix line formatting in INSTALL.txt 
(authored by vedantk).

Changed prior to commit:
  http://reviews.llvm.org/D12684?vs=34178=34650#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12684

Files:
  cfe/trunk/INSTALL.txt

Index: cfe/trunk/INSTALL.txt
===
--- cfe/trunk/INSTALL.txt
+++ cfe/trunk/INSTALL.txt
@@ -44,6 +44,6 @@
 compiler and header files into the prefix directory selected when LLVM was
 configured.
 
-The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc 
like command line
-interface. See the man page for clang (installed into $prefix/share/man/man1)
-for more information.
+The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc 
like
+command line interface. See the man page for clang (installed into
+$prefix/share/man/man1) for more information.


Index: cfe/trunk/INSTALL.txt
===
--- cfe/trunk/INSTALL.txt
+++ cfe/trunk/INSTALL.txt
@@ -44,6 +44,6 @@
 compiler and header files into the prefix directory selected when LLVM was
 configured.
 
-The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like command line
-interface. See the man page for clang (installed into $prefix/share/man/man1)
-for more information.
+The Clang compiler is available as 'clang' and 'clang++'. It supports a gcc like
+command line interface. See the man page for clang (installed into
+$prefix/share/man/man1) for more information.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D12840: [cfe-dev] Enabling ThreadSanitizer on PPC64(BE/LE) plarforms

2015-09-14 Thread Simone via cfe-commits
simoatze created this revision.
simoatze added reviewers: kbarton, nemanjai, wschmidt.
simoatze added a subscriber: cfe-commits.

Enabling ThreadSanitizer on PPC64(BE/LE) platforms. The current patch will 
enable the flag "-fsanitize=thread" on Clang on PPC64 systems.

http://reviews.llvm.org/D12840

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3759,7 +3759,7 @@
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64)
 Res |= SanitizerKind::Leak;
-  if (IsX86_64 || IsMIPS64 || IsAArch64)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;
   if (IsX86_64 || IsMIPS64 || IsPowerPC64)
 Res |= SanitizerKind::Memory;


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3759,7 +3759,7 @@
 Res |= SanitizerKind::DataFlow;
   if (IsX86_64 || IsMIPS64)
 Res |= SanitizerKind::Leak;
-  if (IsX86_64 || IsMIPS64 || IsAArch64)
+  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64)
 Res |= SanitizerKind::Thread;
   if (IsX86_64 || IsMIPS64 || IsPowerPC64)
 Res |= SanitizerKind::Memory;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12381: [Static Analyzer] Merge the Objective-C Generics Checker into Dynamic Type Propagation checker.

2015-09-13 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247532: [Static Analyzer] Merge the Objective-C Generics 
Checker into Dynamic Type… (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D12381?vs=34606=34651#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12381

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  cfe/trunk/test/Analysis/generics.m

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -53,7 +53,6 @@
   ObjCAtSyncChecker.cpp
   ObjCContainersASTChecker.cpp
   ObjCContainersChecker.cpp
-  ObjCGenericsChecker.cpp
   ObjCMissingSuperCallChecker.cpp
   ObjCSelfInitChecker.cpp
   ObjCUnusedIVarsChecker.cpp
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -7,11 +7,23 @@
 //
 //===--===//
 //
+// This file contains two checkers. One helps the static analyzer core to track
+// types, the other does type inference on Obj-C generics and report type
+// errors.
+//
+// Dynamic Type Propagation:
 // This checker defines the rules for dynamic type gathering and propagation.
 //
+// Generics Checker for Objective-C:
+// This checker tries to find type errors that the compiler is not able to catch
+// due to the implicit conversions that were introduced for backward
+// compatibility.
+//
 //===--===//
 
 #include "ClangSACheckers.h"
+#include "clang/AST/ParentMap.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
@@ -24,25 +36,83 @@
 using namespace clang;
 using namespace ento;
 
+// ProgramState trait - The type inflation is tracked by DynamicTypeMap. This is
+// an auxiliary map that tracks more information about generic types, because in
+// some cases the most derived type is not the most informative one about the
+// type parameters. This types that are stored for each symbol in this map must
+// be specialized.
+REGISTER_MAP_WITH_PROGRAMSTATE(TypeParamMap, SymbolRef,
+   const ObjCObjectPointerType *)
+
 namespace {
 class DynamicTypePropagation:
 public Checker< check::PreCall,
 check::PostCall,
 check::DeadSymbols,
-check::PostStmt,
-check::PostStmt > {
+check::PostStmt,
+check::PostStmt,
+check::PreObjCMessage,
+check::PostObjCMessage > {
   const ObjCObjectType *getObjectTypeForAllocAndNew(const ObjCMessageExpr *MsgE,
 CheckerContext ) const;
 
   /// \brief Return a better dynamic type if one can be derived from the cast.
   const ObjCObjectPointerType *getBetterObjCType(const Expr *CastE,
  CheckerContext ) const;
+
+  ExplodedNode *dynamicTypePropagationOnCasts(const CastExpr *CE,
+  ProgramStateRef ,
+  CheckerContext ) const;
+
+  mutable std::unique_ptr ObjCGenericsBugType;
+  void initBugType() const {
+if (!ObjCGenericsBugType)
+  ObjCGenericsBugType.reset(
+  new BugType(this, "Generics", categories::CoreFoundationObjectiveC));
+  }
+
+  class GenericsBugVisitor : public BugReporterVisitorImpl {
+  public:
+GenericsBugVisitor(SymbolRef S) : Sym(S) {}
+
+void Profile(llvm::FoldingSetNodeID ) const override {
+  static int X = 0;
+  ID.AddPointer();
+  ID.AddPointer(Sym);
+}
+
+PathDiagnosticPiece *VisitNode(const ExplodedNode *N,
+   const ExplodedNode *PrevN,
+   BugReporterContext ,
+   BugReport ) override;
+
+  private:
+// The tracked symbol.
+SymbolRef Sym;
+  };
+
+  void reportGenericsBug(const ObjCObjectPointerType *From,
+ const ObjCObjectPointerType *To, ExplodedNode *N,
+ SymbolRef Sym, CheckerContext ,
+ const Stmt *ReportedNode = nullptr) const;
+
+  void checkReturnType(const ObjCMessageExpr *MessageExpr,
+   const ObjCObjectPointerType *TrackedType, SymbolRef Sym,
+   

Re: [PATCH] D12862: [WebAssembly] Define the atomic type sizes

2015-09-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247624: [WebAssembly] Define the atomic type sizes (authored 
by djg).

Changed prior to commit:
  http://reviews.llvm.org/D12862?vs=34731=34739#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12862

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/init.c

Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -8472,17 +8472,17 @@
 // WEBASSEMBLY32-NEXT:#define __FLT_MIN_EXP__ (-125){{$}}
 // WEBASSEMBLY32-NEXT:#define __FLT_MIN__ 1.17549435e-38F{{$}}
 // WEBASSEMBLY32-NEXT:#define __FLT_RADIX__ 2{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_BOOL_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_BOOL_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2{{$}}
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2{{$}}
 // WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1{{$}}
-// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1{{$}}
+// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2{{$}}
 // WEBASSEMBLY32-NEXT:#define __GNUC_MINOR__ {{.}}
 // WEBASSEMBLY32-NEXT:#define __GNUC_PATCHLEVEL__ {{.}}
 // WEBASSEMBLY32-NEXT:#define __GNUC_STDC_INLINE__ 1{{$}}
@@ -8586,7 +8586,7 @@
 // WEBASSEMBLY32-NOT:#define __REGISTER_PREFIX__
 // WEBASSEMBLY32-NEXT:#define __SCHAR_MAX__ 127{{$}}
 // WEBASSEMBLY32-NEXT:#define __SHRT_MAX__ 32767{{$}}
-// WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_MAX__ 2147483647{{$}}
+// WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_MAX__ 2147483647L{{$}}
 // WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_WIDTH__ 32{{$}}
 // WEBASSEMBLY32-NEXT:#define __SIZEOF_DOUBLE__ 8{{$}}
 // WEBASSEMBLY32-NEXT:#define __SIZEOF_FLOAT__ 4{{$}}
@@ -8788,17 +8788,17 @@
 // WEBASSEMBLY64-NEXT:#define __FLT_MIN_EXP__ (-125){{$}}
 // WEBASSEMBLY64-NEXT:#define __FLT_MIN__ 1.17549435e-38F{{$}}
 // WEBASSEMBLY64-NEXT:#define __FLT_RADIX__ 2{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_BOOL_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 1{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_BOOL_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2{{$}}
 // WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1{{$}}
-// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1{{$}}
+// WEBASSEMBLY64-NEXT:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2{{$}}
 // WEBASSEMBLY64-NEXT:#define __GNUC_MINOR__ {{.}}
 // WEBASSEMBLY64-NEXT:#define __GNUC_PATCHLEVEL__ {{.}}
 // WEBASSEMBLY64-NEXT:#define __GNUC_STDC_INLINE__ 1{{$}}
@@ -8902,8 +8902,8 @@
 // WEBASSEMBLY64-NOT:#define __REGISTER_PREFIX__
 // WEBASSEMBLY64-NEXT:#define __SCHAR_MAX__ 127{{$}}
 // WEBASSEMBLY64-NEXT:#define __SHRT_MAX__ 32767{{$}}
-// WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_MAX__ 2147483647{{$}}
-// WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_WIDTH__ 32{{$}}
+// WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_MAX__ 9223372036854775807L{{$}}
+// WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_WIDTH__ 

Re: [PATCH] D12858: [Static Analyzer] Turn on some nullability checks by default.

2015-09-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247614: [Static Analyzer] Turn on some nullability checks by 
default. (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D12858?vs=34720=34726#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12858

Files:
  cfe/trunk/lib/Driver/Tools.cpp

Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -3322,6 +3322,11 @@
   CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mktemp");
   CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mkstemp");
   CmdArgs.push_back("-analyzer-checker=security.insecureAPI.vfork");
+
+  // Default nullability checks.
+  CmdArgs.push_back("-analyzer-checker=nullability.NullPassedToNonnull");
+  CmdArgs.push_back(
+  "-analyzer-checker=nullability.NullReturnedFromNonnull");
 }
 
 // Set the output format. The default is plist, for (lame) historical


Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -3322,6 +3322,11 @@
   CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mktemp");
   CmdArgs.push_back("-analyzer-checker=security.insecureAPI.mkstemp");
   CmdArgs.push_back("-analyzer-checker=security.insecureAPI.vfork");
+
+  // Default nullability checks.
+  CmdArgs.push_back("-analyzer-checker=nullability.NullPassedToNonnull");
+  CmdArgs.push_back(
+  "-analyzer-checker=nullability.NullReturnedFromNonnull");
 }
 
 // Set the output format. The default is plist, for (lame) historical
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12848: [Static Analyzer] Nullability checker optimization.

2015-09-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247612: [Static Analyzer] Nullability checker optimization. 
(authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D12848?vs=34693=34725#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12848

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -406,12 +406,17 @@
 /// Cleaning up the program state.
 void NullabilityChecker::checkDeadSymbols(SymbolReaper ,
   CheckerContext ) const {
+  if (!SR.hasDeadSymbols())
+return;
+
   ProgramStateRef State = C.getState();
   NullabilityMapTy Nullabilities = State->get();
   for (NullabilityMapTy::iterator I = Nullabilities.begin(),
   E = Nullabilities.end();
I != E; ++I) {
-if (!SR.isLiveRegion(I->first)) {
+const auto *Region = I->first->getAs();
+assert(Region && "Non-symbolic region is tracked.");
+if (SR.isDead(Region->getSymbol())) {
   State = State->remove(I->first);
 }
   }


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -406,12 +406,17 @@
 /// Cleaning up the program state.
 void NullabilityChecker::checkDeadSymbols(SymbolReaper ,
   CheckerContext ) const {
+  if (!SR.hasDeadSymbols())
+return;
+
   ProgramStateRef State = C.getState();
   NullabilityMapTy Nullabilities = State->get();
   for (NullabilityMapTy::iterator I = Nullabilities.begin(),
   E = Nullabilities.end();
I != E; ++I) {
-if (!SR.isLiveRegion(I->first)) {
+const auto *Region = I->first->getAs();
+assert(Region && "Non-symbolic region is tracked.");
+if (SR.isDead(Region->getSymbol())) {
   State = State->remove(I->first);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12402: PR24595: clang-cl fails to compile vswriter.h header from Windows SDK 8.1 in 32 bit mode

2015-09-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247619: PR24595: Ignore calling convention modifiers for 
structors in MS ABI. (authored by asbokhan).

Changed prior to commit:
  http://reviews.llvm.org/D12402?vs=34477=34735#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12402

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/DeclSpec.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/DeclSpec.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp
  cfe/trunk/test/SemaCXX/decl-microsoft-call-conv.cpp

Index: cfe/trunk/include/clang/Sema/DeclSpec.h
===
--- cfe/trunk/include/clang/Sema/DeclSpec.h
+++ cfe/trunk/include/clang/Sema/DeclSpec.h
@@ -2208,6 +2208,9 @@
   /// redeclaration time if the decl is static.
   bool isStaticMember();
 
+  /// Returns true if this declares a constructor or a destructor.
+  bool isCtorOrDtor();
+
   void setRedeclaration(bool Val) { Redeclaration = Val; }
   bool isRedeclaration() const { return Redeclaration; }
 };
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -2919,7 +2919,8 @@
   /// Adjust the calling convention of a method to be the ABI default if it
   /// wasn't specified explicitly.  This handles method types formed from
   /// function type typedefs and typename template arguments.
-  void adjustMemberFunctionCC(QualType , bool IsStatic);
+  void adjustMemberFunctionCC(QualType , bool IsStatic, bool IsCtorOrDtor,
+  SourceLocation Loc);
 
   // Check if there is an explicit attribute, but only look through parens.
   // The intent is to look for an attribute on the current declarator, but not
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2375,6 +2375,9 @@
 def warn_cconv_varargs : Warning<
   "%0 calling convention ignored on variadic function">,
   InGroup;
+def warn_cconv_structors : Warning<
+  "%0 calling convention ignored on constructor/destructor">,
+  InGroup;
 def err_regparm_mismatch : Error<"function declared with regparm(%0) "
   "attribute was previously declared "
   "%plural{0:without the regparm|:with the regparm(%1)}1 attribute">;
Index: cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp
===
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-structors.cpp
@@ -5,6 +5,7 @@
 // RUN: FileCheck --check-prefix DTORS %s < %t
 // RUN: FileCheck --check-prefix DTORS2 %s < %t
 // RUN: FileCheck --check-prefix DTORS3 %s < %t
+// RUN: FileCheck --check-prefix DTORS4 %s < %t
 //
 // RUN: %clang_cc1 -emit-llvm %s -o - -mconstructor-aliases -triple=x86_64-pc-win32 -fno-rtti | FileCheck --check-prefix DTORS-X64 %s
 
@@ -407,9 +408,7 @@
 // CHECK:   (%"struct.test1::B"* returned %this, i32* %a, i32 %is_most_derived)
 // CHECK: define %"struct.test1::B"* @"\01??0B@test1@@QAA@PBDZZ"
 // CHECK:   (%"struct.test1::B"* returned %this, i32 %is_most_derived, i8* %a, ...)
-
-// FIXME: This should be x86_thiscallcc.  MSVC ignores explicit CCs on structors.
-// CHECK: define %"struct.test1::B"* @"\01??0B@test1@@QAA@PAF@Z"
+// CHECK: define x86_thiscallcc %"struct.test1::B"* @"\01??0B@test1@@QAE@PAF@Z"
 // CHECK:   (%"struct.test1::B"* returned %this, i16* %a, i32 %is_most_derived)
 
 void construct_b() {
@@ -458,3 +457,18 @@
 // CHECK:   (%"struct.(anonymous namespace)::A"* %this, i32 %should_call_delete)
 // CHECK: define internal x86_thiscallcc void @"\01??1A@?A@@UAE@XZ"
 // CHECK:   (%"struct.(anonymous namespace)::A"* %this)
+
+// Check that we correctly transform __stdcall to __thiscall for ctors and
+// dtors.
+class G {
+ public:
+  __stdcall G() {};
+// DTORS4: define linkonce_odr x86_thiscallcc %class.G* @"\01??0G@@QAE@XZ"
+  __stdcall ~G() {};
+// DTORS4: define linkonce_odr x86_thiscallcc void @"\01??1G@@QAE@XZ"
+};
+
+extern void testG() {
+  G g;
+}
+
Index: cfe/trunk/test/SemaCXX/decl-microsoft-call-conv.cpp
===
--- cfe/trunk/test/SemaCXX/decl-microsoft-call-conv.cpp
+++ cfe/trunk/test/SemaCXX/decl-microsoft-call-conv.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++14 -triple i686-pc-win32 -fms-extensions -verify %s
+// RUN: %clang_cc1 -std=c++14 -triple i686-pc-win32 -fms-extensions -DMSABI -verify %s
 // RUN: %clang_cc1 -std=c++14 -triple i686-pc-mingw32 -verify %s
 // RUN: %clang_cc1 -std=c++14 -triple 

Re: [PATCH] D12861: [WebAssembly] Use "long long" for int_fast64_t and int_least64_t on wasm64

2015-09-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247622: [WebAssembly] Use "long long" for int_fast64_t and 
int_least64_t on wasm64 (authored by djg).

Changed prior to commit:
  http://reviews.llvm.org/D12861?vs=34727=34738#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12861

Files:
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/init.c

Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -8845,10 +8845,10 @@
 // WEBASSEMBLY64-NEXT:#define __INT_FAST32_FMTi__ "i"{{$}}
 // WEBASSEMBLY64-NEXT:#define __INT_FAST32_MAX__ 2147483647{{$}}
 // WEBASSEMBLY64-NEXT:#define __INT_FAST32_TYPE__ int{{$}}
-// WEBASSEMBLY64-NEXT:#define __INT_FAST64_FMTd__ "ld"{{$}}
-// WEBASSEMBLY64-NEXT:#define __INT_FAST64_FMTi__ "li"{{$}}
-// WEBASSEMBLY64-NEXT:#define __INT_FAST64_MAX__ 9223372036854775807L{{$}}
-// WEBASSEMBLY64-NEXT:#define __INT_FAST64_TYPE__ long int{{$}}
+// WEBASSEMBLY64-NEXT:#define __INT_FAST64_FMTd__ "lld"{{$}}
+// WEBASSEMBLY64-NEXT:#define __INT_FAST64_FMTi__ "lli"{{$}}
+// WEBASSEMBLY64-NEXT:#define __INT_FAST64_MAX__ 9223372036854775807LL{{$}}
+// WEBASSEMBLY64-NEXT:#define __INT_FAST64_TYPE__ long long int{{$}}
 // WEBASSEMBLY64-NEXT:#define __INT_FAST8_FMTd__ "hhd"{{$}}
 // WEBASSEMBLY64-NEXT:#define __INT_FAST8_FMTi__ "hhi"{{$}}
 // WEBASSEMBLY64-NEXT:#define __INT_FAST8_MAX__ 127{{$}}
@@ -8861,10 +8861,10 @@
 // WEBASSEMBLY64-NEXT:#define __INT_LEAST32_FMTi__ "i"{{$}}
 // WEBASSEMBLY64-NEXT:#define __INT_LEAST32_MAX__ 2147483647{{$}}
 // WEBASSEMBLY64-NEXT:#define __INT_LEAST32_TYPE__ int{{$}}
-// WEBASSEMBLY64-NEXT:#define __INT_LEAST64_FMTd__ "ld"{{$}}
-// WEBASSEMBLY64-NEXT:#define __INT_LEAST64_FMTi__ "li"{{$}}
-// WEBASSEMBLY64-NEXT:#define __INT_LEAST64_MAX__ 9223372036854775807L{{$}}
-// WEBASSEMBLY64-NEXT:#define __INT_LEAST64_TYPE__ long int{{$}}
+// WEBASSEMBLY64-NEXT:#define __INT_LEAST64_FMTd__ "lld"{{$}}
+// WEBASSEMBLY64-NEXT:#define __INT_LEAST64_FMTi__ "lli"{{$}}
+// WEBASSEMBLY64-NEXT:#define __INT_LEAST64_MAX__ 9223372036854775807LL{{$}}
+// WEBASSEMBLY64-NEXT:#define __INT_LEAST64_TYPE__ long long int{{$}}
 // WEBASSEMBLY64-NEXT:#define __INT_LEAST8_FMTd__ "hhd"{{$}}
 // WEBASSEMBLY64-NEXT:#define __INT_LEAST8_FMTi__ "hhi"{{$}}
 // WEBASSEMBLY64-NEXT:#define __INT_LEAST8_MAX__ 127{{$}}
@@ -8989,12 +8989,12 @@
 // WEBASSEMBLY64-NEXT:#define __UINT_FAST32_FMTx__ "x"{{$}}
 // WEBASSEMBLY64-NEXT:#define __UINT_FAST32_MAX__ 4294967295U{{$}}
 // WEBASSEMBLY64-NEXT:#define __UINT_FAST32_TYPE__ unsigned int{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_FMTX__ "lX"{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_FMTo__ "lo"{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_FMTu__ "lu"{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_FMTx__ "lx"{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_MAX__ 18446744073709551615UL{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_TYPE__ long unsigned int{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_FMTX__ "llX"{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_FMTo__ "llo"{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_FMTu__ "llu"{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_FMTx__ "llx"{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_MAX__ 18446744073709551615ULL{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_FAST64_TYPE__ long long unsigned int{{$}}
 // WEBASSEMBLY64-NEXT:#define __UINT_FAST8_FMTX__ "hhX"{{$}}
 // WEBASSEMBLY64-NEXT:#define __UINT_FAST8_FMTo__ "hho"{{$}}
 // WEBASSEMBLY64-NEXT:#define __UINT_FAST8_FMTu__ "hhu"{{$}}
@@ -9013,12 +9013,12 @@
 // WEBASSEMBLY64-NEXT:#define __UINT_LEAST32_FMTx__ "x"{{$}}
 // WEBASSEMBLY64-NEXT:#define __UINT_LEAST32_MAX__ 4294967295U{{$}}
 // WEBASSEMBLY64-NEXT:#define __UINT_LEAST32_TYPE__ unsigned int{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_FMTX__ "lX"{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_FMTo__ "lo"{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_FMTu__ "lu"{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_FMTx__ "lx"{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_MAX__ 18446744073709551615UL{{$}}
-// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_TYPE__ long unsigned int{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_FMTX__ "llX"{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_FMTo__ "llo"{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_FMTu__ "llu"{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_FMTx__ "llx"{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL{{$}}
+// WEBASSEMBLY64-NEXT:#define __UINT_LEAST64_TYPE__ long long unsigned int{{$}}
 // WEBASSEMBLY64-NEXT:#define __UINT_LEAST8_FMTX__ "hhX"{{$}}
 // WEBASSEMBLY64-NEXT:#define __UINT_LEAST8_FMTo__ "hho"{{$}}
 // WEBASSEMBLY64-NEXT:#define __UINT_LEAST8_FMTu__ "hhu"{{$}}
Index: 

Re: [PATCH] D12652: [Static Analyzer] Lambda support.

2015-09-11 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247426: [Static Analyzer] Lambda support. (authored by 
xazax).

Changed prior to commit:
  http://reviews.llvm.org/D12652?vs=34498=34555#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12652

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
  cfe/trunk/test/Analysis/dead-stores.cpp
  cfe/trunk/test/Analysis/lambda-notes.cpp
  cfe/trunk/test/Analysis/lambdas.cpp
  cfe/trunk/test/Analysis/temporaries.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
@@ -256,6 +256,9 @@
   /// \sa getMaxNodesPerTopLevelFunction
   Optional MaxNodesPerTopLevelFunction;
 
+  /// \sa shouldInlineLambdas
+  Optional InlineLambdas;
+
   /// A helper function that retrieves option for a given full-qualified
   /// checker name.
   /// Options for checkers can be specified via 'analyzer-config' command-line
@@ -509,6 +512,10 @@
   /// This is controlled by the 'max-nodes' config option.
   unsigned getMaxNodesPerTopLevelFunction();
 
+  /// Returns true if lambdas should be inlined. Otherwise a sink node will be
+  /// generated each time a LambdaExpr is visited.
+  bool shouldInlineLambdas();
+
 public:
   AnalyzerOptions() :
 AnalysisStoreOpt(RegionStoreModel),
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -341,6 +341,10 @@
   void VisitBlockExpr(const BlockExpr *BE, ExplodedNode *Pred, 
   ExplodedNodeSet );
 
+  /// VisitLambdaExpr - Transfer function logic for LambdaExprs.
+  void VisitLambdaExpr(const LambdaExpr *LE, ExplodedNode *Pred, 
+   ExplodedNodeSet );
+
   /// VisitBinaryOperator - Transfer function logic for binary operators.
   void VisitBinaryOperator(const BinaryOperator* B, ExplodedNode *Pred, 
ExplodedNodeSet );
Index: cfe/trunk/test/Analysis/dead-stores.cpp
===
--- cfe/trunk/test/Analysis/dead-stores.cpp
+++ cfe/trunk/test/Analysis/dead-stores.cpp
@@ -174,3 +174,17 @@
   return radar13213575_testit(5) + radar13213575_testit(3);
 }
 
+//===--===//
+// Dead store checking involving lambdas.
+//===--===//
+
+int basicLambda(int i, int j) {
+  i = 5; // no warning
+  j = 6; // no warning
+  [i] { (void)i; }();
+  [] { (void)j; }();
+  i = 2;
+  j = 3;
+  return i + j;
+}
+
Index: cfe/trunk/test/Analysis/lambda-notes.cpp
===
--- cfe/trunk/test/Analysis/lambda-notes.cpp
+++ cfe/trunk/test/Analysis/lambda-notes.cpp
@@ -0,0 +1,204 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze -analyzer-checker=core -analyzer-config inline-lambdas=true -analyzer-output plist -verify %s -o %t
+// RUN: FileCheck --input-file=%t %s
+
+
+// Diagnostic inside a lambda
+
+void diagnosticFromLambda() {
+  int i = 0;
+  [=] {
+int p = 5/i; // expected-warning{{Division by zero}}
+(void)p;
+  }();
+}
+
+// CHECK:  
+// CHECK:   
+// CHECK:path
+// CHECK:
+// CHECK: 
+// CHECK:  kindcontrol
+// CHECK:  edges
+// CHECK:   
+// CHECK:
+// CHECK: start
+// CHECK:  
+// CHECK:   
+// CHECK:line8
+// CHECK:col3
+// CHECK:file0
+// CHECK:   
+// CHECK:   
+// CHECK:line8
+// CHECK:col5
+// CHECK:file0
+// CHECK:   
+// CHECK:  
+// CHECK: end
+// CHECK:  
+// CHECK:   
+// CHECK:line9
+// CHECK:col3
+// CHECK:file0
+// CHECK:   
+// CHECK:   
+// CHECK:line9
+// CHECK:col3
+// CHECK:file0
+// CHECK:   
+// CHECK:  
+// CHECK:
+// CHECK:   
+// CHECK: 
+// CHECK: 
+// CHECK:  kindevent
+// CHECK:  location
+// CHECK:  
+// CHECK:   line9
+// CHECK:   col3
+// CHECK:   file0
+// CHECK:  
+// CHECK:  ranges
+// CHECK:  
+// CHECK:
+// CHECK: 
+// CHECK:  line9
+// CHECK:  

Re: [PATCH] D12743: [CodeGen] Teach SimplifyPersonality about the updated LandingPadInst

2015-09-11 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247437: [test] Specify exception object type in two tests 
(authored by vedantk).

Changed prior to commit:
  http://reviews.llvm.org/D12743?vs=34408=34560#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12743

Files:
  cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
  cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm

Index: cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
===
--- cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
+++ cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
@@ -11,7 +11,7 @@
 void foo() {
   try {
 throw 0;
-  } catch (...) {
+  } catch (int e) {
 return;
   }
 }
Index: cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
===
--- cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
+++ cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
@@ -5,7 +5,7 @@
   void foo() {
 try {
   throw 0;
-} catch (...) {
+} catch (int e) {
   return;
 }
   }


Index: cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
===
--- cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
+++ cfe/trunk/test/CodeGenObjCXX/personality-abuse.mm
@@ -11,7 +11,7 @@
 void foo() {
   try {
 throw 0;
-  } catch (...) {
+  } catch (int e) {
 return;
   }
 }
Index: cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
===
--- cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
+++ cfe/trunk/test/CodeGenObjCXX/exception-cxx.mm
@@ -5,7 +5,7 @@
   void foo() {
 try {
   throw 0;
-} catch (...) {
+} catch (int e) {
   return;
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11693: clang-format: Support generalized lambda captures.

2015-09-16 Thread strager via cfe-commits
strager updated this revision to Diff 34946.
strager marked 2 inline comments as done.
strager added a comment.

Address @djasper's comments.


http://reviews.llvm.org/D11693

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10057,6 +10057,18 @@
   // More complex introducers.
   verifyFormat("return [i, args...] {};");
 
+  // Lambdas with generalized captures.
+  verifyFormat("auto f = [b = d]() {};\n");
+  verifyFormat("auto f = [b = std::move(d)]() {};\n");
+  verifyFormat("auto f = [b = c, d = e, g]() {};\n");
+  verifyFormat("auto f = [b = a[3]]() {};\n");
+  verifyFormat("auto f = [InRange = a < b && b < c]() {};\n");
+  verifyFormat("auto f = [b = std::vector{1, 2, 3}]() {};\n");
+  verifyFormat("auto f = [b = std::vector{\n"
+   "  1, 2, 3,\n"
+   "}]() {};\n");
+  verifyFormat("return [b = std::vector()] {}();\n");
+
   // Not lambdas.
   verifyFormat("constexpr char hello[]{\"hello\"};");
   verifyFormat("double [](int i) { return 0; }\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1054,6 +1054,27 @@
 nextToken();
 if (FormatTok->is(tok::ellipsis))
   nextToken();
+if (FormatTok->is(tok::equal)) {
+  // Generalized lambda capture.
+  nextToken();
+  while (!eof()) {
+// FIXME: Once we have an expression parser in the UnwrappedLineParser,
+// replace this by using parseAssigmentExpression() inside. See also
+// parseBracedList. For now, parsing matching braces ([], (), {}) is
+// good enough.
+if (FormatTok->is(tok::l_paren)) {
+  parseParens();
+} else if (FormatTok->is(tok::l_square)) {
+  parseSquare();
+} else if (FormatTok->is(tok::l_brace)) {
+  parseBracedList(false);
+} else if (FormatTok->isOneOf(tok::comma, tok::r_square)) {
+  break;
+} else {
+  nextToken();
+}
+  }
+}
 if (FormatTok->is(tok::comma)) {
   nextToken();
 } else if (FormatTok->is(tok::r_square)) {
@@ -1110,7 +1131,8 @@
   nextToken();
 
   // FIXME: Once we have an expression parser in the UnwrappedLineParser,
-  // replace this by using parseAssigmentExpression() inside.
+  // replace this by using parseAssigmentExpression() inside. See also
+  // tryToParseLambdaIntroducer.
   do {
 if (Style.Language == FormatStyle::LK_JavaScript) {
   if (FormatTok->is(Keywords.kw_function)) {


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -10057,6 +10057,18 @@
   // More complex introducers.
   verifyFormat("return [i, args...] {};");
 
+  // Lambdas with generalized captures.
+  verifyFormat("auto f = [b = d]() {};\n");
+  verifyFormat("auto f = [b = std::move(d)]() {};\n");
+  verifyFormat("auto f = [b = c, d = e, g]() {};\n");
+  verifyFormat("auto f = [b = a[3]]() {};\n");
+  verifyFormat("auto f = [InRange = a < b && b < c]() {};\n");
+  verifyFormat("auto f = [b = std::vector{1, 2, 3}]() {};\n");
+  verifyFormat("auto f = [b = std::vector{\n"
+   "  1, 2, 3,\n"
+   "}]() {};\n");
+  verifyFormat("return [b = std::vector()] {}();\n");
+
   // Not lambdas.
   verifyFormat("constexpr char hello[]{\"hello\"};");
   verifyFormat("double [](int i) { return 0; }\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -1054,6 +1054,27 @@
 nextToken();
 if (FormatTok->is(tok::ellipsis))
   nextToken();
+if (FormatTok->is(tok::equal)) {
+  // Generalized lambda capture.
+  nextToken();
+  while (!eof()) {
+// FIXME: Once we have an expression parser in the UnwrappedLineParser,
+// replace this by using parseAssigmentExpression() inside. See also
+// parseBracedList. For now, parsing matching braces ([], (), {}) is
+// good enough.
+if (FormatTok->is(tok::l_paren)) {
+  parseParens();
+} else if (FormatTok->is(tok::l_square)) {
+  parseSquare();
+} else if (FormatTok->is(tok::l_brace)) {
+  parseBracedList(false);
+} else if (FormatTok->isOneOf(tok::comma, tok::r_square)) {
+  break;
+} else {
+  nextToken();
+}
+  }
+}
 if (FormatTok->is(tok::comma)) {
   nextToken();
 } else if (FormatTok->is(tok::r_square)) {
@@ -1110,7 +1131,8 @@
   nextToken();
 
   // FIXME: Once we have an expression 

Re: [PATCH] D10370: clang-format: Implement AlwaysBreakAfterDeclarationReturnType.

2015-09-16 Thread strager via cfe-commits
strager updated this revision to Diff 34947.
strager added a comment.

Rebase.


http://reviews.llvm.org/D10370

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4658,6 +4658,44 @@
"  \"c\";");
 }
 
+TEST_F(FormatTest, DeclarationReturnTypeBreakingStyle) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_TopLevel;
+  verifyFormat("class C {\n"
+   "  int f();\n"
+   "};\n"
+   "int\n"
+   "f();",
+   Style);
+  Style.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_All;
+  verifyFormat("class C {\n"
+   "  int\n"
+   "  f();\n"
+   "};\n"
+   "int\n"
+   "f();",
+   Style);
+  verifyFormat("const char *f(void) { return \"\"; }\n"
+   "const char *\n"
+   "bar(void);\n",
+   Style);
+  verifyFormat("template  T *f(T ) { return NULL; }\n"
+   "template \n"
+   "T *\n"
+   "f(T );\n",
+   Style);
+  Style.BreakBeforeBraces = FormatStyle::BS_Stroustrup;
+  verifyFormat("const char *f(void) { return \"\"; }\n"
+   "const char *\n"
+   "bar(void);\n",
+   Style);
+  verifyFormat("template  T *f(T ) { return NULL; }\n"
+   "template \n"
+   "T *\n"
+   "f(T );\n",
+   Style);
+}
+
 TEST_F(FormatTest, DefinitionReturnTypeBreakingStyle) {
   FormatStyle Style = getLLVMStyle();
   Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_TopLevel;
@@ -4738,6 +4776,46 @@
Style);
 }
 
+TEST_F(FormatTest, AlwaysBreakAfterDeclarationAndDefinitionReturnTypeMixed) {
+  FormatStyle AfterType = getLLVMStyle();
+  AfterType.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_None;
+  AfterType.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
+  verifyFormat("void f(void) {\n" // No break here.
+   "  f();\n"
+   "  f();\n"
+   "}\n"
+   "void bar(void);\n", // No break here.
+   AfterType);
+  AfterType.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_All;
+  AfterType.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
+  verifyFormat("void f(void) {\n" // No break here.
+   "  f();\n"
+   "  f();\n"
+   "}\n"
+   "void\n"
+   "bar(void);\n", // Break here.
+   AfterType);
+  AfterType.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_None;
+  AfterType.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
+  verifyFormat("void\n"
+   "f(void) {\n" // Break here.
+   "  f();\n"
+   "  f();\n"
+   "}\n"
+   "void bar(void);\n", // No break here.
+   AfterType);
+  AfterType.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_All;
+  AfterType.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
+  verifyFormat("void\n"
+   "f(void) {\n" // Break here.
+   "  f();\n"
+   "  f();\n"
+   "}\n"
+   "void\n"
+   "bar(void);\n", // Break here.
+   AfterType);
+}
+
 TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) {
   FormatStyle NoBreak = getLLVMStyle();
   NoBreak.AlwaysBreakBeforeMultilineStrings = false;
@@ -9409,6 +9487,15 @@
   CHECK_PARSE("BreakBeforeBraces: GNU", BreakBeforeBraces, FormatStyle::BS_GNU);
   CHECK_PARSE("BreakBeforeBraces: WebKit", BreakBeforeBraces, FormatStyle::BS_WebKit);
 
+  Style.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_All;
+  CHECK_PARSE("AlwaysBreakAfterDeclarationReturnType: None",
+  AlwaysBreakAfterDeclarationReturnType, FormatStyle::DRTBS_None);
+  CHECK_PARSE("AlwaysBreakAfterDeclarationReturnType: All",
+  AlwaysBreakAfterDeclarationReturnType, FormatStyle::DRTBS_All);
+  CHECK_PARSE("AlwaysBreakAfterDeclarationReturnType: TopLevel",
+  AlwaysBreakAfterDeclarationReturnType,
+  FormatStyle::DRTBS_TopLevel);
+
   Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
   CHECK_PARSE("AlwaysBreakAfterDefinitionReturnType: None",
   AlwaysBreakAfterDefinitionReturnType, FormatStyle::DRTBS_None);
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1593,15 +1593,18 @@
 

Re: [PATCH] D10371: clang-format: Support @synchronized.

2015-09-16 Thread strager via cfe-commits
strager updated this revision to Diff 34957.
strager added a comment.

Rebase. Fix style issues.


http://reviews.llvm.org/D10371

Files:
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2419,6 +2419,30 @@
Style);
 }
 
+TEST_F(FormatTest, FormatObjCSynchronized) {
+  FormatStyle Style = getLLVMStyleWithColumns(32);
+  verifyFormat("@synchronized(foo) {\n"
+   "  f();\n"
+   "}\n",
+   Style);
+  verifyFormat("@synchronized([self\n"
+   "veryLongMethodNameWithParameters:\n"
+   "YES]) {\n"
+   "  f();\n"
+   "}\n",
+   Style);
+  Style.BreakBeforeBraces = FormatStyle::BS_Allman;
+  verifyFormat("@synchronized(foo)\n"
+   "{\n"
+   "  f();\n"
+   "}\n"
+   "@synchronized(foo)\n"
+   "{\n"
+   "  f();\n"
+   "}\n",
+   Style);
+}
+
 TEST_F(FormatTest, StaticInitializers) {
   verifyFormat("static SomeClass SC = {1, 'a'};");
 
@@ -8373,6 +8397,10 @@
"  break;\n"
"}",
NoSpace);
+  verifyFormat("@synchronized(x) {\n"
+   "  do_something();\n"
+   "}",
+   NoSpace);
   verifyFormat("auto i = std::make_unique(5);", NoSpace);
   verifyFormat("size_t x = sizeof(x);", NoSpace);
   verifyFormat("auto f(int x) -> decltype(x);", NoSpace);
@@ -8408,6 +8436,10 @@
"  break;\n"
"}",
Space);
+  verifyFormat("@synchronized (x) {\n"
+   "  do_something ();\n"
+   "}",
+   Space);
   verifyFormat("A::A () : a (1) {}", Space);
   verifyFormat("void f () __attribute__ ((asdf));", Space);
   verifyFormat("*( + 1);\n"
@@ -8460,6 +8492,10 @@
"  break;\n"
"}",
Spaces);
+  verifyFormat("@synchronized( x ) {\n"
+   "  do_something();\n"
+   "}",
+   Spaces);
 
   Spaces.SpacesInParentheses = false;
   Spaces.SpacesInCStyleCastParentheses = true;
@@ -8497,6 +8533,10 @@
"  break;\n"
"}",
Spaces);
+  verifyFormat("@synchronized(x) {\n"
+   "  do_something( );\n"
+   "}",
+   Spaces);
 
   // Run the first set of tests again with:
   Spaces.SpaceAfterCStyleCast = true;
@@ -8523,6 +8563,10 @@
"  break;\n"
"}",
Spaces);
+  verifyFormat("@synchronized(x) {\n"
+   "  do_something( );\n"
+   "}",
+   Spaces);
 
   // Run subset of tests again with:
   Spaces.SpacesInCStyleCastParentheses = false;
@@ -8534,6 +8578,10 @@
"  do_something((int) i);\n"
"} while (something( ));",
Spaces);
+  verifyFormat("@synchronized((NSLock) x) {\n"
+   "  do_something( );\n"
+   "}",
+   Spaces);
 }
 
 TEST_F(FormatTest, ConfigurableSpacesInSquareBrackets) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -679,8 +679,12 @@
   addUnwrappedLine();
   return;
 case tok::objc_autoreleasepool:
+case tok::objc_synchronized:
   nextToken();
-  if (FormatTok->Tok.is(tok::l_brace)) {
+  if (FormatTok->is(tok::l_paren)) {
+parseParens();
+  }
+  if (FormatTok->is(tok::l_brace)) {
 if (Style.BreakBeforeBraces == FormatStyle::BS_Allman ||
 Style.BreakBeforeBraces == FormatStyle::BS_GNU)
   addUnwrappedLine();
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -122,7 +122,7 @@
 if (Left->Previous &&
 (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype,
  tok::kw_if, tok::kw_while, tok::l_paren,
- tok::comma) ||
+ tok::comma, Keywords.kw_synchronized) ||
  Left->Previous->is(TT_BinaryOperator))) {
   // static_assert, if and while usually contain expressions.
   Contexts.back().IsExpression = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11693: clang-format: Support generalized lambda captures.

2015-09-16 Thread strager via cfe-commits
strager marked 4 inline comments as done.


Comment at: lib/Format/UnwrappedLineParser.cpp:1057-1058
@@ +1056,4 @@
+  while (!eof()) {
+// FIXME: Once we have an expression parser in the UnwrappedLineParser,
+// replace this by using parseAssigmentExpression() inside.
+if (FormatTok->is(tok::l_paren)) {

strager wrote:
> djasper wrote:
> > I very much doubt that we'll have an Expression parser here anytime soon. 
> > So, I don't think that this FIXME makes much sense. Instead, please provide 
> > a comment on what this is actually doing and in which cases it might fail.
> I copied the comment from elsewhere in the file.
I expanded the comment, including a reference to the other reference to 
`parseAssigmentExpression`.


Comment at: lib/Format/UnwrappedLineParser.cpp:1061
@@ +1060,3 @@
+  parseParens();
+} else if (FormatTok->isOneOf(tok::comma, tok::r_square)) {
+  break;

strager wrote:
> djasper wrote:
> > I think this list should be extended to figure out certain cases where we 
> > know something is fishy. In particular:
> > * If you find an l_square or less, call into parseSquare and parseAngle 
> > respectively.
> > * If you find an r_brace or semi, something is wrong, break.
> > 
> Will do.
Handling r_brace and semi is a bit weird, since we end up aborting mid-stream 
and what's left becomes unparsable/incomplete by clang-format.

parseAngle doesn't exist, and even if it did, the less-than operator wouldn't 
be handled properly.

I added l_square and l_brace support.


http://reviews.llvm.org/D11693



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


[PATCH] D12921: clang-format: Support 'template<>' (no space).

2015-09-16 Thread strager via cfe-commits
strager created this revision.
strager added a reviewer: djasper.
strager added subscribers: cfe-commits, abdulras, sas.
Herald added a subscriber: klimek.

Some styles don't put a space between 'template' and the
opening '<'. Introduce SpaceAfterTemplateKeyword which, when
set to false, causes 'template' and '<' to not have a space
between.

http://reviews.llvm.org/D12921

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5728,6 +5728,17 @@
   verifyFormat("template  void Foo(Ts*... ts) {}", PointersLeft);
 }
 
+TEST_F(FormatTest, SpaceAfterTemplate) {
+  FormatStyle Style = getLLVMStyle();
+  Style.SpaceAfterTemplateKeyword = false;
+  verifyFormat("template<> class Foo {}", Style);
+  verifyFormat("template<> void Foo() {}", Style);
+  verifyFormat("template class Foo {}", Style);
+  verifyFormat("template void Foo() {}", Style);
+  verifyFormat("template class Foo {}", Style);
+  verifyFormat("template void Foo() {}", Style);
+}
+
 TEST_F(FormatTest, AdaptivelyFormatsPointersAndReferences) {
   EXPECT_EQ("int *a;\n"
 "int *a;\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1827,7 +1827,7 @@
   if (Right.isOneOf(tok::semi, tok::comma))
 return false;
   if (Right.is(tok::less) &&
-  (Left.is(tok::kw_template) ||
+  ((Left.is(tok::kw_template) && Style.SpaceAfterTemplateKeyword) ||
(Line.Type == LT_ObjCDecl && Style.ObjCSpaceBeforeProtocolList)))
 return true;
   if (Left.isOneOf(tok::exclaim, tok::tilde))
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -268,6 +268,7 @@
Style.PenaltyReturnTypeOnItsOwnLine);
 IO.mapOptional("PointerAlignment", Style.PointerAlignment);
 IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast);
+IO.mapOptional("SpaceAfterTemplateKeyword", 
Style.SpaceAfterTemplateKeyword);
 IO.mapOptional("SpaceBeforeAssignmentOperators",
Style.SpaceBeforeAssignmentOperators);
 IO.mapOptional("SpaceBeforeParens", Style.SpaceBeforeParens);
@@ -398,6 +399,7 @@
   LLVMStyle.SpacesInContainerLiterals = true;
   LLVMStyle.SpacesInCStyleCastParentheses = false;
   LLVMStyle.SpaceAfterCStyleCast = false;
+  LLVMStyle.SpaceAfterTemplateKeyword = true;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
   LLVMStyle.SpaceBeforeAssignmentOperators = true;
   LLVMStyle.SpacesInAngles = false;
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -367,6 +367,10 @@
   /// \brief If \c true, a space may be inserted after C style casts.
   bool SpaceAfterCStyleCast;
 
+  /// \brief If \c true, a space may be inserted between the 'template' keyword
+  /// and the following '<'.
+  bool SpaceAfterTemplateKeyword;
+
   /// \brief If \c false, spaces will be removed before assignment operators.
   bool SpaceBeforeAssignmentOperators;
 
@@ -512,6 +516,7 @@
PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine &&
PointerAlignment == R.PointerAlignment &&
SpaceAfterCStyleCast == R.SpaceAfterCStyleCast &&
+   SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators 
&&
SpaceBeforeParens == R.SpaceBeforeParens &&
SpaceInEmptyParentheses == R.SpaceInEmptyParentheses &&
Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst
+++ docs/ClangFormatStyleOptions.rst
@@ -481,6 +481,10 @@
 **SpaceAfterCStyleCast** (``bool``)
   If ``true``, a space may be inserted after C style casts.
 
+**SpaceAfterTemplateKeyword** (``bool``)
+  If ``true``, a space may be inserted between the 'template' keyword
+  and the following '<'.
+
 **SpaceBeforeAssignmentOperators** (``bool``)
   If ``false``, spaces will be removed before assignment operators.
 


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5728,6 +5728,17 @@
   verifyFormat("template  void Foo(Ts*... ts) {}", PointersLeft);
 }
 
+TEST_F(FormatTest, SpaceAfterTemplate) {
+  FormatStyle Style = getLLVMStyle();
+  Style.SpaceAfterTemplateKeyword = false;
+  verifyFormat("template<> class Foo {}", Style);
+  verifyFormat("template<> 

[PATCH] D12938: [ARM] Handle +t2dsp feature as an ArchExtKind in ARMTargetParser.def

2015-09-17 Thread A. Skrobov via cfe-commits
tyomitch created this revision.
tyomitch added reviewers: labrinea, rengolin.
tyomitch added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

Currently, the availability of DSP instructions (ACLE 6.4.7) is handled in a 
hand-rolled tricky condition block in lib/Basic/Targets.cpp, with a FIXME: 
attached.

http://reviews.llvm.org/D12937 moves the handling of +t2dsp over to 
ARMTargetParser.def in LLVM, to be in line with other architecture extensions.

This is the corresponding patch to clang, to clear the FIXME: and update the 
tests.

http://reviews.llvm.org/D12938

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

Index: test/CodeGen/arm-target-features.c
===
--- test/CodeGen/arm-target-features.c
+++ test/CodeGen/arm-target-features.c
@@ -1,56 +1,58 @@
 // REQUIRES: arm-registered-target
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
-// CHECK-VFP3: "target-features"="+neon,+vfp3"
+// CHECK-VFP3: "target-features"="+neon,+t2dsp,+vfp3"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a9 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-FP16
-// CHECK-VFP3-FP16: "target-features"="+fp16,+neon,+vfp3"
+// CHECK-VFP3-FP16: "target-features"="+fp16,+neon,+t2dsp,+vfp3"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a5 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4
-// CHECK-VFP4: "target-features"="+neon,+vfp4"
+// CHECK-VFP4: "target-features"="+neon,+t2dsp,+vfp4"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a7 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a12 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a15 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a17 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7s-linux-gnueabi -target-cpu swift -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu krait -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// CHECK-VFP4-DIV: "target-features"="+hwdiv,+hwdiv-arm,+neon,+vfp4"
+// CHECK-VFP4-DIV: "target-features"="+hwdiv,+hwdiv-arm,+neon,+t2dsp,+vfp4"
 
 
 // RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a72 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
-// CHECK-BASIC-V8: "target-features"="+crc,+crypto,+fp-armv8,+hwdiv,+hwdiv-arm,+neon"
+// CHECK-BASIC-V8: "target-features"="+crc,+crypto,+fp-armv8,+hwdiv,+hwdiv-arm,+neon,+t2dsp"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-r5 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-DIV
-// CHECK-VFP3-D16-DIV: "target-features"="+d16,+hwdiv,+hwdiv-arm,+vfp3"
+// CHECK-VFP3-D16-DIV: "target-features"="+d16,+hwdiv,+hwdiv-arm,+t2dsp,+vfp3"
 
 
 // RUN: %clang_cc1 -triple armv7-linux-gnueabi -target-cpu cortex-r4f -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-THUMB-DIV
-// CHECK-VFP3-D16-THUMB-DIV: "target-features"="+d16,+hwdiv,+vfp3"
+// CHECK-VFP3-D16-THUMB-DIV: "target-features"="+d16,+hwdiv,+t2dsp,+vfp3"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-r7 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-FP16-DIV
-// CHECK-VFP3-D16-FP16-DIV: "target-features"="+d16,+fp16,+hwdiv,+hwdiv-arm,+vfp3"
+// CHECK-VFP3-D16-FP16-DIV: "target-features"="+d16,+fp16,+hwdiv,+hwdiv-arm,+t2dsp,+vfp3"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-m4 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-D16-SP-THUMB-DIV
-// CHECK-VFP4-D16-SP-THUMB-DIV: "target-features"="+d16,+fp-only-sp,+hwdiv,+vfp4"
+// CHECK-VFP4-D16-SP-THUMB-DIV: "target-features"="+d16,+fp-only-sp,+hwdiv,+t2dsp,+vfp4"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-m7 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP5-D16-THUMB-DIV
-// CHECK-VFP5-D16-THUMB-DIV: "target-features"="+d16,+fp-armv8,+hwdiv"
+// CHECK-VFP5-D16-THUMB-DIV: "target-features"="+d16,+fp-armv8,+hwdiv,+t2dsp"
 
 
 // RUN: %clang_cc1 -triple armv7-linux-gnueabi -target-cpu cortex-r4 -emit-llvm -o - %s | 

Re: [PATCH] D11693: clang-format: Support generalized lambda captures.

2015-09-17 Thread strager via cfe-commits
strager marked 2 inline comments as done.


Comment at: lib/Format/UnwrappedLineParser.cpp:1060-1061
@@ +1059,4 @@
+  nextToken();
+  while (!eof()) {
+// FIXME: Once we have an expression parser in the UnwrappedLineParser,
+// replace this by using parseAssigmentExpression() inside. See also

djasper wrote:
> Again, please remove the FIXME. We aren't going to have an expression parser 
> here (anytime soon) and shouldn't add (more) comments that make people think 
> otherwise.
> We aren't going to have an expression parser here (anytime soon) and 
> shouldn't add (more) comments that make people think otherwise.

If there is enough need for the function, perhaps it will be written.

I don't think the comment implies some code will be written soon.


Comment at: lib/Format/UnwrappedLineParser.cpp:1064
@@ +1063,3 @@
+// parseBracedList. For now, parsing matching braces ([], (), {}) is
+// good enough.
+if (FormatTok->is(tok::l_paren)) {

djasper wrote:
> Ah, parseAngle doesn't exist here. I was thinking about the TokenAnnotator.
> 
> I don't understand your comment about mid-stream. This is precisely about the 
> case where the input is corrupt so that clang-format can recover and doesn't 
> just parse the reset of the file input the lambda introducer.
> This is precisely about the case where the input is corrupt so that 
> clang-format can recover and doesn't just parse the reset of the file input 
> the lambda introducer.

If I write this test:

```
verifyFormat("return [}] {};\n");
```

I get this output:

```
/Users/strager/Projects/llvm/tools/clang/unittests/Format/FormatTest.cpp:42: 
Failure
Value of: IncompleteFormat
  Actual: true
Expected: ExpectedIncompleteFormat
Which is: false
return [}] {};



/Users/strager/Projects/llvm/tools/clang/unittests/Format/FormatTest.cpp:65: 
Failure
Value of: format(test::messUp(Code), Style)
  Actual: "return [\n}] {};\n"
Expected: Code.str()
Which is: "return [}] {};\n"
```

How can I fix this?


http://reviews.llvm.org/D11693



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


Re: [PATCH] D12921: clang-format: Support 'template<>' (no space).

2015-09-17 Thread strager via cfe-commits
strager added a comment.

Should we remove `ObjCSpaceBeforeProtocolList`? It has the same problem as the 
`SpaceAfterTemplateKeyword` I am introducing.


http://reviews.llvm.org/D12921



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


Re: [PATCH] D1623: Support __builtin_ms_va_list.

2015-09-17 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247941: Support __builtin_ms_va_list. (authored by cdavis).

Changed prior to commit:
  http://reviews.llvm.org/D1623?vs=34728=35036#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D1623

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ASTDiagnostic.cpp
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/CodeGen/ABIInfo.h
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CGExprAgg.cpp
  cfe/trunk/lib/CodeGen/CGExprComplex.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
  cfe/trunk/test/CodeGen/ms_abi.c
  cfe/trunk/test/PCH/Inputs/va_arg.h
  cfe/trunk/test/PCH/va_arg.c
  cfe/trunk/test/PCH/va_arg.cpp
  cfe/trunk/test/PCH/va_arg.h
  cfe/trunk/test/Sema/varargs-win64.c
  cfe/trunk/test/Sema/varargs-x86-32.c
  cfe/trunk/test/Sema/varargs-x86-64.c
  cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp

Index: cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
===
--- cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
+++ cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
@@ -771,6 +771,7 @@
   Writer.AddTypeSourceInfo(E->getWrittenTypeInfo(), Record);
   Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
   Writer.AddSourceLocation(E->getRParenLoc(), Record);
+  Record.push_back(E->isMicrosoftABI());
   Code = serialization::EXPR_VA_ARG;
 }
 
Index: cfe/trunk/lib/Serialization/ASTWriter.cpp
===
--- cfe/trunk/lib/Serialization/ASTWriter.cpp
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp
@@ -4084,6 +4084,8 @@
  PREDEF_DECL_OBJC_INSTANCETYPE_ID);
   RegisterPredefDecl(Context.BuiltinVaListDecl, PREDEF_DECL_BUILTIN_VA_LIST_ID);
   RegisterPredefDecl(Context.VaListTagDecl, PREDEF_DECL_VA_LIST_TAG);
+  RegisterPredefDecl(Context.BuiltinMSVaListDecl,
+ PREDEF_DECL_BUILTIN_MS_VA_LIST_ID);
   RegisterPredefDecl(Context.ExternCContext, PREDEF_DECL_EXTERN_C_CONTEXT_ID);
 
   // Build a record containing all of the tentative definitions in this file, in
Index: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
===
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
@@ -830,6 +830,7 @@
   E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
   E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
   E->setRParenLoc(ReadSourceLocation(Record, Idx));
+  E->setIsMicrosoftABI(Record[Idx++]);
 }
 
 void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
Index: cfe/trunk/lib/Serialization/ASTReader.cpp
===
--- cfe/trunk/lib/Serialization/ASTReader.cpp
+++ cfe/trunk/lib/Serialization/ASTReader.cpp
@@ -6270,6 +6270,9 @@
   case PREDEF_DECL_VA_LIST_TAG:
 return Context.getVaListTagDecl();
 
+  case PREDEF_DECL_BUILTIN_MS_VA_LIST_ID:
+return Context.getBuiltinMSVaListDecl();
+
   case PREDEF_DECL_EXTERN_C_CONTEXT_ID:
 return Context.getExternCContextDecl();
   }
Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -61,6 +61,11 @@
   /*ByRef*/ false, Realign);
 }
 
+Address ABIInfo::EmitMSVAArg(CodeGenFunction , Address VAListAddr,
+ QualType Ty) const {
+  return Address::invalid();
+}
+
 ABIInfo::~ABIInfo() {}
 
 static CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT,
@@ -1734,6 +1739,8 @@
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override;
+  Address EmitMSVAArg(CodeGenFunction , Address VAListAddr,
+  QualType Ty) const override;
 
   bool has64BitPointers() const {
 return Has64BitPointers;
@@ -3266,6 +3273,14 @@
   return ResAddr;
 }
 
+Address X86_64ABIInfo::EmitMSVAArg(CodeGenFunction , Address VAListAddr,
+   QualType Ty) const {
+  return emitVoidPtrVAArg(CGF, 

Re: [PATCH] D10370: clang-format: Implement AlwaysBreakAfterDeclarationReturnType.

2015-09-17 Thread strager via cfe-commits
strager updated this revision to Diff 35038.
strager added a comment.

Fix missing IsDefinition check in ContinuationIndenter::canBreak.


http://reviews.llvm.org/D10370

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/TokenAnnotator.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4658,6 +4658,44 @@
"  \"c\";");
 }
 
+TEST_F(FormatTest, DeclarationReturnTypeBreakingStyle) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_TopLevel;
+  verifyFormat("class C {\n"
+   "  int f();\n"
+   "};\n"
+   "int\n"
+   "f();",
+   Style);
+  Style.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_All;
+  verifyFormat("class C {\n"
+   "  int\n"
+   "  f();\n"
+   "};\n"
+   "int\n"
+   "f();",
+   Style);
+  verifyFormat("const char *f(void) { return \"\"; }\n"
+   "const char *\n"
+   "bar(void);\n",
+   Style);
+  verifyFormat("template  T *f(T ) { return NULL; }\n"
+   "template \n"
+   "T *\n"
+   "f(T );\n",
+   Style);
+  Style.BreakBeforeBraces = FormatStyle::BS_Stroustrup;
+  verifyFormat("const char *f(void) { return \"\"; }\n"
+   "const char *\n"
+   "bar(void);\n",
+   Style);
+  verifyFormat("template  T *f(T ) { return NULL; }\n"
+   "template \n"
+   "T *\n"
+   "f(T );\n",
+   Style);
+}
+
 TEST_F(FormatTest, DefinitionReturnTypeBreakingStyle) {
   FormatStyle Style = getLLVMStyle();
   Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_TopLevel;
@@ -4738,6 +4776,46 @@
Style);
 }
 
+TEST_F(FormatTest, AlwaysBreakAfterDeclarationAndDefinitionReturnTypeMixed) {
+  FormatStyle AfterType = getLLVMStyle();
+  AfterType.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_None;
+  AfterType.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
+  verifyFormat("void f(void) {\n" // No break here.
+   "  f();\n"
+   "  f();\n"
+   "}\n"
+   "void bar(void);\n", // No break here.
+   AfterType);
+  AfterType.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_All;
+  AfterType.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
+  verifyFormat("void f(void) {\n" // No break here.
+   "  f();\n"
+   "  f();\n"
+   "}\n"
+   "void\n"
+   "bar(void);\n", // Break here.
+   AfterType);
+  AfterType.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_None;
+  AfterType.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
+  verifyFormat("void\n"
+   "f(void) {\n" // Break here.
+   "  f();\n"
+   "  f();\n"
+   "}\n"
+   "void bar(void);\n", // No break here.
+   AfterType);
+  AfterType.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_All;
+  AfterType.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
+  verifyFormat("void\n"
+   "f(void) {\n" // Break here.
+   "  f();\n"
+   "  f();\n"
+   "}\n"
+   "void\n"
+   "bar(void);\n", // Break here.
+   AfterType);
+}
+
 TEST_F(FormatTest, AlwaysBreakBeforeMultilineStrings) {
   FormatStyle NoBreak = getLLVMStyle();
   NoBreak.AlwaysBreakBeforeMultilineStrings = false;
@@ -9409,6 +9487,15 @@
   CHECK_PARSE("BreakBeforeBraces: GNU", BreakBeforeBraces, FormatStyle::BS_GNU);
   CHECK_PARSE("BreakBeforeBraces: WebKit", BreakBeforeBraces, FormatStyle::BS_WebKit);
 
+  Style.AlwaysBreakAfterDeclarationReturnType = FormatStyle::DRTBS_All;
+  CHECK_PARSE("AlwaysBreakAfterDeclarationReturnType: None",
+  AlwaysBreakAfterDeclarationReturnType, FormatStyle::DRTBS_None);
+  CHECK_PARSE("AlwaysBreakAfterDeclarationReturnType: All",
+  AlwaysBreakAfterDeclarationReturnType, FormatStyle::DRTBS_All);
+  CHECK_PARSE("AlwaysBreakAfterDeclarationReturnType: TopLevel",
+  AlwaysBreakAfterDeclarationReturnType,
+  FormatStyle::DRTBS_TopLevel);
+
   Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
   CHECK_PARSE("AlwaysBreakAfterDefinitionReturnType: None",
   AlwaysBreakAfterDefinitionReturnType, FormatStyle::DRTBS_None);
Index: lib/Format/TokenAnnotator.h
===
--- 

Re: [PATCH] D10370: clang-format: Implement AlwaysBreakAfterDeclarationReturnType.

2015-09-17 Thread strager via cfe-commits
strager added inline comments.


Comment at: docs/ClangFormatStyleOptions.rst:221-235
@@ -220,3 +220,17 @@
 
-**AlwaysBreakAfterDefinitionReturnType** 
(``DefinitionReturnTypeBreakingStyle``)
+**AlwaysBreakAfterDeclarationReturnType** (``ReturnTypeBreakingStyle``)
+  The function declaration return type breaking style to use.
+
+  Possible values:
+
+  * ``DRTBS_None`` (in configuration: ``None``)
+Break after return type automatically.
+``PenaltyReturnTypeOnItsOwnLine`` is taken into account.
+  * ``DRTBS_All`` (in configuration: ``All``)
+Always break after the return type.
+  * ``DRTBS_TopLevel`` (in configuration: ``TopLevel``)
+Always break after the return types of top level functions.
+
+
+**AlwaysBreakAfterDefinitionReturnType** (``ReturnTypeBreakingStyle``)
   The function definition return type breaking style to use.

djasper wrote:
> Same as I am arguing on some of your other patches. Fewer options are easier 
> to maintain and easier to discover.
I think having separate options for separate cases is easier to maintain.

Current method (separate option):

```
  FormatStyle::ReturnTypeBreakingStyle BreakStyle =
  Line.mightBeFunctionDefinition()
  ? Style.AlwaysBreakAfterDefinitionReturnType
  : Style.AlwaysBreakAfterDeclarationReturnType;
  if ((BreakStyle == FormatStyle::DRTBS_All ||
   (BreakStyle == FormatStyle::DRTBS_TopLevel && Line.Level == 0)))
Current->MustBreakBefore = true;
```

Proposed method:

```
  auto BreakStyle = Style.AlwaysBreakAfterReturnType;
  if (BreakStyle == FormatStyle::DRTBS_All ||
  (BreakStyle == FormatStyle::DRTBS_TopLevel && Line.Level == 0) ||
  (!Line->mightBeFunctionDefinition() &&
   (BreakStyle == FormatStyle::DRTBS_AllDeclarations) ||
   (BreakStyle == FormatStyle::DRTBS_TopLevelDeclarations &&
Line.Level == 0)))
Current->MustBreakBefore = true;
```


http://reviews.llvm.org/D10370



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


Re: [PATCH] D10881: [Sema] Catch a case when 'volatile' qualifier is dropped while binding

2015-09-17 Thread ~paul via cfe-commits
cynecx added a comment.

Hi :),

First of all, I would like to say that I am new into all the clang stuff 
(software architecture/internal concepts) but I wanted to start hacking clang 
so I went here to check out some ##trivial## clang bugs to fix so I can learn 
internal stuff about clang, with internal stuff I mean how AST/Sema are 
implemented and kinda these things.

So basically, I tried all the day long to find a better approach as @rjmccall 
explained that the key issue is that you can't copy-construct a ##W## from a 
##volatile W

Re: [PATCH] D12852: [Static Analyzer] Moving nullability checkers to a top level package.

2015-09-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247590: [Static Analyzer] Moving nullability checkers to a 
top level package. (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D12852?vs=34705=34713#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12852

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  cfe/trunk/test/Analysis/nullability.mm
  cfe/trunk/test/Analysis/nullability_nullonly.mm

Index: cfe/trunk/test/Analysis/nullability_nullonly.mm
===
--- cfe/trunk/test/Analysis/nullability_nullonly.mm
+++ cfe/trunk/test/Analysis/nullability_nullonly.mm
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.nullability.NullPassedToNonnull,alpha.nullability.NullReturnedFromNonnull -verify %s
+
+int getRandom();
+
+typedef struct Dummy { int val; } Dummy;
+
+void takesNullable(Dummy *_Nullable);
+void takesNonnull(Dummy *_Nonnull);
+Dummy *_Nullable returnsNullable();
+
+void testBasicRules() {
+  // The tracking of nullable values is turned off.
+  Dummy *p = returnsNullable();
+  takesNonnull(p); // no warning
+  Dummy *q = 0;
+  if (getRandom()) {
+takesNullable(q);
+takesNonnull(q); // expected-warning {{}}
+  }
+}
+
+Dummy *_Nonnull testNullReturn() {
+  Dummy *p = 0;
+  return p; // expected-warning {{}}
+}
+
+void onlyReportFirstPreconditionViolationOnPath() {
+  Dummy *p = 0;
+  takesNonnull(p); // expected-warning {{}}
+  takesNonnull(p); // No warning.
+  // Passing null to nonnull is a sink. Stop the analysis.
+  int i = 0;
+  i = 5 / i; // no warning
+  (void)i;
+}
+
+Dummy *_Nonnull doNotWarnWhenPreconditionIsViolatedInTopFunc(
+Dummy *_Nonnull p) {
+  if (!p) {
+Dummy *ret =
+0; // avoid compiler warning (which is not generated by the analyzer)
+if (getRandom())
+  return ret; // no warning
+else
+  return p; // no warning
+  } else {
+return p;
+  }
+}
+
+Dummy *_Nonnull doNotWarnWhenPreconditionIsViolated(Dummy *_Nonnull p) {
+  if (!p) {
+Dummy *ret =
+0; // avoid compiler warning (which is not generated by the analyzer)
+if (getRandom())
+  return ret; // no warning
+else
+  return p; // no warning
+  } else {
+return p;
+  }
+}
+
+void testPreconditionViolationInInlinedFunction(Dummy *p) {
+  doNotWarnWhenPreconditionIsViolated(p);
+}
+
+void inlinedNullable(Dummy *_Nullable p) {
+  if (p) return;
+}
+void inlinedNonnull(Dummy *_Nonnull p) {
+  if (p) return;
+}
+void inlinedUnspecified(Dummy *p) {
+  if (p) return;
+}
+
+Dummy *_Nonnull testDefensiveInlineChecks(Dummy * p) {
+  switch (getRandom()) {
+  case 1: inlinedNullable(p); break;
+  case 2: inlinedNonnull(p); break;
+  case 3: inlinedUnspecified(p); break;
+  }
+  if (getRandom())
+takesNonnull(p);
+  return p;
+}
Index: cfe/trunk/test/Analysis/nullability.mm
===
--- cfe/trunk/test/Analysis/nullability.mm
+++ cfe/trunk/test/Analysis/nullability.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.nullability -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.nullability -verify %s
 
 #define nil 0
 #define BOOL int
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -136,6 +136,11 @@
   };
 
   NullabilityChecksFilter Filter;
+  // When set to false no nullability information will be tracked in
+  // NullabilityMap. It is possible to catch errors like passing a null pointer
+  // to a callee that expects nonnull argument without the information that is
+  // stroed in the NullabilityMap. This is an optimization.
+  DefaultBool NeedTracking;
 
 private:
   class NullabilityBugVisitor
@@ -188,6 +193,11 @@
 }
 BR.emitReport(std::move(R));
   }
+
+  /// If an SVal wraps a region that should be tracked, it will return a pointer
+  /// to the wrapped region. Otherwise it will return a nullptr.
+  const SymbolicRegion *getTrackRegion(SVal Val,
+   bool CheckSuperRegion = false) const;
 };
 
 class NullabilityState {
@@ -246,10 +256,11 @@
   return NullConstraint::Unknown;
 }
 
-// If an SVal wraps a region that should be tracked, it will return a pointer
-// to the wrapped region. Otherwise it will return a nullptr.
-static const SymbolicRegion *getTrackRegion(SVal Val,
-bool CheckSuperRegion = false) {
+const SymbolicRegion *
+NullabilityChecker::getTrackRegion(SVal Val, bool CheckSuperRegion) const {
+  if (!NeedTracking)
+return nullptr;
+
   auto RegionSVal = Val.getAs();
   if (!RegionSVal)
 return nullptr;
@@ 

Re: [PATCH] D12818: [Static Analyzer] Relaxing a caching out related assert.

2015-09-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247598: [Static Analyzer] Relaxing a caching out related 
assert. (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D12818?vs=34579=34719#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12818

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
@@ -186,8 +186,11 @@
 
 // Generate a transition to non-Nil state.
 if (notNilState != State) {
+  bool HasTag = Pred->getLocation().getTag();
   Pred = Bldr.generateNode(ME, Pred, notNilState);
-  assert(Pred && "Should have cached out already!");
+  assert((Pred || HasTag) && "Should have cached out already!");
+  if (!Pred)
+continue;
 }
   }
 } else {


Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
@@ -186,8 +186,11 @@
 
 // Generate a transition to non-Nil state.
 if (notNilState != State) {
+  bool HasTag = Pred->getLocation().getTag();
   Pred = Bldr.generateNode(ME, Pred, notNilState);
-  assert(Pred && "Should have cached out already!");
+  assert((Pred || HasTag) && "Should have cached out already!");
+  if (!Pred)
+continue;
 }
   }
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11700: Added remove taint support to ProgramState.

2015-10-03 Thread Francisco via cfe-commits
franchiotta added inline comments.


Comment at: 
include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:444-448
@@ +443,7 @@
+
+  SymbolRef
+  getSymbolFromStmt(const Stmt *S, const LocationContext *LCtx) const;
+
+  const MemRegion*
+  getRegionFromStmt(const Stmt *S, const LocationContext *LCtx) const;
+

krememek wrote:
> krememek wrote:
> > Can we add documentation comments for these?  Seems like generally useful 
> > utility methods.  We could also probably just make these public.
> Actually, I'm wondering if we really need to add these at all.  They are just 
> one liners that easily could be written where they are used.
Right. Removing these methods, and adding the one-liners directly where they 
are used.


Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:653-654
@@ -654,3 +652,4 @@
+  *LCtx) const {
   if (const Expr *E = dyn_cast_or_null(S))
 S = E->IgnoreParens();
 

krememek wrote:
> Is this even needed?  I think Environment::getSVal() already handles 
> parenthesis and other ignored expressions.  This looks like dead code.
> 
> This can probably just be an inline method in ProgramState.h, that just 
> forwards to getSVal(S, LCtx).getAsSymbol().
> 
> Alternatively, if this is only called once, we don't need to add a method at 
> all, since it is just a one liner.
Yes, you are right. It is not needed since it is handle by 
ignoreTransparentExprs method in Environment module. I will not add this method 
at all.


Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:660-663
@@ +659,6 @@
+
+const MemRegion* ProgramState::getRegionFromStmt(const Stmt *S, const 
LocationContext
+ *LCtx) const {
+  return getSVal(S, LCtx).getAsRegion();
+}
+

krememek wrote:
> This is just a one-liner.  Do we really need this method at all?  It is only 
> called once.
We don't. I will add the one-liner directly where it is used.


Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:672-676
@@ -660,7 +671,7 @@
 
-  const MemRegion *R = getSVal(S, LCtx).getAsRegion();
+  const MemRegion *R = getRegionFromStmt(S, LCtx);
   addTaint(R, Kind);
 
   // Cannot add taint, so just return the state.
   return this;
 }

krememek wrote:
> This looks fishy.  'addTaint' returns a new state, but then the return value 
> is ignored, and 'this' is returned.
Yes, it does.. I will return at the time the last addTaint is invoked.


Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:704-708
@@ +703,7 @@
+
+  const MemRegion *R = getRegionFromStmt(S, LCtx);
+  removeTaint(R, Kind);
+
+  // Cannot remove taint, so just return the state.
+  return this;
+}

krememek wrote:
> This looks fishy.  'removeTaint' returns a new state, but then the return 
> value is ignored.  'ProgramState' values are immutable, so this method 
> appears to do nothing.
Yes, you are right. I will return at the time the last addTaint is invoked.


http://reviews.llvm.org/D11700



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


Re: [PATCH] D11700: Added remove taint support to ProgramState.

2015-10-03 Thread Francisco via cfe-commits
franchiotta updated the summary for this revision.
franchiotta updated this revision to Diff 36431.
franchiotta added a comment.

Some changes made based on the received suggestions.


http://reviews.llvm.org/D11700

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/StaticAnalyzer/Core/ProgramState.cpp

Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -648,32 +648,24 @@
   return true;
 }
 
-ProgramStateRef ProgramState::addTaint(const Stmt *S,
-   const LocationContext *LCtx,
-   TaintTagType Kind) const {
-  if (const Expr *E = dyn_cast_or_null(S))
-S = E->IgnoreParens();
-
+ProgramStateRef ProgramState::addTaint(const Stmt *S, const LocationContext
+   *LCtx, TaintTagType Kind) const {
   SymbolRef Sym = getSVal(S, LCtx).getAsSymbol();
   if (Sym)
 return addTaint(Sym, Kind);
 
   const MemRegion *R = getSVal(S, LCtx).getAsRegion();
-  addTaint(R, Kind);
-
-  // Cannot add taint, so just return the state.
-  return this;
+  return addTaint(R, Kind);
 }
 
 ProgramStateRef ProgramState::addTaint(const MemRegion *R,
-   TaintTagType Kind) const {
+   TaintTagType Kind) const {
   if (const SymbolicRegion *SR = dyn_cast_or_null(R))
 return addTaint(SR->getSymbol(), Kind);
   return this;
 }
 
-ProgramStateRef ProgramState::addTaint(SymbolRef Sym,
-   TaintTagType Kind) const {
+ProgramStateRef ProgramState::addTaint(SymbolRef Sym, TaintTagType Kind) const {
   // If this is a symbol cast, remove the cast before adding the taint. Taint
   // is cast agnostic.
   while (const SymbolCast *SC = dyn_cast(Sym))
@@ -684,6 +676,35 @@
   return NewState;
 }
 
+ProgramStateRef ProgramState::removeTaint(const Stmt *S, const LocationContext
+  *LCtx, TaintTagType Kind) const {
+  SymbolRef Sym = getSVal(S, LCtx).getAsSymbol();
+  if (Sym)
+return removeTaint(Sym, Kind);
+
+  const MemRegion *R = getSVal(S, LCtx).getAsRegion();
+  return removeTaint(R, Kind);
+}
+
+ProgramStateRef ProgramState::removeTaint(const MemRegion *R,
+  TaintTagType Kind) const {
+  if (const SymbolicRegion *SR = dyn_cast_or_null(R))
+return removeTaint(SR->getSymbol(), Kind);
+  return this;
+}
+
+ProgramStateRef ProgramState::removeTaint(SymbolRef Sym,
+  TaintTagType Kind) const {
+  // If this is a symbol cast, remove the cast before removing the taint. Taint
+  // is cast agnostic.
+  while (const SymbolCast *SC = dyn_cast(Sym))
+Sym = SC->getOperand();
+
+  ProgramStateRef NewState = remove(Sym);
+  assert(NewState);
+  return NewState;
+}
+
 bool ProgramState::isTainted(const Stmt *S, const LocationContext *LCtx,
  TaintTagType Kind) const {
   if (const Expr *E = dyn_cast_or_null(S))
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -341,15 +341,27 @@
 
   /// Create a new state in which the statement is marked as tainted.
   ProgramStateRef addTaint(const Stmt *S, const LocationContext *LCtx,
-   TaintTagType Kind = TaintTagGeneric) const;
+   TaintTagType Kind = TaintTagGeneric) const;
 
   /// Create a new state in which the symbol is marked as tainted.
   ProgramStateRef addTaint(SymbolRef S,
-   TaintTagType Kind = TaintTagGeneric) const;
+   TaintTagType Kind = TaintTagGeneric) const;
 
   /// Create a new state in which the region symbol is marked as tainted.
   ProgramStateRef addTaint(const MemRegion *R,
-   TaintTagType Kind = TaintTagGeneric) const;
+   TaintTagType Kind = TaintTagGeneric) const;
+
+  /// Create a new state in which the statement is marked as non-tainted.
+  ProgramStateRef removeTaint(const Stmt *S, const LocationContext *LCtx,
+  TaintTagType Kind = TaintTagGeneric) const;
+
+  /// Create a new state in which the symbol is marked as non-tainted.
+  ProgramStateRef removeTaint(SymbolRef S,
+  TaintTagType Kind = TaintTagGeneric) const;
+
+  /// Create a new state in which the region symbol is marked as non-tainted.
+  ProgramStateRef removeTaint(const MemRegion *R,
+  TaintTagType Kind = TaintTagGeneric) const;
 
   /// Check if the statement is tainted in the current 

Re: [PATCH] D13421: Fix makefile build on OSX when ARM targets are not enabled

2015-10-04 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249281: Fix makefile build on OSX when ARM targets are not 
enabled (authored by kfischer).

Changed prior to commit:
  http://reviews.llvm.org/D13421?vs=36462=36473#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13421

Files:
  cfe/trunk/runtime/compiler-rt/Makefile

Index: cfe/trunk/runtime/compiler-rt/Makefile
===
--- cfe/trunk/runtime/compiler-rt/Makefile
+++ cfe/trunk/runtime/compiler-rt/Makefile
@@ -89,8 +89,10 @@
 endif
 
 ifneq ($(IOS_SDK),)
+ifneq (,$(filter ARM AARCH64,$(TARGETS_TO_BUILD)))
 RuntimeLibrary.darwin.Configs += cc_kext_ios.a
 endif
+endif
 
 ifneq ($(IOSSIM_SDK),)
 RuntimeLibrary.darwin.Configs += asan_iossim_dynamic.dylib \


Index: cfe/trunk/runtime/compiler-rt/Makefile
===
--- cfe/trunk/runtime/compiler-rt/Makefile
+++ cfe/trunk/runtime/compiler-rt/Makefile
@@ -89,8 +89,10 @@
 endif
 
 ifneq ($(IOS_SDK),)
+ifneq (,$(filter ARM AARCH64,$(TARGETS_TO_BUILD)))
 RuntimeLibrary.darwin.Configs += cc_kext_ios.a
 endif
+endif
 
 ifneq ($(IOSSIM_SDK),)
 RuntimeLibrary.darwin.Configs += asan_iossim_dynamic.dylib \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12633: Implement ACLE 2.0 macros of chapters 6.6 and 6.7 for [ARM] and [Aarch64] targets

2015-10-02 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249140: Implement ACLE 2.0 macros of chapters 6.6 and 6.7 
for [ARM] and [Aarch64]… (authored by alelab01).

Changed prior to commit:
  http://reviews.llvm.org/D12633?vs=35628=36367#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12633

Files:
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Preprocessor/aarch64-target-features.c
  cfe/trunk/test/Preprocessor/arm-target-features.c

Index: cfe/trunk/include/clang/Basic/LangOptions.def
===
--- cfe/trunk/include/clang/Basic/LangOptions.def
+++ cfe/trunk/include/clang/Basic/LangOptions.def
@@ -146,6 +146,7 @@
 COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro")
 LANGOPT(FastMath  , 1, 0, "__FAST_MATH__ predefined macro")
 LANGOPT(FiniteMathOnly, 1, 0, "__FINITE_MATH_ONLY__ predefined macro")
+LANGOPT(UnsafeFPMath  , 1, 0, "Unsafe Floating Point Math")
 
 BENIGN_LANGOPT(ObjCGCBitmapPrint , 1, 0, "printing of GC's bitmap layout for __weak/__strong ivars")
 
Index: cfe/trunk/test/Preprocessor/arm-target-features.c
===
--- cfe/trunk/test/Preprocessor/arm-target-features.c
+++ cfe/trunk/test/Preprocessor/arm-target-features.c
@@ -32,6 +32,7 @@
 // CHECK-V8-BAREHF: __ARM_FEATURE_DIRECTED_ROUNDING 1
 // CHECK-V8-BAREHF: __ARM_FEATURE_NUMERIC_MAXMIN 1
 // CHECK-V8-BAREHF: __ARM_NEON__ 1
+// CHECK-V8-BAREHF: __ARM_PCS_VFP 1
 // CHECK-V8-BAREHF: __VFP_FP__ 1
 
 // RUN: %clang -target armv8a -mfloat-abi=hard -mfpu=fp-armv8 -x c -E -dM %s | FileCheck --check-prefix=CHECK-V8-BAREHF-FP %s
@@ -85,9 +86,17 @@
 // THUMBV8A-EABI:#define __ARM_ARCH_EXT_IDIV__ 1
 
 // RUN: %clang -target arm-none-linux-gnu -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-DEFS %s
+// CHECK-DEFS:#define __ARM_PCS 1
 // CHECK-DEFS:#define __ARM_SIZEOF_MINIMAL_ENUM 4
 // CHECK-DEFS:#define __ARM_SIZEOF_WCHAR_T 4
 
+// RUN: %clang -target arm-none-linux-gnu -fno-math-errno -fno-signed-zeros\
+// RUN:-fno-trapping-math -fassociative-math -freciprocal-math\
+// RUN:-x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s
+// RUN: %clang -target arm-none-linux-gnu -ffast-math -x c -E -dM %s -o -\
+// RUN:| FileCheck --check-prefix=CHECK-FASTMATH %s
+// CHECK-FASTMATH: __ARM_FP_FAST 1
+
 // RUN: %clang -target arm-none-linux-gnu -fshort-wchar -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SHORTWCHAR %s
 // CHECK-SHORTWCHAR:#define __ARM_SIZEOF_WCHAR_T 2
 
Index: cfe/trunk/test/Preprocessor/aarch64-target-features.c
===
--- cfe/trunk/test/Preprocessor/aarch64-target-features.c
+++ cfe/trunk/test/Preprocessor/aarch64-target-features.c
@@ -30,10 +30,11 @@
 // CHECK: __ARM_FP16_ARGS 1
 // CHECK: __ARM_FP16_FORMAT_IEEE 1
 // CHECK-NOT: __ARM_FP_FAST 1
-// CHECK: __ARM_FP_FENV_ROUNDING 1
 // CHECK: __ARM_NEON 1
 // CHECK: __ARM_NEON_FP 0xE
 // CHECK: __ARM_PCS_AAPCS64 1
+// CHECK-NOT: __ARM_PCS 1
+// CHECK-NOT: __ARM_PCS_VFP 1
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
 
@@ -50,6 +51,9 @@
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+crc -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-CRC32 %s
 // CHECK-CRC32: __ARM_FEATURE_CRC32 1
 
+// RUN: %clang -target aarch64-none-linux-gnu -fno-math-errno -fno-signed-zeros\
+// RUN:-fno-trapping-math -fassociative-math -freciprocal-math\
+// RUN:-x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s
 // RUN: %clang -target aarch64-none-linux-gnu -ffast-math -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s
 // RUN: %clang -target arm64-none-linux-gnu -ffast-math -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-FASTMATH %s
 // CHECK-FASTMATH: __ARM_FP_FAST 1
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4751,6 +4751,9 @@
 // ACLE 6.4.6 Q (saturation) flag
 if (DSP || SAT)
   Builder.defineMacro("__ARM_FEATURE_QBIT", "1");
+
+if (Opts.UnsafeFPMath)
+  Builder.defineMacro("__ARM_FP_FAST", "1");
   }
 
   void getTargetBuiltins(const Builtin::Info *,
@@ -5204,7 +5207,7 @@
 Builder.defineMacro("__ARM_ARCH_PROFILE", "'A'");
 
 Builder.defineMacro("__ARM_64BIT_STATE", "1");
-Builder.defineMacro("__ARM_PCS_AAPCS64");
+Builder.defineMacro("__ARM_PCS_AAPCS64", "1");
 Builder.defineMacro("__ARM_ARCH_ISA_A64", "1");
 
 Builder.defineMacro("__ARM_FEATURE_CLZ", "1");
@@ -5225,11 +5228,8 @@
 Builder.defineMacro("__ARM_FP16_FORMAT_IEEE", "1");
 Builder.defineMacro("__ARM_FP16_ARGS", "1");
 
-if (Opts.FastMath || Opts.FiniteMathOnly)

Re: [PATCH] D12725: [analyzer] A fix for substraction of an integer from a pointer.

2015-09-18 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248021: [analyzer] A fix for substraction of an integer from 
a pointer. (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D12725?vs=34423=35122#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12725

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/test/Analysis/ptr-arith.c

Index: cfe/trunk/test/Analysis/ptr-arith.c
===
--- cfe/trunk/test/Analysis/ptr-arith.c
+++ cfe/trunk/test/Analysis/ptr-arith.c
@@ -296,3 +296,20 @@
   clang_analyzer_eval([i].x < [i].y);// expected-warning{{TRUE}}
 }
 
+void negativeIndex(char *str) {
+  *(str + 1) = 'a';
+  clang_analyzer_eval(*(str + 1) == 'a'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(*(str - 1) == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr1 = str - 1;
+  clang_analyzer_eval(*ptr1 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr2 = str;
+  ptr2 -= 1;
+  clang_analyzer_eval(*ptr2 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr3 = str;
+  --ptr3;
+  clang_analyzer_eval(*ptr3 == 'a'); // expected-warning{{UNKNOWN}}
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -911,8 +911,9 @@
   elementType = elemReg->getElementType();
 }
 else if (isa(region)) {
+  assert(op == BO_Add || op == BO_Sub);
+  index = (op == BO_Add) ? rhs : evalMinus(rhs);
   superR = region;
-  index = rhs;
   if (resultTy->isAnyPointerType())
 elementType = resultTy->getPointeeType();
 }


Index: cfe/trunk/test/Analysis/ptr-arith.c
===
--- cfe/trunk/test/Analysis/ptr-arith.c
+++ cfe/trunk/test/Analysis/ptr-arith.c
@@ -296,3 +296,20 @@
   clang_analyzer_eval([i].x < [i].y);// expected-warning{{TRUE}}
 }
 
+void negativeIndex(char *str) {
+  *(str + 1) = 'a';
+  clang_analyzer_eval(*(str + 1) == 'a'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(*(str - 1) == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr1 = str - 1;
+  clang_analyzer_eval(*ptr1 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr2 = str;
+  ptr2 -= 1;
+  clang_analyzer_eval(*ptr2 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr3 = str;
+  --ptr3;
+  clang_analyzer_eval(*ptr3 == 'a'); // expected-warning{{UNKNOWN}}
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -911,8 +911,9 @@
   elementType = elemReg->getElementType();
 }
 else if (isa(region)) {
+  assert(op == BO_Add || op == BO_Sub);
+  index = (op == BO_Add) ? rhs : evalMinus(rhs);
   superR = region;
-  index = rhs;
   if (resultTy->isAnyPointerType())
 elementType = resultTy->getPointeeType();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D13105: [OpenCL] Enable program scope variables for OpenCL2.0

2015-09-23 Thread Anastasia via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: pekka.jaaskelainen.
Anastasia added a subscriber: cfe-commits.

I would like to commit this change that enables program scope variables (PSVs) 
– an OpenCL2.0 feature (Section 6.5.1).

There are three major changes in this patch.

First change removes virtual SC_OpenCLWorkGroupLocal storage type specifier as 
it conflicts with static
local variables now and prevents diagnosing static local address space 
variables correctly. Also it doesn’t seem really
necessary since we can identify local AS variable by looking at the AS 
attribute itself.

Second change makes static local variables as well as global variables allowed 
in OpenCL2.0 (OpenCL2.0 s6.8 and s6.5.1).

Last change improves diagnostics of allowed ASes for variables in different 
scopes:

Global or static local variables have to be in global or constant ASes 
(OpenCL1.2 s6.5, OpenCL2.0 s6.5.1);
Non-kernel function variables can’t be declared in local or constant ASes 
(OpenCL1.1 s6.5.2 and s6.5.3).

http://reviews.llvm.org/D13105

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  lib/AST/Decl.cpp
  lib/AST/DeclPrinter.cpp
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaDecl.cpp
  test/Parser/opencl-storage-class.cl
  test/SemaOpenCL/storageclass.cl
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6604,8 +6604,6 @@
 return CX_SC_Static;
   case SC_PrivateExtern:
 return CX_SC_PrivateExtern;
-  case SC_OpenCLWorkGroupLocal:
-return CX_SC_OpenCLWorkGroupLocal;
   case SC_Auto:
 return CX_SC_Auto;
   case SC_Register:
Index: test/SemaOpenCL/storageclass.cl
===
--- test/SemaOpenCL/storageclass.cl
+++ test/SemaOpenCL/storageclass.cl
@@ -1,14 +1,48 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCL20 -cl-std=CL2.0
 
 static constant int A = 0;
 
-int X = 0; // expected-error{{global variables must have a constant address space qualifier}}
+int G1 = 0;// expected-error{{program scope variables has wrong address space qualifier}}
 
-// static is not allowed at local scope.
+global int G2 = 0;
+#ifndef CL20
+// expected-error@-2{{program scope variables has wrong address space qualifier}}
+#endif
+
+local int G3 = 0;// expected-error{{program scope variables has wrong address space qualifier}}
+
+// static is not allowed at local scope before CL2.0
 void kernel foo() {
-  static int X = 5; // expected-error{{variables in function scope cannot be declared static}} 
+  static int S1 = 5;
+#ifndef CL20
+  // expected-error@-2{{variables in function scope cannot be declared static}}
+#else
+  // expected-error@-4{{program scope variables has wrong address space qualifier}}
+#endif
+
+  static global int S2 = 5;
+#ifndef CL20
+  // expected-error@-2{{variables in function scope cannot be declared static}}
+#endif
+
+  static private int S3 = 5;
+#ifndef CL20
+  // expected-error@-2{{variables in function scope cannot be declared static}}
+#else
+  // expected-error@-4{{program scope variables has wrong address space qualifier}}
+#endif
+
+  constant int G4 = 0;
+  local int L1;
+
   auto int Y = 7; // expected-error{{OpenCL does not support the 'auto' storage class specifier}}
 }
 
 static void kernel bar() { // expected-error{{kernel functions cannot be declared static}}
 }
+
+void f(){
+  constant int G5 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
+  local int L2; // expected-error{{non-kernel function variable cannot be declared in local address space}}
+}
Index: test/Parser/opencl-storage-class.cl
===
--- test/Parser/opencl-storage-class.cl
+++ test/Parser/opencl-storage-class.cl
@@ -8,7 +8,7 @@
   auto int d;  // expected-error {{OpenCL does not support the 'auto' storage class specifier}}
 
 #pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
-  static int e;
+  static int e; // expected-error {{program scope variables has wrong address space qualifier}}
   register int f;
   extern int g;
   auto int h;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5687,12 +5687,6 @@
   }
 
   if (getLangOpts().OpenCL) {
-// Set up the special work-group-local storage class for variables in the
-// OpenCL __local address space.
-if (R.getAddressSpace() == LangAS::opencl_local) {
-  SC = SC_OpenCLWorkGroupLocal;
-}
-
 // OpenCL v1.2 s6.9.b p4:
 // The sampler type cannot be used with the __local and __global address
 // space qualifiers.
@@ -5759,8 +5753,6 @@
 break;
   case 

Re: [PATCH] D12916: [Static Analyzer] Use generics related information to infer dynamic types.

2015-09-18 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248002: [Static Analyzer] Use generics related information 
to infer dynamic types. (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D12916?vs=35027=35095#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12916

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  cfe/trunk/test/Analysis/DynamicTypePropagation.m

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -665,38 +665,36 @@
 /// Get the returned ObjCObjectPointerType by a method based on the tracked type
 /// information, or null pointer when the returned type is not an
 /// ObjCObjectPointerType.
-static const ObjCObjectPointerType *getReturnTypeForMethod(
+static QualType getReturnTypeForMethod(
 const ObjCMethodDecl *Method, ArrayRef TypeArgs,
 const ObjCObjectPointerType *SelfType, ASTContext ) {
   QualType StaticResultType = Method->getReturnType();
 
   // Is the return type declared as instance type?
   if (StaticResultType == C.getObjCInstanceType())
-return SelfType;
+return QualType(SelfType, 0);
 
   // Check whether the result type depends on a type parameter.
   if (!isObjCTypeParamDependent(StaticResultType))
-return nullptr;
+return QualType();
 
   QualType ResultType = StaticResultType.substObjCTypeArgs(
   C, TypeArgs, ObjCSubstitutionContext::Result);
 
-  return ResultType->getAs();
+  return ResultType;
 }
 
 /// Validate that the return type of a message expression is used correctly.
 /// Returns true in case an error is detected.
 bool DynamicTypePropagation::isReturnValueMisused(
 const ObjCMessageExpr *MessageExpr,
-const ObjCObjectPointerType *SeflType, SymbolRef Sym,
+const ObjCObjectPointerType *ResultPtrType, SymbolRef Sym,
 const ObjCMethodDecl *Method, ArrayRef TypeArgs,
 bool SubscriptOrProperty, CheckerContext ) const {
-  ASTContext  = C.getASTContext();
-  const auto *ResultPtrType =
-  getReturnTypeForMethod(Method, TypeArgs, SeflType, ASTCtxt);
   if (!ResultPtrType)
 return false;
 
+  ASTContext  = C.getASTContext();
   const Stmt *Parent =
   C.getCurrentAnalysisDeclContext()->getParentMap().getParent(MessageExpr);
   if (SubscriptOrProperty) {
@@ -861,20 +859,40 @@
   if (!TypeArgs)
 return;
 
-  if (isReturnValueMisused(MessageExpr, *TrackedType, RecSym, Method, *TypeArgs,
-   M.getMessageKind() != OCM_Message, C))
+  QualType ResultType =
+  getReturnTypeForMethod(Method, *TypeArgs, *TrackedType, ASTCtxt);
+  // The static type is the same as the deduced type.
+  if (ResultType.isNull())
+return;
+
+  const MemRegion *RetRegion = M.getReturnValue().getAsRegion();
+  ExplodedNode *Pred = C.getPredecessor();
+  // When there is an entry available for the return symbol in DynamicTypeMap,
+  // the call was inlined, and the information in the DynamicTypeMap is should
+  // be precise.
+  if (RetRegion && !State->get(RetRegion)) {
+// TODO: we have duplicated information in DynamicTypeMap and
+// MostSpecializedTypeArgsMap. We should only store anything in the later if
+// the stored data differs from the one stored in the former.
+State = setDynamicTypeInfo(State, RetRegion, ResultType,
+   /*CanBeSubclass=*/true);
+Pred = C.addTransition(State);
+  }
+
+  const auto *ResultPtrType = ResultType->getAs();
+
+  if (isReturnValueMisused(MessageExpr, ResultPtrType, RecSym, Method,
+   *TypeArgs, M.getMessageKind() != OCM_Message, C))
 return;
 
-  const auto *ResultPtrType =
-  getReturnTypeForMethod(Method, *TypeArgs, *TrackedType, ASTCtxt);
   if (!ResultPtrType || ResultPtrType->isUnspecialized())
 return;
 
   // When the result is a specialized type and it is not tracked yet, track it
   // for the result symbol.
   if (!State->get(RetSym)) {
 State = State->set(RetSym, ResultPtrType);
-C.addTransition(State);
+C.addTransition(State, Pred);
   }
 }
 
Index: cfe/trunk/test/Analysis/DynamicTypePropagation.m
===
--- cfe/trunk/test/Analysis/DynamicTypePropagation.m
+++ cfe/trunk/test/Analysis/DynamicTypePropagation.m
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics -verify %s
-// XFAIL: *
 
 #if !__has_feature(objc_generics)
 #  error Compiler does not support Objective-C generics?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12938: [ARM] Handle +t2dsp feature as an ArchExtKind in ARMTargetParser.def

2015-09-21 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248154: [ARM] Handle +t2dsp feature as an ArchExtKind in 
ARMTargetParser.def (authored by askrobov).

Changed prior to commit:
  http://reviews.llvm.org/D12938?vs=35001=35244#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12938

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/CodeGen/arm-target-features.c

Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4121,6 +4121,7 @@
 
   unsigned CRC : 1;
   unsigned Crypto : 1;
+  unsigned T2DSP : 1;
   unsigned Unaligned : 1;
 
   enum {
@@ -4472,6 +4473,7 @@
 FPU = 0;
 CRC = 0;
 Crypto = 0;
+T2DSP = 0;
 Unaligned = 1;
 SoftFloat = SoftFloatABI = false;
 HWDiv = 0;
@@ -4507,6 +4509,8 @@
 CRC = 1;
   } else if (Feature == "+crypto") {
 Crypto = 1;
+  } else if (Feature == "+t2dsp") {
+T2DSP = 1;
   } else if (Feature == "+fp-only-sp") {
 HW_FP_remove |= HW_FP_DP | HW_FP_HP;
   } else if (Feature == "+strict-align") {
@@ -4743,11 +4747,7 @@
 
 // ACLE 6.4.7 DSP instructions
 bool hasDSP = false;
-bool is5EOrAbove = (ArchVersion >= 6 ||
-   (ArchVersion == 5 && CPUAttr.count('E')));
-// FIXME: We are not getting all 32-bit ARM architectures
-bool is32Bit = (!isThumb() || supportsThumb2());
-if (is5EOrAbove && is32Bit && (CPUProfile != "M" || CPUAttr  == "7EM")) {
+if (T2DSP) {
   Builder.defineMacro("__ARM_FEATURE_DSP", "1");
   hasDSP = true;
 }
Index: cfe/trunk/test/CodeGen/arm-target-features.c
===
--- cfe/trunk/test/CodeGen/arm-target-features.c
+++ cfe/trunk/test/CodeGen/arm-target-features.c
@@ -1,56 +1,58 @@
 // REQUIRES: arm-registered-target
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a8 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3
-// CHECK-VFP3: "target-features"="+neon,+vfp3"
+// CHECK-VFP3: "target-features"="+neon,+t2dsp,+vfp3"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a9 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-FP16
-// CHECK-VFP3-FP16: "target-features"="+fp16,+neon,+vfp3"
+// CHECK-VFP3-FP16: "target-features"="+fp16,+neon,+t2dsp,+vfp3"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a5 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4
-// CHECK-VFP4: "target-features"="+neon,+vfp4"
+// CHECK-VFP4: "target-features"="+neon,+t2dsp,+vfp4"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu cortex-a7 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-a12 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a15 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-cpu cortex-a17 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7s-linux-gnueabi -target-cpu swift -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -target-cpu krait -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP4-DIV
-// CHECK-VFP4-DIV: "target-features"="+hwdiv,+hwdiv-arm,+neon,+vfp4"
+// CHECK-VFP4-DIV: "target-features"="+hwdiv,+hwdiv-arm,+neon,+t2dsp,+vfp4"
 
 
 // RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple armv8-linux-gnueabi -target-cpu cortex-a53 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
 // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a72 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-BASIC-V8
-// CHECK-BASIC-V8: "target-features"="+crc,+crypto,+fp-armv8,+hwdiv,+hwdiv-arm,+neon"
+// CHECK-BASIC-V8: "target-features"="+crc,+crypto,+fp-armv8,+hwdiv,+hwdiv-arm,+neon,+t2dsp"
 
 
 // RUN: %clang_cc1 -triple thumbv7-linux-gnueabi -target-cpu cortex-r5 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-DIV
-// CHECK-VFP3-D16-DIV: "target-features"="+d16,+hwdiv,+hwdiv-arm,+vfp3"
+// CHECK-VFP3-D16-DIV: "target-features"="+d16,+hwdiv,+hwdiv-arm,+t2dsp,+vfp3"
 
 
 // RUN: %clang_cc1 -triple armv7-linux-gnueabi -target-cpu cortex-r4f -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-VFP3-D16-THUMB-DIV
-// CHECK-VFP3-D16-THUMB-DIV: "target-features"="+d16,+hwdiv,+vfp3"
+// CHECK-VFP3-D16-THUMB-DIV: "target-features"="+d16,+hwdiv,+t2dsp,+vfp3"
 
 
 

Re: [PATCH] D13113: [darwin] [builtins] Stop generating cc_kext_ios5 and move iOS architectures out of cc_kext into cc_kext_ios

2015-09-23 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248442: [darwin] [builtins] Stop generating cc_kext_ios5 and 
move iOS architectures… (authored by cbieneman).

Changed prior to commit:
  http://reviews.llvm.org/D13113?vs=35538=35567#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13113

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/runtime/compiler-rt/Makefile

Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -620,12 +620,10 @@
   llvm::sys::path::append(P, "lib", "darwin");
 
   // Use the newer cc_kext for iOS ARM after 6.0.
-  if (!isTargetIPhoneOS() || isTargetIOSSimulator() ||
-  getTriple().getArch() == llvm::Triple::aarch64 ||
-  !isIPhoneOSVersionLT(6, 0)) {
-llvm::sys::path::append(P, "libclang_rt.cc_kext.a");
+  if (isTargetIPhoneOS()) {
+llvm::sys::path::append(P, "libclang_rt.cc_kext_ios.a");
   } else {
-llvm::sys::path::append(P, "libclang_rt.cc_kext_ios5.a");
+llvm::sys::path::append(P, "libclang_rt.cc_kext.a");
   }
 
   // For now, allow missing resource libraries to support developers who may
Index: cfe/trunk/runtime/compiler-rt/Makefile
===
--- cfe/trunk/runtime/compiler-rt/Makefile
+++ cfe/trunk/runtime/compiler-rt/Makefile
@@ -89,7 +89,7 @@
 endif
 
 ifneq ($(IOS_SDK),)
-RuntimeLibrary.darwin.Configs += cc_kext_ios5.a
+RuntimeLibrary.darwin.Configs += cc_kext_ios.a
 endif
 
 ifneq ($(IOSSIM_SDK),)


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -620,12 +620,10 @@
   llvm::sys::path::append(P, "lib", "darwin");
 
   // Use the newer cc_kext for iOS ARM after 6.0.
-  if (!isTargetIPhoneOS() || isTargetIOSSimulator() ||
-  getTriple().getArch() == llvm::Triple::aarch64 ||
-  !isIPhoneOSVersionLT(6, 0)) {
-llvm::sys::path::append(P, "libclang_rt.cc_kext.a");
+  if (isTargetIPhoneOS()) {
+llvm::sys::path::append(P, "libclang_rt.cc_kext_ios.a");
   } else {
-llvm::sys::path::append(P, "libclang_rt.cc_kext_ios5.a");
+llvm::sys::path::append(P, "libclang_rt.cc_kext.a");
   }
 
   // For now, allow missing resource libraries to support developers who may
Index: cfe/trunk/runtime/compiler-rt/Makefile
===
--- cfe/trunk/runtime/compiler-rt/Makefile
+++ cfe/trunk/runtime/compiler-rt/Makefile
@@ -89,7 +89,7 @@
 endif
 
 ifneq ($(IOS_SDK),)
-RuntimeLibrary.darwin.Configs += cc_kext_ios5.a
+RuntimeLibrary.darwin.Configs += cc_kext_ios.a
 endif
 
 ifneq ($(IOSSIM_SDK),)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13217: [ARM] The Driver does not set the +strict-align flag when targeting armv6m + netbsd

2015-10-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249308: The Driver does not set the +strict-align flag when 
targeting (authored by alelab01).

Changed prior to commit:
  http://reviews.llvm.org/D13217?vs=35883=36507#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13217

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/arm-alignment.c

Index: cfe/trunk/test/Driver/arm-alignment.c
===
--- cfe/trunk/test/Driver/arm-alignment.c
+++ cfe/trunk/test/Driver/arm-alignment.c
@@ -59,6 +59,12 @@
 // RUN: %clang -target armv6-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv6m-apple-darwin -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
+
+// RUN: %clang -target armv6m-netbsd-eabi -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -mno-unaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
 
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4452,10 +4452,6 @@
   if (Feature[0] == '+')
 Features[Feature+1] = true; 
 
-if (ArchVersion < 6  || 
-   (ArchVersion == 6 && ArchProfile == llvm::ARM::PK_M))
-  Features["strict-align"] = true;
-
 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
   }
 
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -834,7 +834,8 @@
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
 if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
-  if (VersionNum < 6)
+  if (VersionNum < 6 ||
+  Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
 } else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
   if (VersionNum < 7)


Index: cfe/trunk/test/Driver/arm-alignment.c
===
--- cfe/trunk/test/Driver/arm-alignment.c
+++ cfe/trunk/test/Driver/arm-alignment.c
@@ -59,6 +59,12 @@
 // RUN: %clang -target armv6-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv6m-apple-darwin -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
+
+// RUN: %clang -target armv6m-netbsd-eabi -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -mno-unaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
 
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4452,10 +4452,6 @@
   if (Feature[0] == '+')
 Features[Feature+1] = true; 
 
-if (ArchVersion < 6  || 
-   (ArchVersion == 6 && ArchProfile == llvm::ARM::PK_M))
-  Features["strict-align"] = true;
-
 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
   }
 
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -834,7 +834,8 @@
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
 if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
-  if (VersionNum < 6)
+  if (VersionNum < 6 ||
+  Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
 } else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
   if (VersionNum < 7)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13430: [VFS] Add an in-memory file system implementation.

2015-10-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249316: [VFS] Add working directories to every virtual file 
system. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D13430?vs=36509=36515#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13430

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

Index: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
===
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
@@ -43,6 +43,12 @@
   openFileForRead(const Twine ) override {
 llvm_unreachable("unimplemented");
   }
+  llvm::ErrorOr getCurrentWorkingDirectory() const override {
+return std::string();
+  }
+  std::error_code setCurrentWorkingDirectory(const Twine ) override {
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map 
Index: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
===
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h
@@ -199,6 +199,25 @@
   /// \note The 'end' iterator is directory_iterator().
   virtual directory_iterator dir_begin(const Twine ,
std::error_code ) = 0;
+
+  /// Set the working directory. This will affect all following operations on
+  /// this file system and may propagate down for nested file systems.
+  virtual std::error_code setCurrentWorkingDirectory(const Twine ) = 0;
+  /// Get the working directory of this file system.
+  virtual llvm::ErrorOr getCurrentWorkingDirectory() const = 0;
+
+  /// Make \a Path an absolute path.
+  ///
+  /// Makes \a Path absolute using the current directory if it is not already.
+  /// An empty \a Path will result in the current directory.
+  ///
+  /// /absolute/path   => /absolute/path
+  /// relative/../path => /relative/../path
+  ///
+  /// \param Path A path that is modified to be an absolute path.
+  /// \returns success if \a path has been made absolute, otherwise a
+  ///  platform-specific error_code.
+  std::error_code makeAbsolute(SmallVectorImpl ) const;
 };
 
 /// \brief Gets an \p vfs::FileSystem for the 'real' file system, as seen by
@@ -230,6 +249,8 @@
   llvm::ErrorOr
   openFileForRead(const Twine ) override;
   directory_iterator dir_begin(const Twine , std::error_code ) override;
+  llvm::ErrorOr getCurrentWorkingDirectory() const override;
+  std::error_code setCurrentWorkingDirectory(const Twine ) override;
 
   typedef FileSystemList::reverse_iterator iterator;
   
@@ -248,6 +269,7 @@
 /// An in-memory file system.
 class InMemoryFileSystem : public FileSystem {
   std::unique_ptr Root;
+  std::string WorkingDirectory;
 
 public:
   InMemoryFileSystem();
@@ -260,6 +282,13 @@
   llvm::ErrorOr
   openFileForRead(const Twine ) override;
   directory_iterator dir_begin(const Twine , std::error_code ) override;
+  llvm::ErrorOr getCurrentWorkingDirectory() const override {
+return WorkingDirectory;
+  }
+  std::error_code setCurrentWorkingDirectory(const Twine ) override {
+WorkingDirectory = Path.str();
+return std::error_code();
+  }
 };
 
 /// \brief Get a globally unique ID for a virtual file or directory.
Index: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
===
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp
@@ -89,6 +89,14 @@
   return (*F)->getBuffer(Name, FileSize, RequiresNullTerminator, IsVolatile);
 }
 
+std::error_code FileSystem::makeAbsolute(SmallVectorImpl ) const {
+  auto WorkingDir = getCurrentWorkingDirectory();
+  if (!WorkingDir)
+return WorkingDir.getError();
+
+  return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
+}
+
 //===---===/
 // RealFileSystem implementation
 //===---===/
@@ -160,6 +168,9 @@
   ErrorOr status(const Twine ) override;
   ErrorOr openFileForRead(const Twine ) override;
   directory_iterator dir_begin(const Twine , std::error_code ) override;
+
+  llvm::ErrorOr getCurrentWorkingDirectory() const override;
+  std::error_code setCurrentWorkingDirectory(const Twine ) override;
 };
 } // end anonymous namespace
 
@@ -178,6 +189,28 @@
   return std::unique_ptr(new RealFile(FD, Name.str()));
 }
 
+llvm::ErrorOr RealFileSystem::getCurrentWorkingDirectory() const {
+  SmallString<256> Dir;
+  if (std::error_code EC = llvm::sys::fs::current_path(Dir))
+return EC;
+  return Dir.str().str();
+}
+
+std::error_code 

Re: [PATCH] D15311: [Clang] Use range loops and autos in lib/Serialization/ASTWriter.cpp

2015-12-08 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255033: Use range loops and autos in 
lib/Serialization/ASTWriter.cpp. (authored by eugenezelenko).

Changed prior to commit:
  http://reviews.llvm.org/D15311?vs=42112=42190#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15311

Files:
  cfe/trunk/lib/Serialization/ASTWriter.cpp

Index: cfe/trunk/lib/Serialization/ASTWriter.cpp
===
--- cfe/trunk/lib/Serialization/ASTWriter.cpp
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp
@@ -1,4 +1,4 @@
-//===--- ASTWriter.cpp - AST File Writer --===//
+//===--- ASTWriter.cpp - AST File Writer *- C++ -*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -60,6 +60,7 @@
 #include 
 #include 
 #include 
+
 using namespace clang;
 using namespace clang::serialization;
 
@@ -102,7 +103,7 @@
 #define ABSTRACT_TYPE(Class, Base)
 #include "clang/AST/TypeNodes.def"
   };
-}
+} // end anonymous namespace
 
 void ASTTypeWriter::VisitBuiltinType(const BuiltinType *T) {
   llvm_unreachable("Built-in types are never serialized");
@@ -333,9 +334,8 @@
   Record.push_back(T->isDependentType());
   Writer.AddTemplateName(T->getTemplateName(), Record);
   Record.push_back(T->getNumArgs());
-  for (TemplateSpecializationType::iterator ArgI = T->begin(), ArgE = T->end();
- ArgI != ArgE; ++ArgI)
-Writer.AddTemplateArgument(*ArgI, Record);
+  for (const auto  : *T)
+Writer.AddTemplateArgument(ArgI, Record);
   Writer.AddTypeRef(T->isTypeAlias() ? T->getAliasedType() :
 T->isCanonicalUnqualified() ? QualType()
 : T->getCanonicalTypeInternal(),
@@ -385,9 +385,8 @@
   Writer.AddNestedNameSpecifier(T->getQualifier(), Record);
   Writer.AddIdentifierRef(T->getIdentifier(), Record);
   Record.push_back(T->getNumArgs());
-  for (DependentTemplateSpecializationType::iterator
- I = T->begin(), E = T->end(); I != E; ++I)
-Writer.AddTemplateArgument(*I, Record);
+  for (const auto  : *T)
+Writer.AddTemplateArgument(I, Record);
   Code = TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION;
 }
 
@@ -466,7 +465,7 @@
   void VisitFunctionTypeLoc(FunctionTypeLoc TyLoc);
 };
 
-}
+} // end anonymous namespace
 
 void TypeLocWriter::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
   // nothing to do
@@ -1182,7 +1181,7 @@
   RecordData Record;
   
   // Metadata
-  BitCodeAbbrev *MetadataAbbrev = new BitCodeAbbrev();
+  auto *MetadataAbbrev = new BitCodeAbbrev();
   MetadataAbbrev->Add(BitCodeAbbrevOp(METADATA));
   MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Major
   MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Minor
@@ -1215,7 +1214,7 @@
 }
 
 // Module name
-BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+auto *Abbrev = new BitCodeAbbrev();
 Abbrev->Add(BitCodeAbbrevOp(MODULE_NAME));
 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name
 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
@@ -1235,7 +1234,7 @@
  .ModuleMapFileHomeIsCwd ||
 WritingModule->Directory->getName() != StringRef(".")) {
   // Module directory.
-  BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+  auto *Abbrev = new BitCodeAbbrev();
   Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Directory
   unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
@@ -1319,11 +1318,8 @@
 
   // Comment options.
   Record.push_back(LangOpts.CommentOpts.BlockCommandNames.size());
-  for (CommentOptions::BlockCommandNamesTy::const_iterator
-   I = LangOpts.CommentOpts.BlockCommandNames.begin(),
-   IEnd = LangOpts.CommentOpts.BlockCommandNames.end();
-   I != IEnd; ++I) {
-AddString(*I, Record);
+  for (const auto  : LangOpts.CommentOpts.BlockCommandNames) {
+AddString(I, Record);
   }
   Record.push_back(LangOpts.CommentOpts.ParseAllComments);
 
@@ -1441,7 +1437,7 @@
   // Original file name and file ID
   SourceManager  = Context.getSourceManager();
   if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-BitCodeAbbrev *FileAbbrev = new BitCodeAbbrev();
+auto *FileAbbrev = new BitCodeAbbrev();
 FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE));
 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID
 FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
@@ -1459,7 +1455,7 @@
 
   // Original PCH directory
   if (!OutputFile.empty() && OutputFile != "-") {
-BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
+auto *Abbrev = new BitCodeAbbrev();
 Abbrev->Add(BitCodeAbbrevOp(ORIGINAL_PCH_DIR));
 Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name
 unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
@@ -1488,16 +1484,16 @@
 bool 

Re: [PATCH] D15313: [Clang] Use range loops and autos in utils/TableGen/ClangAttrEmitter.cpp

2015-12-08 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255042: Use range loops and autos in 
utils/TableGen/ClangAttrEmitter.cpp and… (authored by eugenezelenko).

Changed prior to commit:
  http://reviews.llvm.org/D15313?vs=42192=42197#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15313

Files:
  cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Index: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
@@ -619,7 +619,7 @@
 std::vector uniques;
 std::set unique_set(enums.begin(), enums.end());
 for (const auto  : enums) {
-  std::set::iterator set_i = unique_set.find(i);
+  auto set_i = unique_set.find(i);
   if (set_i != unique_set.end()) {
 uniques.push_back(i);
 unique_set.erase(set_i);
@@ -665,8 +665,7 @@
   OS << type << " " << getUpperName();
 }
 void writeDeclarations(raw_ostream ) const override {
-  std::vector::const_iterator i = uniques.begin(),
-   e = uniques.end();
+  auto i = uniques.cbegin(), e = uniques.cend();
   // The last one needs to not have a comma.
   --e;
 
@@ -771,8 +770,7 @@
 bool isVariadicEnumArg() const override { return true; }
 
 void writeDeclarations(raw_ostream ) const override {
-  std::vector::const_iterator i = uniques.begin(),
-   e = uniques.end();
+  auto i = uniques.cbegin(), e = uniques.cend();
   // The last one needs to not have a comma.
   --e;
 
@@ -958,7 +956,7 @@
 }
 
 void writeTemplateInstantiation(raw_ostream ) const override {
-  OS << "  " << getType() << " *tempInst" << getUpperName()
+  OS << "  auto *tempInst" << getUpperName()
  << " = new (C, 16) " << getType()
  << "[A->" << getLowerName() << "_size()];\n";
   OS << "  {\n";
@@ -1537,7 +1535,7 @@
   }
   OS << ", SourceRange Loc = SourceRange()";
   OS << ") {\n";
-  OS << "" << R.getName() << "Attr *A = new (Ctx) " << R.getName();
+  OS << "auto *A = new (Ctx) " << R.getName();
   OS << "Attr(Loc, Ctx, ";
   for (auto const  : Args) {
 if (ai->isFake() && !emitFake) continue;
@@ -1654,7 +1652,7 @@
 OS << "};\n\n";
   }
 
-  OS << "#endif\n";
+  OS << "#endif // LLVM_CLANG_ATTR_CLASSES_INC\n";
 }
 
 // Emits the class method definitions for attributes.
@@ -1729,7 +1727,7 @@
 
 static void EmitAttrList(raw_ostream , StringRef Class,
  const std::vector ) {
-  std::vector::const_iterator i = AttrList.begin(), e = AttrList.end();
+  auto i = AttrList.cbegin(), e = AttrList.cend();
 
   if (i != e) {
 // Move the end iterator back to emit the last attribute.
@@ -1881,7 +1879,7 @@
 OS << "  case attr::" << R.getName() << ": {\n";
 Args = R.getValueAsListOfDefs("Args");
 if (R.isSubClassOf(InhClass) || !Args.empty())
-  OS << "const " << R.getName() << "Attr *SA = cast<" << R.getName()
+  OS << "const auto *SA = cast<" << R.getName()
  << "Attr>(A);\n";
 if (R.isSubClassOf(InhClass))
   OS << "Record.push_back(SA->isInherited());\n";
@@ -2045,9 +2043,7 @@
   GenerateHasAttrSpellingStringSwitch(Pragma, OS, "Pragma");
   OS << "case AttrSyntax::CXX: {\n";
   // C++11-style attributes are further split out based on the Scope.
-  for (std::map::iterator I = CXX.begin(),
-  E = CXX.end();
-   I != E; ++I) {
+  for (auto I = CXX.cbegin(), E = CXX.cend(); I != E; ++I) {
 if (I != CXX.begin())
   OS << " else ";
 if (I->first.empty())
@@ -2197,7 +2193,7 @@
   continue;
 }
 
-OS << "  const " << R.getName() << "Attr *A = cast<"
+OS << "  const auto *A = cast<"
<< R.getName() << "Attr>(At);\n";
 bool TDependent = R.getValueAsBit("TemplateDependent");
 
@@ -2405,7 +2401,7 @@
   // If this code has already been generated, simply return the previous
   // instance of it.
   static std::set CustomSubjectSet;
-  std::set::iterator I = CustomSubjectSet.find(FnName);
+  auto I = CustomSubjectSet.find(FnName);
   if (I != CustomSubjectSet.end())
 return *I;
 
@@ -2419,7 +2415,7 @@
   }
 
   OS << "static bool " << FnName << "(const Decl *D) {\n";
-  OS << "  if (const " << GetSubjectWithSuffix(Base) << " *S = dyn_cast<";
+  OS << "  if (const auto *S = dyn_cast<";
   OS << GetSubjectWithSuffix(Base);
   OS << ">(D))\n";
   OS << "return " << Subject.getValueAsString("CheckCode") << ";\n";
@@ -2519,7 +2515,7 @@
   // If this code has already been generated, simply return the previous
   // instance of it.
   static std::set CustomLangOptsSet;
-  std::set::iterator I = CustomLangOptsSet.find(FnName);
+  auto I 

Re: [PATCH] D15121: A new clang-tidy module to find calls to `std::swap`, and change them to use ADL

2015-12-01 Thread Richard via cfe-commits
LegalizeAdulthood added a subscriber: LegalizeAdulthood.
LegalizeAdulthood added a comment.

I'm wondering if there isn't an existing module that would be a good fit for 
this check.  Why not in the modernize module?


http://reviews.llvm.org/D15121



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


Re: [PATCH] D15007: [analyzer] Improve modelling of nullptr_t in the analyzer. Fix PR25414.

2015-12-04 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254718: [analyzer] Improve modelling of nullptr_t in the 
analyzer. Fix PR25414. (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D15007?vs=41494=41876#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15007

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
  cfe/trunk/test/Analysis/nullptr.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -95,6 +95,9 @@
 SValBuilder::getRegionValueSymbolVal(const TypedValueRegion* region) {
   QualType T = region->getValueType();
 
+  if (T->isNullPtrType())
+return makeZeroVal(T);
+  
   if (!SymbolManager::canSymbolicate(T))
 return UnknownVal();
 
@@ -112,6 +115,9 @@
unsigned Count) {
   QualType T = Ex->getType();
 
+  if (T->isNullPtrType())
+return makeZeroVal(T);
+
   // Compute the type of the result. If the expression is not an R-value, the
   // result should be a location.
   QualType ExType = Ex->getType();
@@ -126,6 +132,9 @@
const LocationContext *LCtx,
QualType type,
unsigned count) {
+  if (type->isNullPtrType())
+return makeZeroVal(type);
+
   if (!SymbolManager::canSymbolicate(type))
 return UnknownVal();
 
@@ -142,6 +151,9 @@
const LocationContext *LCtx,
QualType type,
unsigned visitCount) {
+  if (type->isNullPtrType())
+return makeZeroVal(type);
+
   if (!SymbolManager::canSymbolicate(type))
 return UnknownVal();
 
@@ -160,6 +172,8 @@
   QualType T = E->getType();
   assert(Loc::isLocType(T));
   assert(SymbolManager::canSymbolicate(T));
+  if (T->isNullPtrType())
+return makeZeroVal(T);
 
   SymbolRef sym = SymMgr.conjureSymbol(E, LCtx, T, VisitCount);
   return loc::MemRegionVal(MemMgr.getSymbolicHeapRegion(sym));
@@ -185,6 +199,9 @@
  const TypedValueRegion *region) {
   QualType T = region->getValueType();
 
+  if (T->isNullPtrType())
+return makeZeroVal(T);
+
   if (!SymbolManager::canSymbolicate(T))
 return UnknownVal();
 
Index: cfe/trunk/test/Analysis/nullptr.cpp
===
--- cfe/trunk/test/Analysis/nullptr.cpp
+++ cfe/trunk/test/Analysis/nullptr.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -std=c++11 -Wno-conversion-null -analyze -analyzer-checker=core -analyzer-store region -verify %s
+// RUN: %clang_cc1 -std=c++11 -Wno-conversion-null -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -verify %s
+
+void clang_analyzer_eval(int);
 
 // test to see if nullptr is detected as a null pointer
 void foo1(void) {
@@ -87,3 +89,40 @@
   // Create MaterializeTemporaryExpr with a nullptr inside.
   const nullptr_t  = nullptr;
 }
+
+int getSymbol();
+
+struct X {
+  virtual void f() {}
+};
+
+void invokeF(X* x) {
+  x->f(); // expected-warning{{Called C++ object pointer is null}}
+}
+
+struct Type {
+  decltype(nullptr) x;
+};
+
+void shouldNotCrash() {
+  decltype(nullptr) p;
+  if (getSymbol())
+invokeF(p); // expected-warning{{Function call argument is an uninit}}
+  if (getSymbol())
+invokeF(nullptr);
+  if (getSymbol()) {
+X *x = Type().x;
+x->f(); // expected-warning{{Called C++ object pointer is null}}
+  }
+}
+
+void f(decltype(nullptr) p) {
+  int *q = nullptr;
+  clang_analyzer_eval(p == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(q == 0); // expected-warning{{TRUE}}
+}
+
+decltype(nullptr) returnsNullPtrType();
+void fromReturnType() {
+  ((X *)returnsNullPtrType())->f(); // expected-warning{{Called C++ object pointer is null}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] Add ObjCBoxable handling to ObjCMigrator

2015-12-05 Thread AlexDenisov via cfe-commits
Extend ObjCMigrator to cover automatic migration from message sending to 
boxable literals, e.g.:

```before
typedef struct __attribute__((objc_boxable)) CGRect CGRect;
/// ...
CGRect rect;
[NSValue valueWithBytes: objCType:@encode(CGRect)];
[NSValue valueWithCGPoint:functionReturningCGPoint()];
```

```after
typedef struct __attribute__((objc_boxable)) CGRect CGRect;
/// ...
CGRect rect;
@(rect);
@(functionReturningCGPoint());
```

I will appreciate any ideas how to improve it since the implementation is far 
from beautiful.



objc_migrator_objc_boxable.patch
Description: Binary data

--
AlexDenisov
Software Engineer, http://lowlevelbits.org



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15254: Fix crash when dumping NamedDecl with NULL getQualifier().

2015-12-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254867: Fix crash in ASTDumper when dumping NamedDecl with 
NULL getQualifier(). (authored by dperchik).

Changed prior to commit:
  http://reviews.llvm.org/D15254?vs=41968=41996#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15254

Files:
  cfe/trunk/lib/AST/ASTDumper.cpp

Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -1385,20 +1385,23 @@
 
 void ASTDumper::VisitUsingDecl(const UsingDecl *D) {
   OS << ' ';
-  D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
+  if (D->getQualifier())
+D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
   OS << D->getNameAsString();
 }
 
 void ASTDumper::VisitUnresolvedUsingTypenameDecl(
 const UnresolvedUsingTypenameDecl *D) {
   OS << ' ';
-  D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
+  if (D->getQualifier())
+D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
   OS << D->getNameAsString();
 }
 
 void ASTDumper::VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl 
*D) {
   OS << ' ';
-  D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
+  if (D->getQualifier())
+D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
   OS << D->getNameAsString();
   dumpType(D->getType());
 }


Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -1385,20 +1385,23 @@
 
 void ASTDumper::VisitUsingDecl(const UsingDecl *D) {
   OS << ' ';
-  D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
+  if (D->getQualifier())
+D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
   OS << D->getNameAsString();
 }
 
 void ASTDumper::VisitUnresolvedUsingTypenameDecl(
 const UnresolvedUsingTypenameDecl *D) {
   OS << ' ';
-  D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
+  if (D->getQualifier())
+D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
   OS << D->getNameAsString();
 }
 
 void ASTDumper::VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D) {
   OS << ' ';
-  D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
+  if (D->getQualifier())
+D->getQualifier()->print(OS, D->getASTContext().getPrintingPolicy());
   OS << D->getNameAsString();
   dumpType(D->getType());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12726: [analyzer] A fix for symbolic element region index lifetime.

2015-12-10 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255236: [analyzer] Fix symbolic element index lifetime. 
(authored by dergachev).

Changed prior to commit:
  http://reviews.llvm.org/D12726?vs=37267=42400#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12726

Files:
  cfe/trunk/docs/analyzer/DebugChecks.rst
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
  cfe/trunk/test/Analysis/return-ptr-range.cpp
  cfe/trunk/test/Analysis/symbol-reaper.c

Index: cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
@@ -171,10 +171,6 @@
   // Copy the binding to the new map.
   EBMapRef = EBMapRef.add(BlkExpr, X);
 
-  // If the block expr's value is a memory region, then mark that region.
-  if (Optional R = X.getAs())
-SymReaper.markLive(R->getRegion());
-
   // Mark all symbols in the block expr's value live.
   RSScaner.scan(X);
   continue;
Index: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2348,8 +2348,12 @@
   if (const SymbolicRegion *SymR = dyn_cast(baseR))
 SymReaper.markLive(SymR->getSymbol());
 
-  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I)
+  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I) {
+// Element index of a binding key is live.
+SymReaper.markElementIndicesLive(I.getKey().getRegion());
+
 VisitBinding(I.getData());
+  }
 }
 
 void removeDeadBindingsWorker::VisitBinding(SVal V) {
@@ -2370,6 +2374,7 @@
   // If V is a region, then add it to the worklist.
   if (const MemRegion *R = V.getAsRegion()) {
 AddToWorkList(R);
+SymReaper.markLive(R);
 
 // All regions captured by a block are also live.
 if (const BlockDataRegion *BR = dyn_cast(R)) {
Index: cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -391,6 +391,18 @@
 
 void SymbolReaper::markLive(const MemRegion *region) {
   RegionRoots.insert(region);
+  markElementIndicesLive(region);
+}
+
+void SymbolReaper::markElementIndicesLive(const MemRegion *region) {
+  for (auto SR = dyn_cast(region); SR;
+   SR = dyn_cast(SR->getSuperRegion())) {
+if (auto ER = dyn_cast(SR)) {
+  SVal Idx = ER->getIndex();
+  for (auto SI = Idx.symbol_begin(), SE = Idx.symbol_end(); SI != SE; ++SI)
+markLive(*SI);
+}
+  }
 }
 
 void SymbolReaper::markInUse(SymbolRef sym) {
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
@@ -17,22 +17,26 @@
 using namespace ento;
 
 namespace {
-class ExprInspectionChecker : public Checker< eval::Call > {
+class ExprInspectionChecker : public Checker {
   mutable std::unique_ptr BT;
 
   void analyzerEval(const CallExpr *CE, CheckerContext ) const;
   void analyzerCheckInlined(const CallExpr *CE, CheckerContext ) const;
   void analyzerWarnIfReached(const CallExpr *CE, CheckerContext ) const;
   void analyzerCrash(const CallExpr *CE, CheckerContext ) const;
+  void analyzerWarnOnDeadSymbol(const CallExpr *CE, CheckerContext ) const;
 
   typedef void (ExprInspectionChecker::*FnCheck)(const CallExpr *,
  CheckerContext ) const;
 
 public:
   bool evalCall(const CallExpr *CE, CheckerContext ) const;
+  void checkDeadSymbols(SymbolReaper , CheckerContext ) const;
 };
 }
 
+REGISTER_SET_WITH_PROGRAMSTATE(MarkedSymbols, const void *)
+
 bool ExprInspectionChecker::evalCall(const CallExpr *CE,
  CheckerContext ) const {
   // These checks should have no effect on the surrounding environment
@@ -42,7 +46,10 @@
 .Case("clang_analyzer_checkInlined",
   ::analyzerCheckInlined)
 .Case("clang_analyzer_crash", ::analyzerCrash)
-.Case("clang_analyzer_warnIfReached", ::analyzerWarnIfReached)
+.Case("clang_analyzer_warnIfReached",
+  ::analyzerWarnIfReached)
+.Case("clang_analyzer_warnOnDeadSymbol",
+  ::analyzerWarnOnDeadSymbol)
 .Default(nullptr);
 
   if (!Handler)
@@ -137,6 +144,41 @@
   

Re: [PATCH] D15586: [WebAssembly] Initial linking support.

2015-12-16 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL255848: [WebAssembly] Initial linking support. (authored by 
djg).

Changed prior to commit:
  http://reviews.llvm.org/D15586?vs=43059=43075#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15586

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Driver/Tools.h

Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -1088,8 +1088,7 @@
 class LLVM_LIBRARY_VISIBILITY WebAssembly final : public ToolChain {
 public:
   WebAssembly(const Driver , const llvm::Triple ,
-  const llvm::opt::ArgList )
-  : ToolChain(D, Triple, Args) {}
+  const llvm::opt::ArgList );
 
 private:
   bool IsMathErrnoDefault() const override;
@@ -1102,8 +1101,11 @@
   bool hasBlocksRuntime() const override;
   bool SupportsObjCGC() const override;
   bool SupportsProfiling() const override;
+  bool HasNativeLLVMSupport() const override;
   void addClangTargetOptions(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const override;
+
+  Tool *buildLinker() const override;
 };
 
 class LLVM_LIBRARY_VISIBILITY PS4CPU : public Generic_ELF {
Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -245,6 +245,21 @@
 
 } // end namespace amdgpu
 
+namespace wasm {
+
+class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
+public:
+  explicit Linker(const ToolChain );
+  bool isLinkJob() const override;
+  bool hasIntegratedCPP() const override;
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char *LinkingOutput) const override;
+};
+
+} // end namespace wasm
+
 namespace arm {
 std::string getARMTargetCPU(StringRef CPU, StringRef Arch,
 const llvm::Triple );
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -4418,6 +4418,13 @@
   return new tools::Myriad::Linker(*this);
 }
 
+WebAssembly::WebAssembly(const Driver , const llvm::Triple ,
+ const llvm::opt::ArgList )
+  : ToolChain(D, Triple, Args) {
+  // Use LLD by default.
+  DefaultLinker = "lld";
+}
+
 bool WebAssembly::IsMathErrnoDefault() const { return false; }
 
 bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }
@@ -4440,13 +4447,19 @@
 // TODO: Support profiling.
 bool WebAssembly::SupportsProfiling() const { return false; }
 
+bool WebAssembly::HasNativeLLVMSupport() const { return true; }
+
 void WebAssembly::addClangTargetOptions(const ArgList ,
 ArgStringList ) const {
   if (DriverArgs.hasFlag(options::OPT_fuse_init_array,
  options::OPT_fno_use_init_array, true))
 CC1Args.push_back("-fuse-init-array");
 }
 
+Tool *WebAssembly::buildLinker() const {
+  return new tools::wasm::Linker(*this);
+}
+
 PS4CPU::PS4CPU(const Driver , const llvm::Triple , const ArgList )
 : Generic_ELF(D, Triple, Args) {
   if (Args.hasArg(options::OPT_static))
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -6439,6 +6439,34 @@
 }
 // AMDGPU tools end.
 
+wasm::Linker::Linker(const ToolChain )
+  : GnuTool("wasm::Linker", "lld", TC) {}
+
+bool wasm::Linker::isLinkJob() const {
+  return true;
+}
+
+bool wasm::Linker::hasIntegratedCPP() const {
+  return false;
+}
+
+void wasm::Linker::ConstructJob(Compilation , const JobAction ,
+const InputInfo ,
+const InputInfoList ,
+const ArgList ,
+const char *LinkingOutput) const {
+  const char *Linker = Args.MakeArgString(getToolChain().GetLinkerPath());
+  ArgStringList CmdArgs;
+  CmdArgs.push_back("-flavor");
+  CmdArgs.push_back("ld");
+  CmdArgs.push_back("-target");
+  CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
+  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+  C.addCommand(llvm::make_unique(JA, *this, Linker, CmdArgs, Inputs));
+}
+
 const std::string arm::getARMArch(StringRef Arch, const llvm::Triple ) {
   std::string MArch;
   if (!Arch.empty())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

  1   2   3   4   5   6   7   8   9   10   >