r297799 - Fix test on Windows. Only a single backslash was required, not a double.
Author: dyung Date: Tue Mar 14 20:38:24 2017 New Revision: 297799 URL: http://llvm.org/viewvc/llvm-project?rev=297799=rev Log: Fix test on Windows. Only a single backslash was required, not a double. Modified: cfe/trunk/test/Modules/modules-cache-path-canonicalization.m Modified: cfe/trunk/test/Modules/modules-cache-path-canonicalization.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/modules-cache-path-canonicalization.m?rev=297799=297798=297799=diff == --- cfe/trunk/test/Modules/modules-cache-path-canonicalization.m (original) +++ cfe/trunk/test/Modules/modules-cache-path-canonicalization.m Tue Mar 14 20:38:24 2017 @@ -26,5 +26,5 @@ // RUN: -fmodules -fimplicit-module-maps -I %S/Inputs/outofdate-rebuild \ // RUN: -fdisable-module-hash %t.m -fsyntax-only -Rmodule-build 2>&1 \ // RUN: | FileCheck %s -// CHECK: {{/|}}rel{{/|}}cache{{/|}}CoreText.pcm +// CHECK: {{/|\\}}rel{{/|\\}}cache{{/|\\}}CoreText.pcm @import Cocoa; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30388: [XRay] Add -fxray-{always, never}-instrument= flags to clang
dberris added a comment. Ping? https://reviews.llvm.org/D30388 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r297798 - Add deployment knobs to tests (for Apple platforms)
Author: mehdi_amini Date: Tue Mar 14 19:59:54 2017 New Revision: 297798 URL: http://llvm.org/viewvc/llvm-project?rev=297798=rev Log: Add deployment knobs to tests (for Apple platforms) The tests for libc++ specify -target on the command-line to the compiler, but this is problematic for a few reasons. Firstly, the -target option isn't supported on Apple platforms. Parts of the triple get dropped and ignored. Instead, software should be compiled with a combination of the -arch and -m-version-min options. Secondly, the generic "darwin" target references a kernel version instead of a platform version. Each platform has its own independent versions (with different versions of libc++.1.dylib), independent of the version of the Darwin kernel. This commit adds support to the LIT infrastructure for testing against Apple platforms using -arch and -platform options. If the host is not on OS X, or the compiler type is not clang or apple-clang, then this commit has NFC. If the host is on OS X and --param=target_triple=... is specified, then a warning is emitted to use arch and platform instead. Besides the warning, there's NFC. If the host is on OS X and *no* target-triple is specified, then use the new deployment target logic. This uses two new lit parameters, --param=arch= and --param=platform=. has the form []. By default, arch is auto-detected from clang -dumpmachine, and platform is "macosx". If the platform doesn't have a version: For "macosx", the version is auto-detected from the host system using sw_vers. This may give a different version than the SDK, since new SDKs can be installed on older hosts. Otherwise, the version is auto-detected from the SDK version using xcrun --show-sdk-path. -arch -m-version-min= is added to the compiler flags. The target triple is computed as -apple-. It is *not* passed to clang, but it is available for XFAIL and UNSUPPORTED (as is with_system_cxx_lib=). For convenience, apple-darwin and -apple-darwin are added to the set of available features. There were a number of tests marked to XFAIL on x86_64-apple-darwin11 and x86_64-apple-darwin12. I updated these to x86_64-apple-macosx10.7 and x86_64-apple-macosx10.8. Modified: libcxx/trunk/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp libcxx/trunk/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp libcxx/trunk/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp libcxx/trunk/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp libcxx/trunk/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp libcxx/trunk/test/std/re/re.traits/translate_nocase.pass.cpp libcxx/trunk/test/std/strings/string.conversions/stof.pass.cpp libcxx/trunk/test/std/strings/string.conversions/stol.pass.cpp libcxx/trunk/test/std/strings/string.conversions/stoll.pass.cpp libcxx/trunk/test/std/strings/string.conversions/stoul.pass.cpp libcxx/trunk/test/std/strings/string.conversions/stoull.pass.cpp libcxx/trunk/test/std/thread/futures/futures.future_error/what.pass.cpp libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp libcxx/trunk/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp libcxx/trunk/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp
[PATCH] D17469: [libcxx] Add deployment knobs to tests (for Apple platforms)
mehdi_amini updated this revision to Diff 91804. mehdi_amini added a comment. Update: we set deployment by default even when not testing the system library. It is intentional because a REQUIRE in a test might be because an issue with libc for example. So for now the default is the OS on which the test runs. https://reviews.llvm.org/D17469 Files: test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp test/std/re/re.traits/translate_nocase.pass.cpp test/std/strings/string.conversions/stof.pass.cpp test/std/strings/string.conversions/stol.pass.cpp test/std/strings/string.conversions/stoll.pass.cpp test/std/strings/string.conversions/stoul.pass.cpp test/std/strings/string.conversions/stoull.pass.cpp test/std/thread/futures/futures.future_error/what.pass.cpp test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp test/std/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp utils/libcxx/test/config.py utils/libcxx/test/target_info.py Index: utils/libcxx/test/target_info.py === --- utils/libcxx/test/target_info.py +++ utils/libcxx/test/target_info.py @@ -12,6 +12,7 @@ import locale import os import platform +import re import sys class DefaultTargetInfo(object): @@ -70,12 +71,62 @@ def __init__(self, full_config): super(DarwinLocalTI, self).__init__(full_config) +def is_host_macosx(self): +name = lit.util.capture(['sw_vers', '-productName']).strip() +return name == "Mac OS X" + +def get_macosx_version(self): +assert self.is_host_macosx() +version = lit.util.capture(['sw_vers', '-productVersion']).strip() +version = re.sub(r'([0-9]+\.[0-9]+)(\..*)?', r'\1', version) +return version + +def get_sdk_version(self, name): +assert self.is_host_macosx() +cmd = ['xcrun', '--sdk', name, '--show-sdk-path'] +try: +out = lit.util.capture(cmd).strip() +except OSError: +pass + +if not out: +self.full_config.lit_config.fatal( +"cannot infer sdk version with: %r" % cmd) + +return re.sub(r'.*/[^0-9]+([0-9.]+)\.sdk', r'\1', out) + +def get_platform(self): +platform = self.full_config.get_lit_conf('platform') +if platform: +platform = re.sub(r'([^0-9]+)([0-9\.]*)', r'\1-\2', platform) +name, version = tuple(platform.split('-', 1)) +else: +name = 'macosx' +version = None + +if version: +return (False, name, version) + +# Infer the version, either from the SDK or the system itself. For +# macosx, ignore the SDK version; what matters is what's at +# /usr/lib/libc++.dylib. +if name == 'macosx': +version = self.get_macosx_version() +else: +version = self.get_sdk_version(name) +return (True, name, version) + def add_locale_features(self, features): add_common_locales(features, self.full_config.lit_config) def add_cxx_compile_flags(self, flags): +
[PATCH] D30810: Preserve vec3 type.
bruno added a comment. > Thanks for your comment. We have a pass to undo the vec4 to vec3. I wondered > why clang generates the vec4 for vec3 load/store. As you can see the comment > on clang's code, they are generated for better performance. I had a questions > at this point. clang should consider vector load/store aligned by 4 > regardless of target??? I believe the assumption is more practical: most part of upstream llvm targets only support vectors with even sized number of lanes. And in those cases you would have to expand to a 4x vector and leave the 4th element as undef anyway, so it was done in the front-end to get rid of it right away. Probably GPU targets do some special tricks here during legalization. > llvm's codegen could handle vec3 according to targets' vector load/store with > their alignment. I agree the flag looks odd but I was concerned some llvm's > targets depend on the vec4 so I suggested to add the flag. If I missed > something, please let me know. My guess here is that targets that do care are looking through the vector shuffle and customizing to whatever seems the best to them. If you wanna change the default behavior you need some data to show that your model solves a real issue and actually brings benefits; do you have any real examples on where that happens, or why GPU targets haven't yet tried to change this? Maybe other custom front-ends based on clang do? Finding the historical reason (if any) should be a good start point. https://reviews.llvm.org/D30810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30963: Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls replaced by visible decls.
jgorbe created this revision. The TypoCorrection::RequiresImport flag is managed by checkCorrectionVisibility() in SemaLookup.cpp. Currently, when none of the declarations in the typo correction are visible RequiresImport is set to true, and if there are no declarations, it's implicitly set to false by assigning a default-constructed TypoCorrection. If all declarations are visible, nothing is done. The current logic assumes a TypoCorrection starts as a 'normal' correction and gets converted into an 'import a module' correction when suggested fixes are not visible. This is not always the case. The crash in the included test case is caused by performQualifiedLookups() copying a TypoCorrection with RequiresImport == true, clearing its CorrectionDecls, then finding another visible declaration in a lookup. This results in an 'import a module' correction for a visible declaration. The fix makes checkCorrectionVisibility() set RequiresImport in all cases, so the relationship between RequiresImport and suggestion visibility always holds after returning. https://reviews.llvm.org/D30963 Files: lib/Sema/SemaLookup.cpp test/Modules/Inputs/crash-typo-correction-visibility/module.h test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap test/Modules/crash-typo-correction-visibility.cpp Index: test/Modules/crash-typo-correction-visibility.cpp === --- /dev/null +++ test/Modules/crash-typo-correction-visibility.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=module -o %T/module.pcm -emit-module %S/Inputs/crash-typo-correction-visibility/module.modulemap +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%T/module.pcm %s -verify + +struct S { + int member; // expected-note {{declared here}} +}; + +int f(...); + +int b = sizeof(f(member)); // expected-error {{undeclared identifier 'member'}} Index: test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap === --- /dev/null +++ test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap @@ -0,0 +1,3 @@ +module "module" { + header "module.h" +} Index: test/Modules/Inputs/crash-typo-correction-visibility/module.h === --- /dev/null +++ test/Modules/Inputs/crash-typo-correction-visibility/module.h @@ -0,0 +1 @@ +struct member; Index: lib/Sema/SemaLookup.cpp === --- lib/Sema/SemaLookup.cpp +++ lib/Sema/SemaLookup.cpp @@ -3786,8 +3786,8 @@ bool FindHidden); /// \brief Check whether the declarations found for a typo correction are -/// visible, and if none of them are, convert the correction to an 'import -/// a module' correction. +/// visible. Set the correction's RequiresImport flag to true if none of the +/// declarations are visible, false otherwise. static void checkCorrectionVisibility(Sema , TypoCorrection ) { if (TC.begin() == TC.end()) return; @@ -3797,9 +3797,11 @@ for (/**/; DI != DE; ++DI) if (!LookupResult::isVisible(SemaRef, *DI)) break; - // Nothing to do if all decls are visible. - if (DI == DE) + // No filtering needed if all decls are visible. + if (DI == DE) { +TC.setRequiresImport(false); return; + } llvm::SmallVectorNewDecls(TC.begin(), DI); bool AnyVisibleDecls = !NewDecls.empty(); Index: test/Modules/crash-typo-correction-visibility.cpp === --- /dev/null +++ test/Modules/crash-typo-correction-visibility.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=module -o %T/module.pcm -emit-module %S/Inputs/crash-typo-correction-visibility/module.modulemap +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%T/module.pcm %s -verify + +struct S { + int member; // expected-note {{declared here}} +}; + +int f(...); + +int b = sizeof(f(member)); // expected-error {{undeclared identifier 'member'}} Index: test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap === --- /dev/null +++ test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap @@ -0,0 +1,3 @@ +module "module" { + header "module.h" +} Index: test/Modules/Inputs/crash-typo-correction-visibility/module.h === --- /dev/null +++ test/Modules/Inputs/crash-typo-correction-visibility/module.h @@ -0,0 +1 @@ +struct member; Index: lib/Sema/SemaLookup.cpp === --- lib/Sema/SemaLookup.cpp +++ lib/Sema/SemaLookup.cpp @@ -3786,8 +3786,8 @@ bool FindHidden); /// \brief Check whether the declarations found for
[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.
dexonsmith added a comment. > ! In https://reviews.llvm.org/D28299#701194, @dexonsmith wrote: > Rebased again, and cleaned up tests, and a ping... now that dependencies are > resolved. > > Richard and/or Ben, can you take a look? (Or anyone else that feels comfortable confirming that the ownership semantics of MemoryBufferCache are correct.) https://reviews.llvm.org/D28299 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30854: [ASTMatchers] Add ObjC matchers for fundamental decls
kastiglione updated this revision to Diff 91801. kastiglione added a comment. Overload matchesConditionally() for multiple compiler args https://reviews.llvm.org/D30854 Files: docs/LibASTMatchersReference.html include/clang/ASTMatchers/ASTMatchers.h lib/ASTMatchers/Dynamic/Registry.cpp unittests/ASTMatchers/ASTMatchersNodeTest.cpp unittests/ASTMatchers/ASTMatchersTest.h Index: unittests/ASTMatchers/ASTMatchersTest.h === --- unittests/ASTMatchers/ASTMatchersTest.h +++ unittests/ASTMatchers/ASTMatchersTest.h @@ -61,7 +61,7 @@ template testing::AssertionResult matchesConditionally( const std::string , const T , bool ExpectMatch, -llvm::StringRef CompileArg, +std::vector Args, const FileContentMappings = FileContentMappings(), const std::string = "input.cc") { bool Found = false, DynamicFound = false; @@ -81,8 +81,8 @@ // FIXME: This is a hack to work around the fact that there's no way to do the // equivalent of runToolOnCodeWithArgs without instantiating a full Driver. // We should consider having a function, at least for tests, that invokes cc1. - std::vector Args = {CompileArg, "-frtti", "-fexceptions", - "-target", "i386-unknown-unknown"}; + Args.insert(Args.end(), {"-frtti", "-fexceptions", + "-target", "i386-unknown-unknown"}); if (!runToolOnCodeWithArgs( Factory->create(), Code, Args, Filename, "clang-tool", std::make_shared(), VirtualMappedFiles)) { @@ -105,6 +105,17 @@ } template +testing::AssertionResult matchesConditionally( +const std::string , const T , bool ExpectMatch, +llvm::StringRef CompileArg, +const FileContentMappings = FileContentMappings(), +const std::string = "input.cc") { + return matchesConditionally( +Code, AMatcher, ExpectMatch, std::vector{CompileArg}, +VirtualMappedFiles, Filename); +} + +template testing::AssertionResult matches(const std::string , const T ) { return matchesConditionally(Code, AMatcher, true, "-std=c++11"); } @@ -117,10 +128,13 @@ template testing::AssertionResult matchesObjC(const std::string , - const T ) { + const T , + bool ExpectMatch = true) { return matchesConditionally( -Code, AMatcher, true, -"", FileContentMappings(), "input.m"); +Code, AMatcher, ExpectMatch, +{"-fobjc-nonfragile-abi", + "-Wno-objc-root-class", "-Wno-incomplete-implementation"}, +FileContentMappings(), "input.m"); } template @@ -145,10 +159,8 @@ template testing::AssertionResult notMatchesObjC(const std::string , - const T ) { - return matchesConditionally( -Code, AMatcher, false, -"", FileContentMappings(), "input.m"); +const T ) { + return matchesObjC(Code, AMatcher, false); } Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp === --- unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1500,9 +1500,10 @@ std::string Objc1String = "@interface Str " - " - (Str *)uppercaseString:(Str *)str;" + " - (Str *)uppercaseString;" "@end " "@interface foo " + "- (void)contents;" "- (void)meth:(Str *)text;" "@end " " " @@ -1540,5 +1541,45 @@ ))); } +TEST(ObjCDeclMacher, CoreDecls) { + std::string ObjCString = +"@protocol Proto " +"- (void)protoDidThing; " +"@end " +"@interface Thing " +"@property int enabled; " +"@end " +"@interface Thing (ABC) " +"- (void)abc_doThing; " +"@end " +"@implementation Thing " +"{ id _ivar; } " +"- (void)anything {} " +"@end " +; + + EXPECT_TRUE(matchesObjC( +ObjCString, +objcProtocolDecl(hasName("Proto"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcCategoryDecl(hasName("ABC"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcMethodDecl(hasName("protoDidThing"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcMethodDecl(hasName("abc_doThing"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcMethodDecl(hasName("anything"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcIvarDecl(hasName("_ivar"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcPropertyDecl(hasName("enabled"; +} + } // namespace ast_matchers } // namespace clang Index: lib/ASTMatchers/Dynamic/Registry.cpp === --- lib/ASTMatchers/Dynamic/Registry.cpp +++ lib/ASTMatchers/Dynamic/Registry.cpp @@ -360,6 +360,11 @@ REGISTER_MATCHER(numSelectorArgs); REGISTER_MATCHER(ofClass); REGISTER_MATCHER(objcInterfaceDecl); + REGISTER_MATCHER(objcProtocolDecl); +
[PATCH] D28299: Module: use PCMCache to manage memory buffers for pcm files.
dexonsmith updated this revision to Diff 91799. dexonsmith added a comment. Rebased again, and cleaned up tests, and a ping... now that dependencies are resolved. Richard and/or Ben, can you take a look? https://reviews.llvm.org/D28299 Files: clang/include/clang/Basic/DiagnosticSerializationKinds.td clang/include/clang/Basic/MemoryBufferCache.h clang/include/clang/Frontend/ASTUnit.h clang/include/clang/Frontend/CompilerInstance.h clang/include/clang/Lex/Preprocessor.h clang/include/clang/Serialization/ASTReader.h clang/include/clang/Serialization/ASTWriter.h clang/include/clang/Serialization/Module.h clang/include/clang/Serialization/ModuleManager.h clang/lib/Basic/CMakeLists.txt clang/lib/Basic/MemoryBufferCache.cpp clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/CompilerInstance.cpp clang/lib/Lex/Preprocessor.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/GeneratePCH.cpp clang/lib/Serialization/ModuleManager.cpp clang/test/Modules/Inputs/system-out-of-date/X.h clang/test/Modules/Inputs/system-out-of-date/Y.h clang/test/Modules/Inputs/system-out-of-date/Z.h clang/test/Modules/Inputs/system-out-of-date/module.map clang/test/Modules/Inputs/warning-mismatch/Mismatch.h clang/test/Modules/Inputs/warning-mismatch/System.h clang/test/Modules/Inputs/warning-mismatch/module.modulemap clang/test/Modules/outofdate-rebuild.m clang/test/Modules/system-out-of-date-test.m clang/test/Modules/warning-mismatch.m clang/unittests/Basic/CMakeLists.txt clang/unittests/Basic/MemoryBufferCacheTest.cpp clang/unittests/Basic/SourceManagerTest.cpp clang/unittests/Lex/LexerTest.cpp clang/unittests/Lex/PPCallbacksTest.cpp clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp Index: clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp === --- clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp +++ clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp @@ -12,6 +12,7 @@ #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/MemoryBufferCache.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" #include "clang/Basic/TargetOptions.h" @@ -93,10 +94,11 @@ SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf))); VoidModuleLoader ModLoader; + MemoryBufferCache PCMCache; HeaderSearch HeaderInfo(std::make_shared(), SourceMgr, Diags, LangOpts, Target.get()); Preprocessor PP(std::make_shared(), Diags, LangOpts, - SourceMgr, HeaderInfo, ModLoader, + SourceMgr, PCMCache, HeaderInfo, ModLoader, /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false); PP.Initialize(*Target); Index: clang/unittests/Lex/PPCallbacksTest.cpp === --- clang/unittests/Lex/PPCallbacksTest.cpp +++ clang/unittests/Lex/PPCallbacksTest.cpp @@ -14,6 +14,7 @@ #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/MemoryBufferCache.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" #include "clang/Basic/TargetOptions.h" @@ -161,13 +162,14 @@ SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf))); VoidModuleLoader ModLoader; +MemoryBufferCache PCMCache; HeaderSearch HeaderInfo(std::make_shared(), SourceMgr, Diags, LangOpts, Target.get()); AddFakeHeader(HeaderInfo, HeaderPath, SystemHeader); Preprocessor PP(std::make_shared(), Diags, LangOpts, -SourceMgr, HeaderInfo, ModLoader, +SourceMgr, PCMCache, HeaderInfo, ModLoader, /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false); PP.Initialize(*Target); @@ -198,11 +200,12 @@ SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf))); VoidModuleLoader ModLoader; +MemoryBufferCache PCMCache; HeaderSearch HeaderInfo(std::make_shared(), SourceMgr, Diags, OpenCLLangOpts, Target.get()); Preprocessor PP(std::make_shared(), Diags, -OpenCLLangOpts, SourceMgr, HeaderInfo, ModLoader, +OpenCLLangOpts, SourceMgr, PCMCache, HeaderInfo, ModLoader, /*IILookup =*/nullptr, /*OwnsHeaderSearch =*/false); PP.Initialize(*Target); Index: clang/unittests/Lex/LexerTest.cpp === --- clang/unittests/Lex/LexerTest.cpp +++ clang/unittests/Lex/LexerTest.cpp @@ -12,6 +12,7 @@ #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileManager.h" #include
Re: [PATCH] D30700: [Driver] Always add arch-specific-subdir to -rpath
On Mon, Mar 13, 2017 at 10:37:41PM +, Reid Kleckner via Phabricator via cfe-commits wrote: > I don't agree. If we want to be good citizens on Linux, what's supposed > to happen is that we install our shared libraries into > /usr/lib/${distro_target}, which is what GCC does with its shared > compiler runtime libraries. GCC does not add system-specific absolute > rpaths to the binaries it produces. That only applies if you install into /usr directly. There are many use cases for which this is not the case. GCC generally handles them abysmal and I'd prefer if we didn't go that way. In short: if you can reasonably expect the rtlib path to be part of the system default, no rpath is necessary. Otherwise, the driver should add it and make it easy for clang builds to provide them. A compile-time flag is fine that though. Joerg ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297791 - Make a blind attempt to fix this testcase on Windows.
Author: adrian Date: Tue Mar 14 18:29:40 2017 New Revision: 297791 URL: http://llvm.org/viewvc/llvm-project?rev=297791=rev Log: Make a blind attempt to fix this testcase on Windows. Modified: cfe/trunk/test/Modules/modules-cache-path-canonicalization.m Modified: cfe/trunk/test/Modules/modules-cache-path-canonicalization.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/modules-cache-path-canonicalization.m?rev=297791=297790=297791=diff == --- cfe/trunk/test/Modules/modules-cache-path-canonicalization.m (original) +++ cfe/trunk/test/Modules/modules-cache-path-canonicalization.m Tue Mar 14 18:29:40 2017 @@ -26,5 +26,5 @@ // RUN: -fmodules -fimplicit-module-maps -I %S/Inputs/outofdate-rebuild \ // RUN: -fdisable-module-hash %t.m -fsyntax-only -Rmodule-build 2>&1 \ // RUN: | FileCheck %s -// CHECK: /rel/cache/CoreText.pcm +// CHECK: {{/|}}rel{{/|}}cache{{/|}}CoreText.pcm @import Cocoa; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30809: [coroutines] Add codegen for await and yield expressions
GorNishanov marked 4 inline comments as done. GorNishanov added inline comments. Comment at: lib/CodeGen/CGCoroutine.cpp:26 +enum class AwaitKind { Init, Normal, Yield, Final }; +char const *AwaitKindStr[] = {"init", "await", "yield", "final"}; +} majnemer wrote: > I'd move this into buildSuspendSuffixStr. I prefer to keep AwaitKindStr here, so it is trivial to visually inspect that the order in the array matches the order of the enum. Comment at: lib/CodeGen/CGCoroutine.cpp:85 + unsigned No = 0; + StringRef AwaitKindStr = 0; + switch (Kind) { rjmccall wrote: > majnemer wrote: > > I'd just let the default constructor do its thing. > Agreed. Assigning 0 to a StringRef reads very wrong. I got rid of this one and now use a llvm::StringLiteral array to get names. Comment at: lib/CodeGen/CGCoroutine.cpp:203 +break; + } + return nullptr; rjmccall wrote: > This function should return an RValue and take an AggValueSlot, just like > every other generically-typed expression emitter. That way, you can just use > EmitAnyExpr here instead of inlining two of three cases. > > And you should implement it in CGExprComplex, of course, and add that as a > test case. Thank you! That was very helpful. The code shrunk and looks nicer now. Not sure, if ignoreResult is needed, but, I added it as well to match EmitAnyExpr. https://reviews.llvm.org/D30809 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30810: Preserve vec3 type.
jaykang10 added a comment. In https://reviews.llvm.org/D30810#701132, @ahatanak wrote: > Actually, it's not a mis-compile. The record layout shows that there is a > padding before field f2 and f2 starts at byte 16. So using "store <4 x > float>" doesn't overwrite the field. It depends on float3's alignment. I guess the float3's alignment is 16 on your target so there is a padding bytes before f2 to be aligned by 16. If you add __attribute__((packed)) on struct type, you could see overwrite. https://reviews.llvm.org/D30810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30809: [coroutines] Add codegen for await and yield expressions
GorNishanov updated this revision to Diff 91790. GorNishanov added a comment. - reworked EmitAwait/Yield to has the signature similar to EmitAnyExpr - await expresions now support _Complex types. - s/Suffix/Prefix in buildCoroutineSuffix, since it was actually building a prefix - buildCoroutineSuffix uses literal array for names, as opposed to getting names from the switch stmt. - added tests to test for Aggr, Scalar and Complex - added tests for codegen for operator co_await - sprinkled more comments Thank you very much for your feedback, John and David! https://reviews.llvm.org/D30809 Files: lib/CodeGen/CGCoroutine.cpp lib/CodeGen/CGExprAgg.cpp lib/CodeGen/CGExprComplex.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenCoroutines/coro-await.cpp Index: test/CodeGenCoroutines/coro-await.cpp === --- /dev/null +++ test/CodeGenCoroutines/coro-await.cpp @@ -0,0 +1,230 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s + +namespace std { +namespace experimental { +template +struct coroutine_traits; + +template struct coroutine_handle; + +template <> +struct coroutine_handle { + void *ptr; + static coroutine_handle from_address(void *); +}; + +template +struct coroutine_handle : coroutine_handle<> { + static coroutine_handle from_address(void *); +}; + +} +} + +struct suspend_always { + int stuff; + bool await_ready(); + void await_suspend(std::experimental::coroutine_handle<>); + void await_resume(); +}; + +template<> +struct std::experimental::coroutine_traits { + struct promise_type { +void get_return_object(); +suspend_always initial_suspend(); +suspend_always final_suspend(); +void return_void(); + }; +}; + +// CHECK-LABEL: f0( +extern "C" void f0() { + + co_await suspend_always{}; + // See if we need to suspend: + // -- + // CHECK: %[[READY:.+]] = call zeroext i1 @_ZN14suspend_always11await_readyEv(%struct.suspend_always* %[[AWAITABLE:.+]]) + // CHECK: br i1 %[[READY]], label %[[READY_BB:.+]], label %[[SUSPEND_BB:.+]] + + // If we are suspending: + // - + // CHECK: [[SUSPEND_BB]]: + // CHECK: %[[SUSPEND_ID:.+]] = call token @llvm.coro.save( + // --- + // Build the coroutine handle and pass it to await_suspend + // --- + // CHECK: %[[FRAME:.+]] = call i8* @llvm.coro.frame() + // CHECK: call i8* @_ZNSt12experimental16coroutine_handleINS_16coroutine_traitsIJvEE12promise_typeEE12from_addressEPv(i8* %[[FRAME]]) + // ... many lines of code to coerce coroutine_handle into an i8* scalar + // CHECK: %[[CH:.+]] = load i8*, i8** %{{.+}} + // CHECK: call void @_ZN14suspend_always13await_suspendENSt12experimental16coroutine_handleIvEE(%struct.suspend_always* %[[AWAITABLE]], i8* %[[CH]]) + // - + // Generate a suspend point: + // - + // CHECK: %[[OUTCOME:.+]] = call i8 @llvm.coro.suspend(token %[[SUSPEND_ID]], i1 false) + // CHECK: switch i8 %[[OUTCOME]], label %[[RET_BB:.+]] [ + // CHECK: i8 0, label %[[READY_BB]] + // CHECK: i8 1, label %[[CLEANUP_BB:.+]] + // CHECK: ] + + // Cleanup code goes here: + // --- + // CHECK: [[CLEANUP_BB]]: + + // When coroutine is resumed, call await_resume + // -- + // CHECK: [[READY_BB]]: + // CHECK: call void @_ZN14suspend_always12await_resumeEv(%struct.suspend_always* %[[AWAITABLE]]) +} + +struct suspend_maybe { + float stuff; + ~suspend_maybe(); + bool await_ready(); + bool await_suspend(std::experimental::coroutine_handle<>); + void await_resume(); +}; + + +template<> +struct std::experimental::coroutine_traits{ + struct promise_type { +void get_return_object(); +suspend_always initial_suspend(); +suspend_always final_suspend(); +void return_void(); +suspend_maybe yield_value(int); + }; +}; + +// CHECK-LABEL: f1( +extern "C" void f1(int) { + co_yield 42; + // CHECK: %[[PROMISE:.+]] = alloca %"struct.std::experimental::coroutine_traits ::promise_type" + // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJviEE12promise_type11yield_valueEi(%struct.suspend_maybe* sret %[[AWAITER:.+]], %"struct.std::experimental::coroutine_traits ::promise_type"* %[[PROMISE]], i32 42) + + // See if we need to suspend: + // -- + // CHECK: %[[READY:.+]] = call zeroext i1 @_ZN13suspend_maybe11await_readyEv(%struct.suspend_maybe* %[[AWAITABLE]]) + // CHECK: br i1 %[[READY]], label %[[READY_BB:.+]], label %[[SUSPEND_BB:.+]] + + // If we are suspending: + // - + // CHECK: [[SUSPEND_BB]]: + // CHECK: %[[SUSPEND_ID:.+]] = call token @llvm.coro.save( + // --- + // Build the coroutine handle and pass it to await_suspend + //
[PATCH] D30915: Canonicalize the path provided by -fmodules-cache-path
This revision was automatically updated to reflect the committed changes. Closed by commit rL297790: Canonicalize the path provided by -fmodules-cache-path. (authored by adrian). Changed prior to commit: https://reviews.llvm.org/D30915?vs=91628=91791#toc Repository: rL LLVM https://reviews.llvm.org/D30915 Files: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/Modules/Inputs/outofdate-rebuild/AppKit.h cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Cocoa.h cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreText.h cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreVideo.h cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Foundation.h cfe/trunk/test/Modules/Inputs/outofdate-rebuild/module.modulemap cfe/trunk/test/Modules/modules-cache-path-canonicalization.m Index: cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreText.h === --- cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreText.h +++ cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreText.h @@ -0,0 +1 @@ +struct C { int i; }; Index: cfe/trunk/test/Modules/Inputs/outofdate-rebuild/AppKit.h === --- cfe/trunk/test/Modules/Inputs/outofdate-rebuild/AppKit.h +++ cfe/trunk/test/Modules/Inputs/outofdate-rebuild/AppKit.h @@ -0,0 +1,3 @@ +// AppKit +#import "CoreVideo.h" // CoreVideo +struct B { int i; }; Index: cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Foundation.h === --- cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Foundation.h +++ cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Foundation.h @@ -0,0 +1,3 @@ +// Foundation +#import "CoreText.h" +struct D { int i; }; Index: cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Cocoa.h === --- cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Cocoa.h +++ cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Cocoa.h @@ -0,0 +1,5 @@ +// Cocoa +#import "Foundation.h" +#import "AppKit.h" + +struct A { int i; }; Index: cfe/trunk/test/Modules/Inputs/outofdate-rebuild/module.modulemap === --- cfe/trunk/test/Modules/Inputs/outofdate-rebuild/module.modulemap +++ cfe/trunk/test/Modules/Inputs/outofdate-rebuild/module.modulemap @@ -0,0 +1,19 @@ +module Cocoa { + header "Cocoa.h" +} + +module AppKit { + header "AppKit.h" +} + +module CoreText { + header "CoreText.h" +} + +module Foundation { + header "Foundation.h" +} + +module CoreVideo { + header "CoreVideo.h" +} Index: cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreVideo.h === --- cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreVideo.h +++ cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreVideo.h @@ -0,0 +1,3 @@ +// CoreVideo +#import "Foundation.h" // Foundation +struct E { int i; }; Index: cfe/trunk/test/Modules/modules-cache-path-canonicalization.m === --- cfe/trunk/test/Modules/modules-cache-path-canonicalization.m +++ cfe/trunk/test/Modules/modules-cache-path-canonicalization.m @@ -0,0 +1,30 @@ +// RUN: rm -rf %t/cache %T/rel + +// This testcase reproduces a use-after-free after looking up a PCM in +// a non-canonical modules-cache-path. +// +// Prime the module cache (note the '.' in the path). +// RUN: %clang_cc1 -fdisable-module-hash -fmodules-cache-path=%t/./cache \ +// RUN: -fmodules -fimplicit-module-maps -I %S/Inputs/outofdate-rebuild \ +// RUN: %s -fsyntax-only +// +// Force a module to be rebuilt by creating a conflict. +// RUN: echo "@import CoreText;" > %t.m +// RUN: %clang_cc1 -DMISMATCH -Werror -fdisable-module-hash \ +// RUN: -fmodules-cache-path=%t/./cache -fmodules -fimplicit-module-maps \ +// RUN: -I %S/Inputs/outofdate-rebuild %t.m -fsyntax-only +// +// Rebuild. +// RUN: %clang_cc1 -fdisable-module-hash -fmodules-cache-path=%t/./cache \ +// RUN: -fmodules -fimplicit-module-maps -I %S/Inputs/outofdate-rebuild \ +// RUN: %s -fsyntax-only + + +// Unrelated to the above: Check that a relative path is resolved correctly. +// +// RUN: %clang_cc1 -working-directory %T/rel -fmodules-cache-path=./cache \ +// RUN: -fmodules -fimplicit-module-maps -I %S/Inputs/outofdate-rebuild \ +// RUN: -fdisable-module-hash %t.m -fsyntax-only -Rmodule-build 2>&1 \ +// RUN: | FileCheck %s +// CHECK: /rel/cache/CoreText.pcm +@import Cocoa; Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp === --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -1419,7 +1419,8 @@ return P.str(); } -static void ParseHeaderSearchArgs(HeaderSearchOptions , ArgList ) { +static void ParseHeaderSearchArgs(HeaderSearchOptions , ArgList , +
r297790 - Canonicalize the path provided by -fmodules-cache-path.
Author: adrian Date: Tue Mar 14 18:07:49 2017 New Revision: 297790 URL: http://llvm.org/viewvc/llvm-project?rev=297790=rev Log: Canonicalize the path provided by -fmodules-cache-path. This fixes lookup mismatches that could happen when the module cache path contained a '/./' component. Differential Revision: https://reviews.llvm.org/D30915 Added: cfe/trunk/test/Modules/Inputs/outofdate-rebuild/ cfe/trunk/test/Modules/Inputs/outofdate-rebuild/AppKit.h cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Cocoa.h cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreText.h cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreVideo.h cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Foundation.h cfe/trunk/test/Modules/Inputs/outofdate-rebuild/module.modulemap cfe/trunk/test/Modules/modules-cache-path-canonicalization.m Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=297790=297789=297790=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Mar 14 18:07:49 2017 @@ -1419,7 +1419,8 @@ std::string CompilerInvocation::GetResou return P.str(); } -static void ParseHeaderSearchArgs(HeaderSearchOptions , ArgList ) { +static void ParseHeaderSearchArgs(HeaderSearchOptions , ArgList , + const std::string ) { using namespace options; Opts.Sysroot = Args.getLastArgValue(OPT_isysroot, "/"); Opts.Verbose = Args.hasArg(OPT_v); @@ -1429,7 +1430,18 @@ static void ParseHeaderSearchArgs(Header if (const Arg *A = Args.getLastArg(OPT_stdlib_EQ)) Opts.UseLibcxx = (strcmp(A->getValue(), "libc++") == 0); Opts.ResourceDir = Args.getLastArgValue(OPT_resource_dir); - Opts.ModuleCachePath = Args.getLastArgValue(OPT_fmodules_cache_path); + + // Canonicalize -fmodules-cache-path before storing it. + SmallString<128> P(Args.getLastArgValue(OPT_fmodules_cache_path)); + if (!(P.empty() || llvm::sys::path::is_absolute(P))) { +if (WorkingDir.empty()) + llvm::sys::fs::make_absolute(P); +else + llvm::sys::fs::make_absolute(WorkingDir, P); + } + llvm::sys::path::remove_dots(P); + Opts.ModuleCachePath = P.str(); + Opts.ModuleUserBuildPath = Args.getLastArgValue(OPT_fmodules_user_build_path); for (const Arg *A : Args.filtered(OPT_fprebuilt_module_path)) Opts.AddPrebuiltModulePath(A->getValue()); @@ -2496,7 +2508,8 @@ bool CompilerInvocation::CreateFromArgs( ParseTargetArgs(Res.getTargetOpts(), Args, Diags); Success &= ParseCodeGenArgs(Res.getCodeGenOpts(), Args, DashX, Diags, Res.getTargetOpts()); - ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args); + ParseHeaderSearchArgs(Res.getHeaderSearchOpts(), Args, +Res.getFileSystemOpts().WorkingDir); if (DashX == IK_AST || DashX == IK_LLVM_IR) { // ObjCAAutoRefCount and Sanitize LangOpts are used to setup the // PassManager in BackendUtil.cpp. They need to be initializd no matter Added: cfe/trunk/test/Modules/Inputs/outofdate-rebuild/AppKit.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/outofdate-rebuild/AppKit.h?rev=297790=auto == --- cfe/trunk/test/Modules/Inputs/outofdate-rebuild/AppKit.h (added) +++ cfe/trunk/test/Modules/Inputs/outofdate-rebuild/AppKit.h Tue Mar 14 18:07:49 2017 @@ -0,0 +1,3 @@ +// AppKit +#import "CoreVideo.h" // CoreVideo +struct B { int i; }; Added: cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Cocoa.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Cocoa.h?rev=297790=auto == --- cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Cocoa.h (added) +++ cfe/trunk/test/Modules/Inputs/outofdate-rebuild/Cocoa.h Tue Mar 14 18:07:49 2017 @@ -0,0 +1,5 @@ +// Cocoa +#import "Foundation.h" +#import "AppKit.h" + +struct A { int i; }; Added: cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreText.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreText.h?rev=297790=auto == --- cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreText.h (added) +++ cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreText.h Tue Mar 14 18:07:49 2017 @@ -0,0 +1 @@ +struct C { int i; }; Added: cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreVideo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/outofdate-rebuild/CoreVideo.h?rev=297790=auto == ---
[PATCH] D30810: Preserve vec3 type.
ahatanak added a comment. Actually, it's not a mis-compile. The record layout shows that there is a padding before field f2 and f2 starts at byte 16. So using "store <4 x float>" doesn't overwrite the field. https://reviews.llvm.org/D30810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30810: Preserve vec3 type.
ahatanak added a comment. It looks like converting vec3 to vec4 is incorrect in some cases. In the following program, IRGen emits "store <4 x float>" to store g1 to *a, which will overwrite s1.f2. typedef __attribute__((__ext_vector_type__(3))) float float3; struct S1 { float3 f1; float f2; }; float3 g1; void __attribute__((noinline)) foo2(float3 *a) { *a = g1; } void foo1() { struct S1 s1; foo2(); } https://reviews.llvm.org/D30810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29851: [clang-tools-extra] [test] Fix test dependencies when using installed tools
beanz accepted this revision. beanz added a comment. This revision is now accepted and ready to land. Ugh... I really don't like how `LLVM_UTILS_PROVIDED` is implemented, but I guess it is fine. This patch is good. Repository: rL LLVM https://reviews.llvm.org/D29851 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30766: Add support for attribute "enum_extensibility"
ahatanak added inline comments. Comment at: test/Sema/enum-attr.c:27 + +enum __attribute__((enum_extensibility(arg1))) EnumInvalidArg { // expected-warning{{'enum_extensibility' attribute argument not supported: 'arg1'}} + G aaron.ballman wrote: > ahatanak wrote: > > arphaman wrote: > > > Should this be an error instead? > > Yes, I agree. > I'm not opposed to it, but we do treat it as a warning for every other > attribute (and just ignore the attribute), FWIW. Do you know the reason we treat wrong attribute arguments as a warning in other cases rather than an error? I'm guessing a warning is preferred because in most cases dropping an attribute doesn't affect correctness (it doesn't cause miscompiles). https://reviews.llvm.org/D30766 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30766: Add support for attribute "enum_extensibility"
ahatanak updated this revision to Diff 91782. ahatanak marked 3 inline comments as done. ahatanak added a comment. Address review comments from Aaron. https://reviews.llvm.org/D30766 Files: include/clang/AST/Decl.h include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td include/clang/Basic/DiagnosticSemaKinds.td lib/AST/Decl.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaStmt.cpp test/Sema/enum-attr.c test/SemaCXX/attr-flag-enum-reject.cpp test/SemaCXX/enum-attr.cpp Index: test/SemaCXX/enum-attr.cpp === --- /dev/null +++ test/SemaCXX/enum-attr.cpp @@ -0,0 +1,108 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wassign-enum -Wswitch-enum -Wcovered-switch-default -std=c++11 %s + +enum Enum { + A0 = 1, A1 = 10 +}; + +enum __attribute__((enum_extensibility(closed))) EnumClosed { + B0 = 1, B1 = 10 +}; + +enum [[clang::enum_extensibility(open)]] EnumOpen { + C0 = 1, C1 = 10 +}; + +enum __attribute__((flag_enum)) EnumFlag { + D0 = 1, D1 = 8 +}; + +enum __attribute__((flag_enum,enum_extensibility(closed))) EnumFlagClosed { + E0 = 1, E1 = 8 +}; + +enum __attribute__((flag_enum,enum_extensibility(open))) EnumFlagOpen { + F0 = 1, F1 = 8 +}; + +void test() { + enum Enum t0; + + switch (t0) { // expected-warning{{enumeration value 'A1' not handled in switch}} + case A0: break; + case 16: break; // expected-warning{{case value not in enumerated type}} + } + + switch (t0) { + case A0: break; + case A1: break; + default: break; // expected-warning{{default label in switch which covers all enumeration}} + } + + enum EnumClosed t1; + + switch (t1) { // expected-warning{{enumeration value 'B1' not handled in switch}} + case B0: break; + case 16: break; // expected-warning{{case value not in enumerated type}} + } + + switch (t1) { + case B0: break; + case B1: break; + default: break; // expected-warning{{default label in switch which covers all enumeration}} + } + + enum EnumOpen t2; + + switch (t2) { // expected-warning{{enumeration value 'C1' not handled in switch}} + case C0: break; + case 16: break; + } + + switch (t2) { + case C0: break; + case C1: break; + default: break; + } + + enum EnumFlag t3; + + switch (t3) { // expected-warning{{enumeration value 'D1' not handled in switch}} + case D0: break; + case 9: break; + case 16: break; // expected-warning{{case value not in enumerated type}} + } + + switch (t3) { + case D0: break; + case D1: break; + default: break; + } + + enum EnumFlagClosed t4; + + switch (t4) { // expected-warning{{enumeration value 'E1' not handled in switch}} + case E0: break; + case 9: break; + case 16: break; // expected-warning{{case value not in enumerated type}} + } + + switch (t4) { + case E0: break; + case E1: break; + default: break; + } + + enum EnumFlagOpen t5; + + switch (t5) { // expected-warning{{enumeration value 'F1' not handled in switch}} + case F0: break; + case 9: break; + case 16: break; + } + + switch (t5) { + case F0: break; + case F1: break; + default: break; + } +} Index: test/SemaCXX/attr-flag-enum-reject.cpp === --- test/SemaCXX/attr-flag-enum-reject.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// RUN: %clang_cc1 -verify -fsyntax-only -x c++ -Wassign-enum %s - -enum __attribute__((flag_enum)) flag { // expected-warning {{ignored}} -}; Index: test/Sema/enum-attr.c === --- /dev/null +++ test/Sema/enum-attr.c @@ -0,0 +1,129 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wassign-enum -Wswitch-enum -Wcovered-switch-default %s + +enum Enum { + A0 = 1, A1 = 10 +}; + +enum __attribute__((enum_extensibility(closed))) EnumClosed { + B0 = 1, B1 = 10 +}; + +enum __attribute__((enum_extensibility(open))) EnumOpen { + C0 = 1, C1 = 10 +}; + +enum __attribute__((flag_enum)) EnumFlag { + D0 = 1, D1 = 8 +}; + +enum __attribute__((flag_enum,enum_extensibility(closed))) EnumFlagClosed { + E0 = 1, E1 = 8 +}; + +enum __attribute__((flag_enum,enum_extensibility(open))) EnumFlagOpen { + F0 = 1, F1 = 8 +}; + +enum __attribute__((enum_extensibility(arg1))) EnumInvalidArg { // expected-error{{'enum_extensibility' attribute argument not supported: 'arg1'}} + X0 +}; + +enum __attribute__((enum_extensibility(closed,open))) EnumTooManyArgs { // expected-error{{use of undeclared identifier 'open'}} + X1 +}; + +enum __attribute__((enum_extensibility())) EnumTooFewArgs { // expected-error{{'enum_extensibility' attribute takes one argument}} + X2 +}; + +struct __attribute__((enum_extensibility(open))) S { // expected-warning{{'enum_extensibility' attribute only applies to enums}}{ +}; + +void test() { + enum Enum t0 = 100; // expected-warning{{integer constant not in range of enumerated type}} + t0 = 1; + + switch (t0) { // expected-warning{{enumeration value 'A1' not handled in switch}} + case A0:
[PATCH] D30954: Modules: Simulate diagnostic settings for implicit modules
dexonsmith created this revision. This is a follow-up to r293123 that makes it work with implicit modules. Some background: An implicit module build (using Clang's internal build system) uses the same PCM file location for different `-Werror` levels. E.g., if a TU has `-Werror=format` and tries to load a PCM built without `-Werror=format`, a new PCM will be built in its place (and the new PCM should have the same signature, since r297655). In the other direction, if a TU does not have `-Werror=format` and tries to load a PCM built with `-Werror=format`, it should "just work". The idea is to evolve the PCM toward the strictest -Werror flags that anyone tries. --- r293123 started serializing the diagnostic state for each PCM, which broke the implicit build model. This commit filters the diagnostic state to match the current compilation's diagnostic settings. - Ignore the module's serialized first diagnostic state. Use this TU's state instead. - If a pragma warning was upgraded to error/fatal when generating the PCM (e.g., due to `-Werror` on the command-line), check whether it should still be upgraded in its current context. Some feedback I'd like on this approach: 1. The patch-as-is checks whether pragmas should be demoted to warnings for all AST files, not just implicit modules. I can add a bit of logic to ReadPragmaDiagnosticMappings that limits it to `F.Kind == MK_ImplicitModule`, but I'm not sure it's necessary. Maybe it hits when reading PCH files, but no tests fail, and I'm not sure this is worse... thoughts? 2. If `ReadDiagState` sees a back-reference, it doesn't bother to check whether pragmas should be demoted; it assumes it should match whatever was done with the back-reference. - I think this could be exercised with `-Werror=X` on the command-line and pragmas modifying -WX (first "ignored", then "error", then "warning"). Perhaps I should add a FIXME or a comment, but otherwise I think this is okay to miss... - It could be a back-reference to `CurDiagState`, which current gets (de)serialized before the pragma mappings. If we instead (de)serialize `CurDiagState` last, I think this one goes away. Is there a problem with that? https://reviews.llvm.org/D30954 Files: clang/include/clang/Basic/Diagnostic.h clang/include/clang/Basic/DiagnosticIDs.h clang/lib/Basic/Diagnostic.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/Modules/Inputs/implicit-built-Werror-using-W/convert.h clang/test/Modules/Inputs/implicit-built-Werror-using-W/module.modulemap clang/test/Modules/implicit-built-Werror-using-W.cpp Index: clang/test/Modules/implicit-built-Werror-using-W.cpp === --- /dev/null +++ clang/test/Modules/implicit-built-Werror-using-W.cpp @@ -0,0 +1,42 @@ +// Check that implicit modules builds give correct diagnostics, even when +// reusing a module built with strong -Werror flags. +// +// Clear the caches. +// RUN: rm -rf %t.cache %t-pragma.cache +// +// Build with -Werror, then with -W, and then with neither. +// RUN: not %clang_cc1 -triple x86_64-apple-darwin16 -fsyntax-only -fmodules \ +// RUN: -Werror=shorten-64-to-32 \ +// RUN: -I%S/Inputs/implicit-built-Werror-using-W -fimplicit-module-maps \ +// RUN: -fmodules-cache-path=%t.cache -x c++ %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-ERROR +// RUN: %clang_cc1 -triple x86_64-apple-darwin16 -fsyntax-only -fmodules \ +// RUN: -Wshorten-64-to-32 \ +// RUN: -I%S/Inputs/implicit-built-Werror-using-W -fimplicit-module-maps \ +// RUN: -fdisable-module-hash \ +// RUN: -fmodules-cache-path=%t.cache -x c++ %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-WARN +// RUN: %clang_cc1 -triple x86_64-apple-darwin16 -fsyntax-only -fmodules \ +// RUN: -I%S/Inputs/implicit-built-Werror-using-W -fimplicit-module-maps \ +// RUN: -fmodules-cache-path=%t.cache -x c++ %s 2>&1 \ +// RUN: | FileCheck %s -allow-empty +// +// In the presence of a warning pragma, build with -Werror and then without. +// RUN: not %clang_cc1 -triple x86_64-apple-darwin16 -fsyntax-only -fmodules \ +// RUN: -DUSE_PRAGMA -Werror=shorten-64-to-32 \ +// RUN: -I%S/Inputs/implicit-built-Werror-using-W -fimplicit-module-maps \ +// RUN: -fmodules-cache-path=%t-pragma.cache -x c++ %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-ERROR +// RUN: %clang_cc1 -triple x86_64-apple-darwin16 -fsyntax-only -fmodules \ +// RUN: -DUSE_PRAGMA \ +// RUN: -I%S/Inputs/implicit-built-Werror-using-W -fimplicit-module-maps \ +// RUN: -fmodules-cache-path=%t-pragma.cache -x c++ %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-WARN +#include + +long long foo() { return convert(0); } + +// CHECK-ERROR: error: implicit conversion +// CHECK-WARN: warning: implicit conversion +// CHECK-NOT: error: implicit conversion +//
r297784 - Fix Wdocumentation warning
Author: rksimon Date: Tue Mar 14 16:43:52 2017 New Revision: 297784 URL: http://llvm.org/viewvc/llvm-project?rev=297784=rev Log: Fix Wdocumentation warning Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=297784=297783=297784=diff == --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Mar 14 16:43:52 2017 @@ -687,7 +687,7 @@ void CodeGenFunction::EmitNullabilityChe llvm::Value *IsNotNull = Builder.CreateIsNotNull(RHS); llvm::Constant *StaticData[] = { EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(LHS.getType()), - llvm::ConstantInt::get(Int8Ty, 0), //< The LogAlignment info is unused. + llvm::ConstantInt::get(Int8Ty, 0), // The LogAlignment info is unused. llvm::ConstantInt::get(Int8Ty, TCK_NonnullAssign)}; EmitCheck({{IsNotNull, SanitizerKind::NullabilityAssign}}, SanitizerHandler::TypeMismatch, StaticData, RHS); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29818: [libcxx] Threading support: Attempt to externalize system_clock::now() and steady_clock::now() implementations
jroelofs added a comment. In https://reviews.llvm.org/D29818#700949, @ed wrote: > Worth mentioning: the latest version of macOS now supports `clock_gettime()`. > Maybe better to leave the code as is and simply axe the Mach time code at > some point in the future? Supporting only the latest and greatest is unfriendly to folks who are stuck on particular versions... https://reviews.llvm.org/D29818 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29818: [libcxx] Threading support: Attempt to externalize system_clock::now() and steady_clock::now() implementations
ed added a comment. Worth mentioning: the latest version of macOS now supports `clock_gettime()`. Maybe better to leave the code as is and simply axe the Mach time code at some point in the future? https://reviews.llvm.org/D29818 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30675: [clangd] Fix not being able to attach a debugger on macOS
This revision was automatically updated to reflect the committed changes. Closed by commit rL297779: [clangd] Fix not being able to attach a debugger on macOS (authored by d0k). Changed prior to commit: https://reviews.llvm.org/D30675?vs=91246=91768#toc Repository: rL LLVM https://reviews.llvm.org/D30675 Files: clang-tools-extra/trunk/clangd/ClangDMain.cpp Index: clang-tools-extra/trunk/clangd/ClangDMain.cpp === --- clang-tools-extra/trunk/clangd/ClangDMain.cpp +++ clang-tools-extra/trunk/clangd/ClangDMain.cpp @@ -67,6 +67,10 @@ // by \r\n. std::string Line; std::getline(std::cin, Line); +if (!std::cin.good() && errno == EINTR) { + std::cin.clear(); + continue; +} // Skip empty lines. llvm::StringRef LineRef(Line); Index: clang-tools-extra/trunk/clangd/ClangDMain.cpp === --- clang-tools-extra/trunk/clangd/ClangDMain.cpp +++ clang-tools-extra/trunk/clangd/ClangDMain.cpp @@ -67,6 +67,10 @@ // by \r\n. std::string Line; std::getline(std::cin, Line); +if (!std::cin.good() && errno == EINTR) { + std::cin.clear(); + continue; +} // Skip empty lines. llvm::StringRef LineRef(Line); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r297779 - [clangd] Fix not being able to attach a debugger on macOS
Author: d0k Date: Tue Mar 14 15:41:28 2017 New Revision: 297779 URL: http://llvm.org/viewvc/llvm-project?rev=297779=rev Log: [clangd] Fix not being able to attach a debugger on macOS Clangd is often waiting for input on getline as it awaits requests. If the getline is interrupted, it causes the system call (read) to fail and the EINTR error to be set. This can be seen when attaching a debugger such as LLDB on macOS. On macOS (and possibly other operating systems), this system call is not restarted after interruption but on Linux it is restarted which is why attaching a debugger does work correctly there. The solution is to work around the non-restarting system call by checking the errno for EINTR when the stream fails and try again. This should be safe on all Unixish platforms. See also http://bugs.llvm.org/show_bug.cgi?id=32149 for some background discussion. Patch by Marc-Andre Laperle! Differential Revision: https://reviews.llvm.org/D30675 Modified: clang-tools-extra/trunk/clangd/ClangDMain.cpp Modified: clang-tools-extra/trunk/clangd/ClangDMain.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangDMain.cpp?rev=297779=297778=297779=diff == --- clang-tools-extra/trunk/clangd/ClangDMain.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangDMain.cpp Tue Mar 14 15:41:28 2017 @@ -67,6 +67,10 @@ int main(int argc, char *argv[]) { // by \r\n. std::string Line; std::getline(std::cin, Line); +if (!std::cin.good() && errno == EINTR) { + std::cin.clear(); + continue; +} // Skip empty lines. llvm::StringRef LineRef(Line); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297778 - [Hexagon] Recognize hexagonv62 as a valid target CPU
Author: kparzysz Date: Tue Mar 14 15:29:23 2017 New Revision: 297778 URL: http://llvm.org/viewvc/llvm-project?rev=297778=rev Log: [Hexagon] Recognize hexagonv62 as a valid target CPU Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/test/Driver/hexagon-toolchain-elf.c Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=297778=29=297778=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 14 15:29:23 2017 @@ -2326,6 +2326,8 @@ def mv55 : Flag<["-"], "mv55">, Group, AliasArgs<["hexagonv55"]>; def mv60 : Flag<["-"], "mv60">, Group, Alias, AliasArgs<["hexagonv60"]>; +def mv62 : Flag<["-"], "mv62">, Group, + Alias, AliasArgs<["hexagonv62"]>; def mhexagon_hvx : Flag<["-"], "mhvx">, Group, Flags<[CC1Option]>, HelpText<"Enable Hexagon Vector eXtensions">; def mno_hexagon_hvx : Flag<["-"], "mno-hvx">, Group, Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=297778=29=297778=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Tue Mar 14 15:29:23 2017 @@ -6461,6 +6461,7 @@ public: .Case("hexagonv5", "5") .Case("hexagonv55", "55") .Case("hexagonv60", "60") + .Case("hexagonv62", "62") .Default(nullptr); } @@ -6505,6 +6506,9 @@ void HexagonTargetInfo::getTargetDefines Builder.defineMacro("__HEXAGON_ARCH__", "60"); Builder.defineMacro("__QDSP6_V60__"); Builder.defineMacro("__QDSP6_ARCH__", "60"); + } else if (CPU == "hexagonv62") { +Builder.defineMacro("__HEXAGON_V62__"); +Builder.defineMacro("__HEXAGON_ARCH__", "62"); } if (hasFeature("hvx")) { Modified: cfe/trunk/test/Driver/hexagon-toolchain-elf.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hexagon-toolchain-elf.c?rev=297778=29=297778=diff == --- cfe/trunk/test/Driver/hexagon-toolchain-elf.c (original) +++ cfe/trunk/test/Driver/hexagon-toolchain-elf.c Tue Mar 14 15:29:23 2017 @@ -89,6 +89,14 @@ // CHECK023: "-cc1" {{.*}} "-target-cpu" "hexagonv60" // CHECK023: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v60/crt0 +// RUN: %clang -### -target hexagon-unknown-elf \ +// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \ +// RUN: -mcpu=hexagonv62 \ +// RUN: %s 2>&1 \ +// RUN: | FileCheck -check-prefix=CHECK024 %s +// CHECK024: "-cc1" {{.*}} "-target-cpu" "hexagonv62" +// CHECK024: hexagon-link{{.*}}/Inputs/hexagon_tree/Tools/bin/../target/hexagon/lib/v62/crt0 + // - // Test Linker related args // - ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30675: [clangd] Fix not being able to attach a debugger on macOS
malaperle-ericsson added a comment. In https://reviews.llvm.org/D30675#700917, @bkramer wrote: > lg, do you have commit access? No I do not have commit access. Could you commit it? Thank you very much! https://reviews.llvm.org/D30675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30675: [clangd] Fix not being able to attach a debugger on macOS
bkramer accepted this revision. bkramer added a comment. This revision is now accepted and ready to land. lg, do you have commit access? https://reviews.llvm.org/D30675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30898: Add new -fverbose-asm that enables source interleaving
hfinkel added a comment. > Note that in contrast to the original suggestion -fsource-asm here we use the > preferred -fverbose-asm. Basically explicitly saying -fverbose-asm in the > command line enables a minimum amount of debugging, so in AsmPrinter we can > use it to print the source code. -fverbose-asm seems like a good name to me, but that's taken already. This feature should imply -fverbose-asm (that's where the value-add is over having objdump do this). But we don't always want this when we enable -fverbose-asm. How about -fsource-interleaved-asm for this feature? > This patch introduces a -masm-source flag for cc1 that maps to the AsmSource > value in the llvm code generation. I see no reason to use a different flag name for cc1. Just use the same flag (tag it with `Flags<[CC1Option]` in the .td file). Comment at: lib/Driver/ToolChains/Clang.cpp:2754 + // assembler output with debug directives. + if (Args.hasArg(options::OPT_fverbose_asm)) { +CmdArgs.push_back("-masm-source"); I think that we should factor this out a bit. This feature is not the only one with this problem. The optimization reporting features also have this property (they need to enable debug info for some reason other than an actual desire to embed debug info in the resulting binaries). I think that we should add some separate feature, which this can toggle, but that optimization reporting can also use, to avoid actually generating debug info when only needed by these features. Comment at: lib/Frontend/CompilerInvocation.cpp:855 NeedLocTracking = true; if (Arg *A = Args.getLastArg(OPT_Rpass_EQ)) { This is where you'd enable debug line-table info when needed by this feature. https://reviews.llvm.org/D30898 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r297772 - Fixed unintentional assignment-in-assert in new "extending memory management tools" algorithms.
Author: bion Date: Tue Mar 14 14:36:30 2017 New Revision: 297772 URL: http://llvm.org/viewvc/llvm-project?rev=297772=rev Log: Fixed unintentional assignment-in-assert in new "extending memory management tools" algorithms. Modified: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp Modified: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp?rev=297772=297771=297772=diff == --- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp Tue Mar 14 14:36:30 2017 @@ -80,7 +80,7 @@ void test_counted() Counted* p = (Counted*)pool; std::uninitialized_default_construct(It(p), It(p+1)); assert(Counted::count == 1); -assert(Counted::constructed = 1); +assert(Counted::constructed == 1); std::uninitialized_default_construct(It(p+1), It(p+N)); assert(Counted::count == 5); assert(Counted::constructed == 5); Modified: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp?rev=297772=297771=297772=diff == --- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp Tue Mar 14 14:36:30 2017 @@ -80,7 +80,7 @@ void test_counted() It e = std::uninitialized_default_construct_n(It(p), 1); assert(e == It(p+1)); assert(Counted::count == 1); -assert(Counted::constructed = 1); +assert(Counted::constructed == 1); e = std::uninitialized_default_construct_n(It(p+1), 4); assert(e == It(p+N)); assert(Counted::count == 5); Modified: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp?rev=297772=297771=297772=diff == --- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp (original) +++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp Tue Mar 14 14:36:30 2017 @@ -79,7 +79,7 @@ void test_counted() Counted* p = (Counted*)pool; std::uninitialized_value_construct(It(p), It(p+1)); assert(Counted::count == 1); -assert(Counted::constructed = 1); +assert(Counted::constructed == 1); std::uninitialized_value_construct(It(p+1), It(p+N)); assert(Counted::count == 5); assert(Counted::constructed == 5); Modified: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp?rev=297772=297771=297772=diff == --- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp (original) +++
r297770 - Modules: Optimize bitcode encoding of diagnostic state
Author: dexonsmith Date: Tue Mar 14 14:31:27 2017 New Revision: 297770 URL: http://llvm.org/viewvc/llvm-project?rev=297770=rev Log: Modules: Optimize bitcode encoding of diagnostic state Since bitcode uses VBR encoding, large numbers are more expensive than small ones. Instead of emitting a UINT_MAX sentinel after each sequence of state-change pairs, emit the size of the sequence as a prefix. This should have no functionality change besides saving bits from the encoding. Modified: cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/lib/Serialization/ASTWriter.cpp Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=297770=297769=297770=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Mar 14 14:31:27 2017 @@ -5463,16 +5463,16 @@ void ASTReader::ReadPragmaDiagnosticMapp Diag.DiagStates.push_back(BasedOn); DiagState *NewState = (); DiagStates.push_back(NewState); - while (Idx + 1 < Record.size() && Record[Idx] != unsigned(-1)) { + unsigned Size = Record[Idx++]; + assert(Idx + Size * 2 <= Record.size() && + "Invalid data, not enough diag/map pairs"); + while (Size--) { unsigned DiagID = Record[Idx++]; diag::Severity Map = (diag::Severity)Record[Idx++]; DiagnosticMapping Mapping = Diag.makeUserMapping(Map, Loc); if (Mapping.isPragma() || IncludeNonPragmaStates) NewState->setMapping(DiagID, Mapping); } - assert(Idx != Record.size() && Record[Idx] == unsigned(-1) && - "Invalid data, didn't find '-1' marking end of diag/map pairs"); - ++Idx; return NewState; }; Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=297770=297769=297770=diff == --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original) +++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Mar 14 14:31:27 2017 @@ -2871,14 +2871,18 @@ void ASTWriter::WritePragmaDiagnosticMap if (DiagStateID == 0) { DiagStateID = ++CurrID; + + // Add a placeholder for the number of mappings. + auto SizeIdx = Record.size(); + Record.emplace_back(); for (const auto : *State) { if (I.second.isPragma() || IncludeNonPragmaStates) { Record.push_back(I.first); Record.push_back((unsigned)I.second.getSeverity()); } } - // Add a sentinel to mark the end of the diag IDs. - Record.push_back(unsigned(-1)); + // Update the placeholder. + Record[SizeIdx] = (Record.size() - SizeIdx) / 2; } }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30810: Preserve vec3 type.
jaykang10 added a comment. In https://reviews.llvm.org/D30810#700476, @Anastasia wrote: > In https://reviews.llvm.org/D30810#699827, @jaykang10 wrote: > > > In https://reviews.llvm.org/D30810#699695, @bruno wrote: > > > > > Hi JinGu, > > > > > > I just read the discussion on cfe-dev, some comments: > > > > > > > My colleague and I are implementing a transformation pass between LLVM > > > > IR and another IR and we want to keep the 3-component vector types in > > > > our target IR > > > > > > Why can't you go back through the shuffle to find out that it comes from > > > a vec3 -> vec4 transformation? Adding a flag here just for that seems > > > very odd. > > > > > > Hi Bruno, > > > > Thanks for your comment. We have a pass to undo the vec4 to vec3. I > > wondered why clang generates the vec4 for vec3 load/store. As you can see > > the comment on clang's code, they are generated for better performance. I > > had a questions at this point. clang should consider vector load/store > > aligned by 4 regardless of target??? llvm's codegen could handle vec3 > > according to targets' vector load/store with their alignment. I agree the > > flag looks odd but I was concerned some llvm's targets depend on the vec4 > > so I suggested to add the flag. If I missed something, please let me know. > > > I think doing this transformation in a frontend was not the best choice > because we are losing the source information too early. But some targets can > offer a better support for vec3 natively than converting to vec4. Regarding > the option, I am wondering whether adding this as a part of TargetInfo would > be a better solution. Although, I don't think any currently available > upstream targets support this. In https://reviews.llvm.org/D30810#700476, @Anastasia wrote: > In https://reviews.llvm.org/D30810#699827, @jaykang10 wrote: > > > In https://reviews.llvm.org/D30810#699695, @bruno wrote: > > > > > Hi JinGu, > > > > > > I just read the discussion on cfe-dev, some comments: > > > > > > > My colleague and I are implementing a transformation pass between LLVM > > > > IR and another IR and we want to keep the 3-component vector types in > > > > our target IR > > > > > > Why can't you go back through the shuffle to find out that it comes from > > > a vec3 -> vec4 transformation? Adding a flag here just for that seems > > > very odd. > > > > > > Hi Bruno, > > > > Thanks for your comment. We have a pass to undo the vec4 to vec3. I > > wondered why clang generates the vec4 for vec3 load/store. As you can see > > the comment on clang's code, they are generated for better performance. I > > had a questions at this point. clang should consider vector load/store > > aligned by 4 regardless of target??? llvm's codegen could handle vec3 > > according to targets' vector load/store with their alignment. I agree the > > flag looks odd but I was concerned some llvm's targets depend on the vec4 > > so I suggested to add the flag. If I missed something, please let me know. > > > I think doing this transformation in a frontend was not the best choice > because we are losing the source information too early. But some targets can > offer a better support for vec3 natively than converting to vec4. Regarding > the option, I am wondering whether adding this as a part of TargetInfo would > be a better solution. Although, I don't think any currently available > upstream targets support this. I have a fundamental question for vec3 load/store again. I have checked how llvm's codegen handles the vec3 and vec4 load/store. Assuming that target's action is widen for vector type unsupported. If they have same alignment, the llvm's codegen generates one vector load for both of them. But it handles store differently between vec3 and vec4 on DAGTypeLegalizer because vec4 store writes place over vec3 type. For example, source code typedef float float3 __attribute__((ext_vector_type(3))); void foo(float3 *a, float3 *b) { *a = *b; } LLVM IR for vec4 (it is original clang's output) define void @foo(<3 x float>* nocapture %a, <3 x float>* nocapture readonly %b) { entry: %castToVec4 = bitcast <3 x float>* %b to <4 x float>* %loadVec4 = load <4 x float>, <4 x float>* %castToVec4, align 16 %storetmp = bitcast <3 x float>* %a to <4 x float>* store <4 x float> %loadVec4, <4 x float>* %storetmp, align 16 ret void } LLVM IR for vec3 define void @foo(<3 x float>* nocapture %a, <3 x float>* nocapture readonly %b) { entry: %0 = load <3 x float>, <3 x float>* %b, align 16 store <3 x float> %0, <3 x float>* %a, align 16 ret void } As you can see above IR for vec4, "store <4 x float> %loadVec4, <4 x float>* %storetmp, align 16" writes place beyond float3. Is the behavior correct??? I can not find which spec or document mentions it... The vec3 store are lowered to more instructions such as stores and extractelements but the behavior is correct. If the vec3 -->
r297764 - Fix arch-specific-libdir tests on Windows
Author: rnk Date: Tue Mar 14 13:24:41 2017 New Revision: 297764 URL: http://llvm.org/viewvc/llvm-project?rev=297764=rev Log: Fix arch-specific-libdir tests on Windows This is pretty horrible, but I forget if we have any better ways to handle these backslashing issues. Modified: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c cfe/trunk/test/Driver/arch-specific-libdir.c Modified: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arch-specific-libdir-rpath.c?rev=297764=297763=297764=diff == --- cfe/trunk/test/Driver/arch-specific-libdir-rpath.c (original) +++ cfe/trunk/test/Driver/arch-specific-libdir-rpath.c Tue Mar 14 13:24:41 2017 @@ -76,10 +76,10 @@ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s // -// RESDIR: "-resource-dir" "[[RESDIR:[^ ]*]]" -// LIBPATH-X86_64: -L[[RESDIR]]/lib/linux/x86_64 -// RPATH-X86_64:"-rpath" "[[RESDIR]]/lib/linux/x86_64" -// LIBPATH-AArch64: -L[[RESDIR]]/lib/linux/aarch64 -// RPATH-AArch64: "-rpath" "[[RESDIR]]/lib/linux/aarch64" -// NO-LIBPATH-NOT: -L{{.*}}Inputs/resource_dir -// NO-RPATH-NOT:"-rpath" {{.*}}/Inputs/resource_dir +// RESDIR: "-resource-dir" "[[RESDIR:[^"]*]]" +// LIBPATH-X86_64: -L[[RESDIR]]{{(/|)lib(/|)linux(/|)x86_64}} +// RPATH-X86_64:"-rpath" "[[RESDIR]]{{(/|)lib(/|)linux(/|)x86_64}}" +// LIBPATH-AArch64: -L[[RESDIR]]{{(/|)lib(/|)linux(/|)aarch64}} +// RPATH-AArch64: "-rpath" "[[RESDIR]]{{(/|)lib(/|)linux(/|)aarch64}}" +// NO-LIBPATH-NOT: -L{{.*Inputs(/|)resource_dir}} +// NO-RPATH-NOT:"-rpath" {{.*(/|)Inputs(/|)resource_dir}} Modified: cfe/trunk/test/Driver/arch-specific-libdir.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arch-specific-libdir.c?rev=297764=297763=297764=diff == --- cfe/trunk/test/Driver/arch-specific-libdir.c (original) +++ cfe/trunk/test/Driver/arch-specific-libdir.c Tue Mar 14 13:24:41 2017 @@ -42,11 +42,11 @@ // RUN: | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s // // -// FILEPATH: "-x" "c" "[[FILE_PATH:.*]]/{{.*}}.c" -// ARCHDIR-i386: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/i386 -// ARCHDIR-x86_64: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64 -// ARCHDIR-arm: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/arm -// ARCHDIR-aarch64: -L[[FILE_PATH]]/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64 +// FILEPATH: "-x" "c" "[[FILE_PATH:.*]]{{(/|).*}}.c" +// ARCHDIR-i386: -L[[FILE_PATH]]{{(/|)Inputs(/|)resource_dir_with_arch_subdir(/|)lib(/|)linux(/|)i386}} +// ARCHDIR-x86_64: -L[[FILE_PATH]]{{(/|)Inputs(/|)resource_dir_with_arch_subdir(/|)lib(/|)linux(/|)x86_64}} +// ARCHDIR-arm: -L[[FILE_PATH]]{{(/|)Inputs(/|)resource_dir_with_arch_subdir(/|)lib(/|)linux(/|)arm}} +// ARCHDIR-aarch64: -L[[FILE_PATH]]{{(/|)Inputs(/|)resource_dir_with_arch_subdir(/|)lib(/|)linux(/|)aarch64}} // // Have a stricter check for no-archdir - that the driver doesn't add any // subdirectory from the provided resource directory. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30949: [CodeGen] Add an option to enable LLVM IR linting
vsk created this revision. LLVM has a nifty linter which checks for some common kinds of unusual or undefined behavior by doing some basic IR-level static analysis. Add a CC1 option to clang which enables this analysis. Having the linter available through clang could be a useful debugging tool. It can also be a useful reporting tool: hacking your build system to add in "-Xclang -enable-llvm-linter" is usually easier than hacking it to add "$CC ... | opt -S -o /dev/null -lint". Eventually, I'd like to teach the linter about the sanitizers, so that it can statically report the kinds of bugs the sanitizers know how to flag. This would work by checking for diagnostic calls which post-dom function entry blocks (unconditionally buggy code). The research paper on the STACK static UB checker suggests that this could be useful. https://reviews.llvm.org/D30949 Files: include/clang/Driver/CC1Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/BackendUtil.cpp lib/Frontend/CompilerInvocation.cpp test/CodeGen/enable-llvm-linter.c Index: test/CodeGen/enable-llvm-linter.c === --- /dev/null +++ test/CodeGen/enable-llvm-linter.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -enable-llvm-linter -O0 -emit-llvm -o /dev/null %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -enable-llvm-linter -O3 -emit-llvm -o /dev/null %s 2>&1 | FileCheck %s + +// CHECK: Unusual: Address one pointer dereference +// CHECK-NEXT: load i32, i32* +int foo() { + int *p = (int *)1; + return *p; +} Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -650,6 +650,7 @@ Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name); Opts.VerifyModule = !Args.hasArg(OPT_disable_llvm_verifier); + Opts.LintModule = Args.hasArg(OPT_enable_llvm_linter); Opts.DisableGCov = Args.hasArg(OPT_test_coverage); Opts.EmitGcovArcs = Args.hasArg(OPT_femit_coverage_data); Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -19,6 +19,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" +#include "llvm/Analysis/Lint.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Bitcode/BitcodeReader.h" @@ -257,6 +258,11 @@ PM.add(createEfficiencySanitizerPass(Opts)); } +static void addLinterPass(const PassManagerBuilder , + legacy::PassManagerBase ) { + PM.add(createLintPass()); +} + static TargetLibraryInfoImpl *createTLII(llvm::Triple , const CodeGenOptions ) { TargetLibraryInfoImpl *TLII = new TargetLibraryInfoImpl(TargetTriple); @@ -415,6 +421,12 @@ addEfficiencySanitizerPass); } + if (CodeGenOpts.LintModule) { +PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast, addLinterPass); +PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0, + addLinterPass); + } + // Set up the per-function pass manager. FPM.add(new TargetLibraryInfoWrapperPass(*TLII)); if (CodeGenOpts.VerifyModule) Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -184,6 +184,9 @@ CODEGENOPT(VerifyModule , 1, 1) ///< Control whether the module should be run ///< through the LLVM Verifier. +CODEGENOPT(LintModule, 1, 0) ///< Control whether the module should be run + ///< through the LLVM Linter. + CODEGENOPT(StackRealignment , 1, 0) ///< Control whether to force stack ///< realignment. CODEGENOPT(UseInitArray , 1, 0) ///< Control whether to use .init_array or Index: include/clang/Driver/CC1Options.td === --- include/clang/Driver/CC1Options.td +++ include/clang/Driver/CC1Options.td @@ -164,6 +164,8 @@ def disable_llvm_verifier : Flag<["-"], "disable-llvm-verifier">, HelpText<"Don't run the LLVM IR verifier pass">; +def enable_llvm_linter : Flag<["-"], "enable-llvm-linter">, + HelpText<"Run the LLVM IR linter pass">; def disable_llvm_passes : Flag<["-"], "disable-llvm-passes">, HelpText<"Use together with -emit-llvm to get pristine LLVM IR from the " "frontend by not running any LLVM passes at all">; Index: test/CodeGen/enable-llvm-linter.c === --- /dev/null +++ test/CodeGen/enable-llvm-linter.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1
[PATCH] D30923: Warn on enum assignment to bitfields that can't fit all values
This revision was automatically updated to reflect the committed changes. Closed by commit rL297761: Warn on enum assignment to bitfields that can't fit all values (authored by rnk). Changed prior to commit: https://reviews.llvm.org/D30923?vs=91749=91752#toc Repository: rL LLVM https://reviews.llvm.org/D30923 Files: cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/SemaCXX/warn-bitfield-enum-conversion.cpp Index: cfe/trunk/lib/Sema/SemaChecking.cpp === --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -8729,13 +8729,66 @@ return false; Expr *OriginalInit = Init->IgnoreParenImpCasts(); + unsigned FieldWidth = Bitfield->getBitWidthValue(S.Context); llvm::APSInt Value; - if (!OriginalInit->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects)) + if (!OriginalInit->EvaluateAsInt(Value, S.Context, + Expr::SE_AllowSideEffects)) { +// The RHS is not constant. If the RHS has an enum type, make sure the +// bitfield is wide enough to hold all the values of the enum without +// truncation. +if (const auto *EnumTy = OriginalInit->getType()->getAs()) { + EnumDecl *ED = EnumTy->getDecl(); + bool SignedBitfield = BitfieldType->isSignedIntegerType(); + + // Enum types are implicitly signed on Windows, so check if there are any + // negative enumerators to see if the enum was intended to be signed or + // not. + bool SignedEnum = ED->getNumNegativeBits() > 0; + + // Check for surprising sign changes when assigning enum values to a + // bitfield of different signedness. If the bitfield is signed and we + // have exactly the right number of bits to store this unsigned enum, + // suggest changing the enum to an unsigned type. This typically happens + // on Windows where unfixed enums always use an underlying type of 'int'. + unsigned DiagID = 0; + if (SignedEnum && !SignedBitfield) { +DiagID = diag::warn_unsigned_bitfield_assigned_signed_enum; + } else if (SignedBitfield && !SignedEnum && + ED->getNumPositiveBits() == FieldWidth) { +DiagID = diag::warn_signed_bitfield_enum_conversion; + } + + if (DiagID) { +S.Diag(InitLoc, DiagID) << Bitfield << ED; +TypeSourceInfo *TSI = Bitfield->getTypeSourceInfo(); +SourceRange TypeRange = +TSI ? TSI->getTypeLoc().getSourceRange() : SourceRange(); +S.Diag(Bitfield->getTypeSpecStartLoc(), diag::note_change_bitfield_sign) +<< SignedEnum << TypeRange; + } + + // Compute the required bitwidth. If the enum has negative values, we need + // one more bit than the normal number of positive bits to represent the + // sign bit. + unsigned BitsNeeded = SignedEnum ? std::max(ED->getNumPositiveBits() + 1, + ED->getNumNegativeBits()) + : ED->getNumPositiveBits(); + + // Check the bitwidth. + if (BitsNeeded > FieldWidth) { +Expr *WidthExpr = Bitfield->getBitWidth(); +S.Diag(InitLoc, diag::warn_bitfield_too_small_for_enum) +<< Bitfield << ED; +S.Diag(WidthExpr->getExprLoc(), diag::note_widen_bitfield) +<< BitsNeeded << ED << WidthExpr->getSourceRange(); + } +} + return false; + } unsigned OriginalWidth = Value.getBitWidth(); - unsigned FieldWidth = Bitfield->getBitWidthValue(S.Context); if (!Value.isSigned() || Value.isNegative()) if (UnaryOperator *UO = dyn_cast(OriginalInit)) Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -4908,6 +4908,21 @@ def warn_anon_bitfield_width_exceeds_type_width : Warning< "width of anonymous bit-field (%0 bits) exceeds width of its type; value " "will be truncated to %1 bit%s1">, InGroup; +def warn_bitfield_too_small_for_enum : Warning< + "bit-field %0 is not wide enough to store all enumerators of %1">, + InGroup, DefaultIgnore; +def note_widen_bitfield : Note< + "widen this field to %0 bits to store all values of %1">; +def warn_unsigned_bitfield_assigned_signed_enum : Warning< + "assigning value of signed enum type %1 to unsigned bit-field %0; " + "negative enumerators of enum %1 will be converted to positive values">, + InGroup, DefaultIgnore; +def warn_signed_bitfield_enum_conversion : Warning< + "signed bit-field %0 needs an extra bit to represent the largest positive " + "enumerators of %1">, + InGroup, DefaultIgnore; +def note_change_bitfield_sign : Note< + "consider making the bitfield type
r297761 - Warn on enum assignment to bitfields that can't fit all values
Author: rnk Date: Tue Mar 14 13:01:02 2017 New Revision: 297761 URL: http://llvm.org/viewvc/llvm-project?rev=297761=rev Log: Warn on enum assignment to bitfields that can't fit all values This adds -Wbitfield-enum-conversion, which warns on implicit conversions that happen on bitfield assignment that change the value of some enumerators. Values of enum type typically take on a very small range of values, so they are frequently stored in bitfields. Unfortunately, there is no convenient way to calculate the minimum number of bits necessary to store all possible values at compile time, so users usually hard code a bitwidth that works today and widen it as necessary to pass basic testing and validation. This is very error-prone, and leads to stale widths as enums grow. This warning aims to catch such bugs. This would have found two real bugs in clang and two instances of questionable code. See r297680 and r297654 for the full description of the issues. This warning is currently disabled by default while we investigate its usefulness outside of LLVM. The major cause of false positives with this warning is this kind of enum: enum E { W, X, Y, Z, SENTINEL_LAST }; The last enumerator is an invalid value used to validate inputs or size an array. Depending on the prevalance of this style of enum across a codebase, this warning may be more or less feasible to deploy. It also has trouble on sentinel values such as ~0U. Reviewers: rsmith, rtrieu, thakis Reviewed By: thakis Subscribers: hfinkel, voskresensky.vladimir, sashab, cfe-commits Differential Revision: https://reviews.llvm.org/D30923 Added: cfe/trunk/test/SemaCXX/warn-bitfield-enum-conversion.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaChecking.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=297761=297760=297761=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Mar 14 13:01:02 2017 @@ -34,6 +34,7 @@ def CXX14BinaryLiteral : DiagGroup<"c++1 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">; def GNUCompoundLiteralInitializer : DiagGroup<"gnu-compound-literal-initializer">; def BitFieldConstantConversion : DiagGroup<"bitfield-constant-conversion">; +def BitFieldEnumConversion : DiagGroup<"bitfield-enum-conversion">; def BitFieldWidth : DiagGroup<"bitfield-width">; def ConstantConversion : DiagGroup<"constant-conversion", [ BitFieldConstantConversion ] >; @@ -606,6 +607,7 @@ def Conversion : DiagGroup<"conversion", [BoolConversion, ConstantConversion, EnumConversion, +BitFieldEnumConversion, FloatConversion, Shorten64To32, IntConversion, Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=297761=297760=297761=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 14 13:01:02 2017 @@ -4908,6 +4908,21 @@ def warn_bitfield_width_exceeds_type_wid def warn_anon_bitfield_width_exceeds_type_width : Warning< "width of anonymous bit-field (%0 bits) exceeds width of its type; value " "will be truncated to %1 bit%s1">, InGroup; +def warn_bitfield_too_small_for_enum : Warning< + "bit-field %0 is not wide enough to store all enumerators of %1">, + InGroup, DefaultIgnore; +def note_widen_bitfield : Note< + "widen this field to %0 bits to store all values of %1">; +def warn_unsigned_bitfield_assigned_signed_enum : Warning< + "assigning value of signed enum type %1 to unsigned bit-field %0; " + "negative enumerators of enum %1 will be converted to positive values">, + InGroup, DefaultIgnore; +def warn_signed_bitfield_enum_conversion : Warning< + "signed bit-field %0 needs an extra bit to represent the largest positive " + "enumerators of %1">, + InGroup, DefaultIgnore; +def note_change_bitfield_sign : Note< + "consider making the bitfield type %select{unsigned|signed}0">; def warn_missing_braces : Warning< "suggest braces around initialization of subobject">, Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=297761=297760=297761=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Mar 14
[PATCH] D30923: Warn on enum assignment to bitfields that can't fit all values
rnk marked an inline comment as done. rnk added a comment. Cool, thanks for the reviews, this is definitely in better shape now. This is off by default, so I'm going to commit and experiment with it on a few codebases. I'd still like to hear if either of the Richards have diagnostic wording suggestions, but we can do that in a follow-up. https://reviews.llvm.org/D30923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30923: Warn on enum assignment to bitfields that can't fit all values
hfinkel added a comment. In https://reviews.llvm.org/D30923#700780, @rnk wrote: > In https://reviews.llvm.org/D30923#700708, @hfinkel wrote: > > > In https://reviews.llvm.org/D30923#700696, @rnk wrote: > > > > > Do you think it's worth indicating that the error can be suppressed with > > > an explicit cast, or is that wasted space? > > > > > > What might this look like? Also, I don't see a regression test for this. > > > The warning only looks through implicit casts and paren exprs, so it could > look like this: `f.two_bits = (unsigned)three_bits;` I added a test for it. Great, thanks! Comment at: lib/Sema/SemaChecking.cpp:8765 +TypeSourceInfo *TSI = Bitfield->getTypeSourceInfo(); +SourceRange TypeRange = TSI ? TSI->getTypeLoc().getSourceRange() : SourceRange(); +S.Diag(Bitfield->getTypeSpecStartLoc(), diag::note_change_bitfield_sign) Line is too long. https://reviews.llvm.org/D30923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297759 - Add more debugging code for the SystemZ bot.
Author: ributzka Date: Tue Mar 14 12:46:26 2017 New Revision: 297759 URL: http://llvm.org/viewvc/llvm-project?rev=297759=rev Log: Add more debugging code for the SystemZ bot. Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=297759=297758=297759=diff == --- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original) +++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Tue Mar 14 12:46:26 2017 @@ -363,16 +363,22 @@ TEST(VirtualFileSystemTest, BrokenSymlin for (vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC), E; I != E; I.increment(EC)) { // Skip broken symlinks. -if (EC == std::errc::no_such_file_or_directory) { - EC = std::error_code(); +auto EC2 = std::make_error_code(std::errc::no_such_file_or_directory); +if (EC == EC2) { + EC.clear(); continue; } // For bot debugging. if (EC) { - outs() << "std::errc::no_such_file_or_directory: " - << (int)std::errc::no_such_file_or_directory << "\n"; - outs() << "EC: " << EC.value() << "\n"; - outs() << "EC message: " << EC.message() << "\n"; + outs() << "Error code found:\n" + << "EC value: " << EC.value() << "\n" + << "EC category: " << EC.category().name() + << "EC message: " << EC.message() << "\n"; + + outs() << "Error code tested for:\n" + << "EC value: " << EC2.value() << "\n" + << "EC category: " << EC2.category().name() + << "EC message: " << EC2.message() << "\n"; } ASSERT_FALSE(EC); EXPECT_TRUE(I->getName() == _b); @@ -441,16 +447,22 @@ TEST(VirtualFileSystemTest, BrokenSymlin for (vfs::recursive_directory_iterator I(*FS, Twine(TestDirectory), EC), E; I != E; I.increment(EC)) { // Skip broken symlinks. -if (EC == std::errc::no_such_file_or_directory) { - EC = std::error_code(); +auto EC2 = std::make_error_code(std::errc::no_such_file_or_directory); +if (EC == EC2) { + EC.clear(); continue; } // For bot debugging. if (EC) { - outs() << "std::errc::no_such_file_or_directory: " - << (int)std::errc::no_such_file_or_directory << "\n"; - outs() << "EC: " << EC.value() << "\n"; - outs() << "EC message: " << EC.message() << "\n"; + outs() << "Error code found:\n" + << "EC value: " << EC.value() << "\n" + << "EC category: " << EC.category().name() + << "EC message: " << EC.message() << "\n"; + + outs() << "Error code tested for:\n" + << "EC value: " << EC2.value() << "\n" + << "EC category: " << EC2.category().name() + << "EC message: " << EC2.message() << "\n"; } ASSERT_FALSE(EC); Contents.push_back(I->getName()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r297756 - Fix misspelled enum
Author: jroelofs Date: Tue Mar 14 12:29:33 2017 New Revision: 297756 URL: http://llvm.org/viewvc/llvm-project?rev=297756=rev Log: Fix misspelled enum https://reviews.llvm.org/D30945 Modified: cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/lib/Parse/ParseOpenMP.cpp cfe/trunk/lib/Parse/ParseStmt.cpp Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=297756=297755=297756=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Tue Mar 14 12:29:33 2017 @@ -1686,7 +1686,7 @@ private: StmtResult ParseStatement(SourceLocation *TrailingElseLoc = nullptr, bool AllowOpenMPStandalone = false); - enum AllowedContsructsKind { + enum AllowedConstructsKind { /// \brief Allow any declarations, statements, OpenMP directives. ACK_Any, /// \brief Allow only statements and non-standalone OpenMP directives. @@ -1695,11 +1695,11 @@ private: ACK_StatementsOpenMPAnyExecutable }; StmtResult - ParseStatementOrDeclaration(StmtVector , AllowedContsructsKind Allowed, + ParseStatementOrDeclaration(StmtVector , AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc = nullptr); StmtResult ParseStatementOrDeclarationAfterAttributes( StmtVector , - AllowedContsructsKind Allowed, + AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc, ParsedAttributesWithRange ); StmtResult ParseExprStatement(); @@ -1728,7 +1728,7 @@ private: StmtResult ParseAsmStatement(bool ); StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc); StmtResult ParsePragmaLoopHint(StmtVector , - AllowedContsructsKind Allowed, + AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc, ParsedAttributesWithRange ); @@ -2587,7 +2587,7 @@ private: /// executable directives are allowed. /// StmtResult - ParseOpenMPDeclarativeOrExecutableDirective(AllowedContsructsKind Allowed); + ParseOpenMPDeclarativeOrExecutableDirective(AllowedConstructsKind Allowed); /// \brief Parses clause of kind \a CKind for directive of a kind \a Kind. /// /// \param DKind Kind of current directive. Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=297756=297755=297756=diff == --- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original) +++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Tue Mar 14 12:29:33 2017 @@ -806,7 +806,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpen /// annot_pragma_openmp_end /// StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( -AllowedContsructsKind Allowed) { +AllowedConstructsKind Allowed) { assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!"); ParenBraceBracketBalancer BalancerRAIIObj(*this); SmallVector Clauses; Modified: cfe/trunk/lib/Parse/ParseStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=297756=297755=297756=diff == --- cfe/trunk/lib/Parse/ParseStmt.cpp (original) +++ cfe/trunk/lib/Parse/ParseStmt.cpp Tue Mar 14 12:29:33 2017 @@ -97,7 +97,7 @@ StmtResult Parser::ParseStatement(Source /// StmtResult Parser::ParseStatementOrDeclaration(StmtVector , -AllowedContsructsKind Allowed, +AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc) { ParenBraceBracketBalancer BalancerRAIIObj(*this); @@ -150,7 +150,7 @@ private: StmtResult Parser::ParseStatementOrDeclarationAfterAttributes(StmtVector , - AllowedContsructsKind Allowed, SourceLocation *TrailingElseLoc, + AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc, ParsedAttributesWithRange ) { const char *SemiError = nullptr; StmtResult Res; @@ -1903,7 +1903,7 @@ StmtResult Parser::ParseReturnStatement( } StmtResult Parser::ParsePragmaLoopHint(StmtVector , - AllowedContsructsKind Allowed, + AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc, ParsedAttributesWithRange ) { // Create temporary attribute list. ___ cfe-commits
[PATCH] D30945: Fix mis-spelled enum
jroelofs closed this revision. jroelofs added a comment. r297756 https://reviews.llvm.org/D30945 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r297758 - Mark LWG issues 2868, 2872, and 2890 as complete. There's nothing we need to do for them.
Author: marshall Date: Tue Mar 14 12:35:56 2017 New Revision: 297758 URL: http://llvm.org/viewvc/llvm-project?rev=297758=rev Log: Mark LWG issues 2868, 2872, and 2890 as complete. There's nothing we need to do for them. Modified: libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/www/cxx1z_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=297758=297757=297758=diff == --- libcxx/trunk/www/cxx1z_status.html (original) +++ libcxx/trunk/www/cxx1z_status.html Tue Mar 14 12:35:56 2017 @@ -465,14 +465,14 @@ http://wg21.link/LWG2857;>2857{variant,optional,any}::emplace should return the constructed valueKona http://wg21.link/LWG2861;>2861basic_string should require that charT match traits::char_typeKona http://wg21.link/LWG2866;>2866Incorrect derived classes constraintsKona - http://wg21.link/LWG2868;>2868Missing specification of bad_any_cast::what()Kona - http://wg21.link/LWG2872;>2872Add definition for direct-non-list-initializationKona + http://wg21.link/LWG2868;>2868Missing specification of bad_any_cast::what()KonaComplete + http://wg21.link/LWG2872;>2872Add definition for direct-non-list-initializationKonaComplete http://wg21.link/LWG2873;>2873Add noexcept to several shared_ptr related functionsKona http://wg21.link/LWG2874;>2874Constructor shared_ptr::shared_ptr(Y*) should be constrainedKona http://wg21.link/LWG2875;>2875shared_ptr::shared_ptr(Y*, D, []) constructors should be constrainedKona http://wg21.link/LWG2876;>2876shared_ptr::shared_ptr(const weak_ptrY) constructor should be constrainedKona http://wg21.link/LWG2878;>2878Missing DefaultConstructible requirement for istream_iterator default constructorKona - http://wg21.link/LWG2890;>2890The definition of 'object state' applies only to class typesKona + http://wg21.link/LWG2890;>2890The definition of 'object state' applies only to class typesKonaComplete http://wg21.link/LWG2900;>2900The copy and move constructors of optional are not constexprKona http://wg21.link/LWG2903;>2903The form of initialization for the emplace-constructors is not specifiedKona http://wg21.link/LWG2904;>2904Make variant move-assignment more exception safeKona ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30923: Warn on enum assignment to bitfields that can't fit all values
rnk added a comment. In https://reviews.llvm.org/D30923#700708, @hfinkel wrote: > In https://reviews.llvm.org/D30923#700696, @rnk wrote: > > > Do you think it's worth indicating that the error can be suppressed with an > > explicit cast, or is that wasted space? > > > What might this look like? Also, I don't see a regression test for this. The warning only looks through implicit casts and paren exprs, so it could look like this: `f.two_bits = (unsigned)three_bits;` I added a test for it. https://reviews.llvm.org/D30923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30923: Warn on enum assignment to bitfields that can't fit all values
rnk updated this revision to Diff 91749. rnk added a comment. - Test that explicit casts suppress the warning https://reviews.llvm.org/D30923 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/SemaCXX/warn-bitfield-enum-conversion.cpp Index: test/SemaCXX/warn-bitfield-enum-conversion.cpp === --- /dev/null +++ test/SemaCXX/warn-bitfield-enum-conversion.cpp @@ -0,0 +1,59 @@ +// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -verify %s -Wbitfield-enum-conversion +// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux -verify %s -Wbitfield-enum-conversion + +enum TwoBits { Hi1 = 3 } two_bits; +enum TwoBitsSigned { Lo2 = -2, Hi2 = 1 } two_bits_signed; +enum ThreeBits { Hi3 = 7 } three_bits; +enum ThreeBitsSigned { Lo4 = -4, Hi4 = 3 } three_bits_signed; +enum TwoBitsFixed : unsigned { Hi5 = 3 } two_bits_fixed; + +struct Foo { + unsigned two_bits : 2;// expected-note 2 {{widen this field to 3 bits}} expected-note 2 {{type signed}} + int two_bits_signed : 2; // expected-note 2 {{widen this field to 3 bits}} expected-note 1 {{type unsigned}} + unsigned three_bits : 3; // expected-note 2 {{type signed}} + int three_bits_signed : 3;// expected-note 1 {{type unsigned}} + +#ifdef _WIN32 + // expected-note@+2 {{type unsigned}} +#endif + ThreeBits three_bits_enum : 3; + ThreeBits four_bits_enum : 4; +}; + +void f() { + Foo f; + + f.two_bits = two_bits; + f.two_bits = two_bits_signed;// expected-warning {{negative enumerators}} + f.two_bits = three_bits; // expected-warning {{not wide enough}} + f.two_bits = three_bits_signed; // expected-warning {{negative enumerators}} expected-warning {{not wide enough}} + f.two_bits = two_bits_fixed; + + f.two_bits_signed = two_bits;// expected-warning {{needs an extra bit}} + f.two_bits_signed = two_bits_signed; + f.two_bits_signed = three_bits; // expected-warning {{not wide enough}} + f.two_bits_signed = three_bits_signed; // expected-warning {{not wide enough}} + + f.three_bits = two_bits; + f.three_bits = two_bits_signed; // expected-warning {{negative enumerators}} + f.three_bits = three_bits; + f.three_bits = three_bits_signed;// expected-warning {{negative enumerators}} + + f.three_bits_signed = two_bits; + f.three_bits_signed = two_bits_signed; + f.three_bits_signed = three_bits;// expected-warning {{needs an extra bit}} + f.three_bits_signed = three_bits_signed; + +#ifdef _WIN32 + // Enums on Windows are always implicitly 'int', which is signed, so you need + // an extra bit to store values that set the MSB. This is not true on SysV + // platforms like Linux. + // expected-warning@+2 {{needs an extra bit}} +#endif + f.three_bits_enum = three_bits; + f.four_bits_enum = three_bits; + + // Explicit casts suppress the warning. + f.two_bits = (unsigned)three_bits_signed; + f.two_bits = static_cast(three_bits_signed); +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -8729,13 +8729,65 @@ return false; Expr *OriginalInit = Init->IgnoreParenImpCasts(); + unsigned FieldWidth = Bitfield->getBitWidthValue(S.Context); llvm::APSInt Value; - if (!OriginalInit->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects)) + if (!OriginalInit->EvaluateAsInt(Value, S.Context, + Expr::SE_AllowSideEffects)) { +// The RHS is not constant. If the RHS has an enum type, make sure the +// bitfield is wide enough to hold all the values of the enum without +// truncation. +if (const auto *EnumTy = OriginalInit->getType()->getAs()) { + EnumDecl *ED = EnumTy->getDecl(); + bool SignedBitfield = BitfieldType->isSignedIntegerType(); + + // Enum types are implicitly signed on Windows, so check if there are any + // negative enumerators to see if the enum was intended to be signed or + // not. + bool SignedEnum = ED->getNumNegativeBits() > 0; + + // Check for surprising sign changes when assigning enum values to a + // bitfield of different signedness. If the bitfield is signed and we + // have exactly the right number of bits to store this unsigned enum, + // suggest changing the enum to an unsigned type. This typically happens + // on Windows where unfixed enums always use an underlying type of 'int'. + unsigned DiagID = 0; + if (SignedEnum && !SignedBitfield) { +DiagID = diag::warn_unsigned_bitfield_assigned_signed_enum; + } else if (SignedBitfield && !SignedEnum && + ED->getNumPositiveBits() == FieldWidth) { +DiagID = diag::warn_signed_bitfield_enum_conversion; + } + + if (DiagID) { +S.Diag(InitLoc, DiagID) <<
r297754 - [Driver] Fix arch-specific-libdir-rpath.c
Author: pirama Date: Tue Mar 14 12:26:56 2017 New Revision: 297754 URL: http://llvm.org/viewvc/llvm-project?rev=297754=rev Log: [Driver] Fix arch-specific-libdir-rpath.c Summary: Fix the test by adding missing -target flags with a 'linux' triple. Reviewers: rnk, srhines Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30947 Modified: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c Modified: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arch-specific-libdir-rpath.c?rev=297754=297753=297754=diff == --- cfe/trunk/test/Driver/arch-specific-libdir-rpath.c (original) +++ cfe/trunk/test/Driver/arch-specific-libdir-rpath.c Tue Mar 14 12:26:56 2017 @@ -59,19 +59,19 @@ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s // // Add LIBPATH but no RPATH for ubsan (or any other sanitizer) -// RUN: %clang %s -### 2>&1 -fsanitize=undefined \ +// RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Add LIBPATH but no RPATH if no sanitizer or runtime is specified -// RUN: %clang %s -### 2>&1 \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist -// RUN: %clang %s -### 2>&1 \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30947: [Driver] Fix arch-specific-libdir-rpath.c
This revision was automatically updated to reflect the committed changes. Closed by commit rL297754: [Driver] Fix arch-specific-libdir-rpath.c (authored by pirama). Changed prior to commit: https://reviews.llvm.org/D30947?vs=91746=91747#toc Repository: rL LLVM https://reviews.llvm.org/D30947 Files: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c Index: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c === --- cfe/trunk/test/Driver/arch-specific-libdir-rpath.c +++ cfe/trunk/test/Driver/arch-specific-libdir-rpath.c @@ -59,19 +59,19 @@ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s // // Add LIBPATH but no RPATH for ubsan (or any other sanitizer) -// RUN: %clang %s -### 2>&1 -fsanitize=undefined \ +// RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Add LIBPATH but no RPATH if no sanitizer or runtime is specified -// RUN: %clang %s -### 2>&1 \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist -// RUN: %clang %s -### 2>&1 \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s Index: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c === --- cfe/trunk/test/Driver/arch-specific-libdir-rpath.c +++ cfe/trunk/test/Driver/arch-specific-libdir-rpath.c @@ -59,19 +59,19 @@ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s // // Add LIBPATH but no RPATH for ubsan (or any other sanitizer) -// RUN: %clang %s -### 2>&1 -fsanitize=undefined \ +// RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Add LIBPATH but no RPATH if no sanitizer or runtime is specified -// RUN: %clang %s -### 2>&1 \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist -// RUN: %clang %s -### 2>&1 \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30947: [Driver] Fix arch-specific-libdir-rpath.c
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm https://reviews.llvm.org/D30947 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30947: [Driver] Fix arch-specific-libdir-rpath.c
pirama created this revision. Fix the test by adding missing -target flags with a 'linux' triple. https://reviews.llvm.org/D30947 Files: test/Driver/arch-specific-libdir-rpath.c Index: test/Driver/arch-specific-libdir-rpath.c === --- test/Driver/arch-specific-libdir-rpath.c +++ test/Driver/arch-specific-libdir-rpath.c @@ -59,19 +59,19 @@ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s // // Add LIBPATH but no RPATH for ubsan (or any other sanitizer) -// RUN: %clang %s -### 2>&1 -fsanitize=undefined \ +// RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Add LIBPATH but no RPATH if no sanitizer or runtime is specified -// RUN: %clang %s -### 2>&1 \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist -// RUN: %clang %s -### 2>&1 \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s Index: test/Driver/arch-specific-libdir-rpath.c === --- test/Driver/arch-specific-libdir-rpath.c +++ test/Driver/arch-specific-libdir-rpath.c @@ -59,19 +59,19 @@ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s // // Add LIBPATH but no RPATH for ubsan (or any other sanitizer) -// RUN: %clang %s -### 2>&1 -fsanitize=undefined \ +// RUN: %clang %s -### 2>&1 -fsanitize=undefined -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Add LIBPATH but no RPATH if no sanitizer or runtime is specified -// RUN: %clang %s -### 2>&1 \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Do not add LIBPATH or RPATH if arch-specific subdir doesn't exist -// RUN: %clang %s -### 2>&1 \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: -frtlib-add-rpath \ // RUN: | FileCheck --check-prefixes=RESDIR,NO-LIBPATH,NO-RPATH %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r297753 - Also mark LWG#2785 as complete, because we already implemented that
Author: marshall Date: Tue Mar 14 12:24:29 2017 New Revision: 297753 URL: http://llvm.org/viewvc/llvm-project?rev=297753=rev Log: Also mark LWG#2785 as complete, because we already implemented that Modified: libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/www/cxx1z_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=297753=297752=297753=diff == --- libcxx/trunk/www/cxx1z_status.html (original) +++ libcxx/trunk/www/cxx1z_status.html Tue Mar 14 12:24:29 2017 @@ -437,7 +437,7 @@ http://wg21.link/LWG2781;>2781Contradictory requirements for std::function and std::reference_wrapperKonaComplete http://wg21.link/LWG2782;>2782scoped_allocator_adaptor constructors must be constrainedKona http://wg21.link/LWG2784;>2784Resolution to LWG 2484 is missing "otherwise, no effects" and is hard to parseKonaComplete - http://wg21.link/LWG2785;>2785quoted should work with basic_string_viewKona + http://wg21.link/LWG2785;>2785quoted should work with basic_string_viewKonaComplete http://wg21.link/LWG2786;>2786Annex C should mention shared_ptr changes for array supportKonaComplete http://wg21.link/LWG2787;>2787[file_status.cons] doesn't match class definitionKonaComplete http://wg21.link/LWG2788;>2788basic_string range mutators unintentionally require a default constructible allocatorKona ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30854: [ASTMatchers] Add ObjC matchers for fundamental decls
aaron.ballman added inline comments. Comment at: unittests/ASTMatchers/ASTMatchersNodeTest.cpp:1547 + std::string ObjCString = +"#pragma clang diagnostic ignored \"-Wobjc-root-class\"\n" +"@protocol Proto " kastiglione wrote: > aaron.ballman wrote: > > kastiglione wrote: > > > kastiglione wrote: > > > > aaron.ballman wrote: > > > > > Instead of using a pragma for this, I think it would make more sense > > > > > to just modify `matchesObjC()` to disable the diagnostic. This is > > > > > only intended to test the dynamic AST matchers, so the diagnostics > > > > > are not useful in that case anyway. > > > > `matchesConditionally()` accepts only one compiler arg, so putting the > > > > diagnostics here was a smaller change than refactoring that function. > > > > Do you think it would be better to refactor `matchesConditionally()`? > > > I notice that many other tests have warnings. Should these tests just > > > allow the warnings to be emitted? > > We generally let the warnings go -- it's not harmful to have them. However, > > if this is a warning that's likely to trigger on most tests, there's no > > harm in suppressing it either. > Sounds good, I'm for suppressing them. Should I refactor > `matchesConditionally()` to allow multiple compile args, and disable these > warnings from `matchesObjC()`? Yes, I think that's the way to go. Comment at: unittests/ASTMatchers/ASTMatchersTest.h:123 Code, AMatcher, true, -"", FileContentMappings(), "input.m"); +"-fobjc-runtime=macosx", FileContentMappings(), "input.m"); } kastiglione wrote: > aaron.ballman wrote: > > kastiglione wrote: > > > aaron.ballman wrote: > > > > Can you explain why this change is required? > > > `Code` was not being evaluated as Objective-C 2, which resulted in > > > warnings and errors for the test this diff introduces. Setting the > > > runtime was the first approach I tried, and it worked so I went with it > > > without looking into why it was necessary. Now that you've asked, I > > > stepped through and found that the `i386-unknown-unknown` triple is > > > resulting in the use of an ELF toolchain and GCC objc runtime. > > > > > > It can be changed to `-fobjc-nonfragile-abi`, which seems better than a > > > specific runtime, do you agree? Is there any reason to not have > > > Objective-C 2 be the default? > > I think -fobjc-nonfragile-abi may be fine, but I guess I'm surprised that > > ObjC1 didn't require any specific runtime and ObjC2 requires one or else > > you get errors (warnings are fine, however -- we have plenty of those in > > these tests). > > > > Perhaps it's time to fix the FIXME in `matchesConditionally()` so that we > > don't need to specify the triple at all, and then you won't need to specify > > the runtime? I don't think that should hold up this patch, however. > > I'm surprised that ObjC1 didn't require any specific runtime and ObjC2 > > requires one or else you get errors > > I think this is because the existing ObjC in this test was small in size and > coverage of syntax/features. Given the variable name `Objc1String`, it was > probably written to avoid ObjC2 specific abi/features. Fair enough https://reviews.llvm.org/D30854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin
mehdi_amini added a comment. In https://reviews.llvm.org/D30920#700574, @hfinkel wrote: > In https://reviews.llvm.org/D30920#700557, @mehdi_amini wrote: > > > In https://reviews.llvm.org/D30920#700433, @tejohnson wrote: > > > > > In https://reviews.llvm.org/D30920#700133, @pcc wrote: > > > > > > > In https://reviews.llvm.org/D30920#700077, @tejohnson wrote: > > > > > > > > > Until everything is converted to using size attributes, it seems like > > > > > a correct fix for the bug is to accept these options in the > > > > > gold-plugin and pass through the LTO API to the PassManagerBuilder. > > > > > > > > > > > > Not necessarily. There is no requirement (from a correctness > > > > perspective) that `-Os` at link time should exactly match the behaviour > > > > of `-Os` at compile time. > > > > > > > > > Sure, but there is certainly a perception that optimization flags > > > affecting the non-LTO pipeline should similarly affect the LTO pipeline. > > > LTO should be transparent to the user, so if -Os behaves one way without > > > LTO, it seems problematic to me if it behaves a different way with LTO. > > > > > > That being said, agree that the best way to enforce that is to pass the > > > relevant flags through the IR. (On the flip side, if the user passes -O1 > > > to the link step, it does get passed through to the plugin and affects > > > the LTO optimization pipeline...) > > > > > > I agree that I don't like the discrepancy: the driver should *not* drop -Os > > silently if it passes down -O1/-O2/-O3, a warning is the minimum. > > > I don't like the discrepancy either, and I agree that we should be passing > these other flags through the IR as well (even though, in the face of > inlining, there is some ambiguity as to what the flags would mean). That > having been said, I don't see the value in the warning. Forcing users to > endure a warning solely because they use LTO and use -Os or -Oz for all of > their compilation steps, is not friendly. The warning here is only about the *link* step. > The information has been captured already so there's nothing to warn about. > You might worry about the opposite situation (the user uses only -Os or -Oz > on the link step, but not for the compile steps), and that will have no > effect. That, however, should be the expected behavior (optimization is > associated with compiling, not linking, except perhaps for specifically > called-out exceptions). The fact that our other optimization level don't work > that way is a bug, not a feature, that we should fix instead of further > exposing to our users. Yes, the issue is only about how the driver accepts Os for the link even though it has no effect (O0/https://reviews.llvm.org/owners/package/1//https://reviews.llvm.org/owners/package/2//https://reviews.llvm.org/owners/package/3/ *will* have an effect though). https://reviews.llvm.org/D30920 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r297752 - Implement LWG2784, and mark 2786, 2795, 2804, 2812, 2826, 2834, 2837 and 2838 as complete - since we do them already
Author: marshall Date: Tue Mar 14 12:08:47 2017 New Revision: 297752 URL: http://llvm.org/viewvc/llvm-project?rev=297752=rev Log: Implement LWG2784, and mark 2786, 2795, 2804, 2812, 2826, 2834, 2837 and 2838 as complete - since we do them already Modified: libcxx/trunk/include/exception libcxx/trunk/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/include/exception URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=297752=297751=297752=diff == --- libcxx/trunk/include/exception (original) +++ libcxx/trunk/include/exception Tue Mar 14 12:08:47 2017 @@ -248,12 +248,17 @@ throw_with_nested (_Tp& __t, typename en #endif } +template +struct __can_dynamic_cast : public _LIBCPP_BOOL_CONSTANT( + is_polymorphic<_From>::value && + (!is_base_of<_To, _From>::value || + is_convertible::value)) {}; + template inline _LIBCPP_INLINE_VISIBILITY void -rethrow_if_nested(const _Ep& __e, typename enable_if< - is_polymorphic<_Ep>::value - >::type* = 0) +rethrow_if_nested(const _Ep& __e, + typename enable_if< __can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0) { const nested_exception* __nep = dynamic_cast(_VSTD::addressof(__e)); if (__nep) @@ -263,9 +268,8 @@ rethrow_if_nested(const _Ep& __e, typena template inline _LIBCPP_INLINE_VISIBILITY void -rethrow_if_nested(const _Ep&, typename enable_if< - !is_polymorphic<_Ep>::value - >::type* = 0) +rethrow_if_nested(const _Ep&, + typename enable_if::value>::type* = 0) { } Modified: libcxx/trunk/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp?rev=297752=297751=297752=diff == --- libcxx/trunk/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp (original) +++ libcxx/trunk/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp Tue Mar 14 12:08:47 2017 @@ -46,16 +46,47 @@ public: C * operator&() const { assert(false); } // should not be called }; +class D : private std::nested_exception {}; + + +class E1 : public std::nested_exception {}; +class E2 : public std::nested_exception {}; +class E : public E1, public E2 {}; + int main() { { try { -A a(3); +A a(3); // not a polymorphic type --> no effect std::rethrow_if_nested(a); assert(true); } catch (...) +{ +assert(false); +} +} +{ +try +{ +D s; // inaccessible base class --> no effect +std::rethrow_if_nested(s); +assert(true); +} +catch (...) +{ +assert(false); +} +} +{ +try +{ +E s; // ambiguous base class --> no effect +std::rethrow_if_nested(s); +assert(true); +} +catch (...) { assert(false); } Modified: libcxx/trunk/www/cxx1z_status.html URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=297752=297751=297752=diff == --- libcxx/trunk/www/cxx1z_status.html (original) +++ libcxx/trunk/www/cxx1z_status.html Tue Mar 14 12:08:47 2017 @@ -436,28 +436,28 @@ http://wg21.link/LWG2769;>2769Redundant const in the return type of any_cast(const any)KonaComplete http://wg21.link/LWG2781;>2781Contradictory requirements for std::function and std::reference_wrapperKonaComplete http://wg21.link/LWG2782;>2782scoped_allocator_adaptor constructors must be constrainedKona - http://wg21.link/LWG2784;>2784Resolution to LWG 2484 is missing "otherwise, no effects" and is hard to parseKona + http://wg21.link/LWG2784;>2784Resolution to LWG 2484 is missing "otherwise, no effects" and is hard to parseKonaComplete http://wg21.link/LWG2785;>2785quoted should work with basic_string_viewKona - http://wg21.link/LWG2786;>2786Annex C should mention shared_ptr changes for array supportKona + http://wg21.link/LWG2786;>2786Annex C should mention shared_ptr changes for array supportKonaComplete http://wg21.link/LWG2787;>2787[file_status.cons] doesn't match class definitionKonaComplete http://wg21.link/LWG2788;>2788basic_string range mutators
[PATCH] D30582: [Driver] Restructure handling of -ffast-math and similar options
john.brawn updated this revision to Diff 91745. john.brawn added a comment. Respond to review comments, and also fix a couple of 80-column violations that I spotted. Repository: rL LLVM https://reviews.llvm.org/D30582 Files: lib/Driver/ToolChains/Clang.cpp test/Driver/fast-math.c Index: test/Driver/fast-math.c === --- test/Driver/fast-math.c +++ test/Driver/fast-math.c @@ -148,20 +148,31 @@ // // One umbrella flag is *really* weird and also changes the semantics of the // program by adding a special preprocessor macro. Check that the frontend flag -// modeling this semantic change is provided. Also check that the semantic -// impact remains even if every optimization is disabled. +// modeling this semantic change is provided. Also check that the flag is not +// present if any of the optimization is disabled. // RUN: %clang -### -ffast-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s // RUN: %clang -### -fno-fast-math -ffast-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s -// RUN: %clang -### -ffast-math -fno-finite-math-only \ -// RUN: -fno-unsafe-math-optimizations -fmath-errno -c %s 2>&1 \ +// RUN: %clang -### -funsafe-math-optimizations -ffinite-math-only \ +// RUN: -fno-math-errno -ffp-contract=fast -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s +// RUN: %clang -### -fhonor-infinities -fhonor-nans -fno-math-errno \ +// RUN: -fassociative-math -freciprocal-math -fno-signed-zeros \ +// RUN: -fno-trapping-math -ffp-contract=fast -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s // CHECK-FAST-MATH: "-cc1" // CHECK-FAST-MATH: "-ffast-math" +// CHECK-FAST-MATH: "-ffinite-math-only" // // RUN: %clang -### -ffast-math -fno-fast-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -fno-unsafe-math-optimizations -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s +// RUN: %clang -### -ffast-math -fmath-errno -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-FAST-MATH %s // CHECK-NO-FAST-MATH: "-cc1" // CHECK-NO-FAST-MATH-NOT: "-ffast-math" // @@ -179,6 +190,7 @@ // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s // CHECK-NO-NO-INFS: "-cc1" // CHECK-NO-NO-INFS-NOT: "-menable-no-infs" +// CHECK-NO-NO-INFS-NOT: "-ffinite-math-only" // CHECK-NO-NO-INFS: "-o" // // RUN: %clang -### -fno-honor-nans -fhonor-nans -c %s 2>&1 \ @@ -193,6 +205,7 @@ // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s // CHECK-NO-NO-NANS: "-cc1" // CHECK-NO-NO-NANS-NOT: "-menable-no-nans" +// CHECK-NO-NO-NANS-NOT: "-ffinite-math-only" // CHECK-NO-NO-NANS: "-o" // // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ Index: lib/Driver/ToolChains/Clang.cpp === --- lib/Driver/ToolChains/Clang.cpp +++ lib/Driver/ToolChains/Clang.cpp @@ -2301,98 +2301,128 @@ if (Args.hasArg(options::OPT_fsplit_stack)) CmdArgs.push_back("-split-stacks"); - // If -Ofast is the optimization level, then -ffast-math should be enabled. - // This alias option is being used to simplify the getLastArg logic. - OptSpecifier FastMathAliasOption = - OFastEnabled ? options::OPT_Ofast : options::OPT_ffast_math; - // Handle various floating point optimization flags, mapping them to the - // appropriate LLVM code generation flags. The pattern for all of these is to - // default off the codegen optimizations, and if any flag enables them and no - // flag disables them after the flag enabling them, enable the codegen - // optimization. This is complicated by several "umbrella" flags. - if (Arg *A = Args.getLastArg( - options::OPT_ffast_math, FastMathAliasOption, - options::OPT_fno_fast_math, options::OPT_ffinite_math_only, - options::OPT_fno_finite_math_only, options::OPT_fhonor_infinities, - options::OPT_fno_honor_infinities)) -if (A->getOption().getID() != options::OPT_fno_fast_math && -A->getOption().getID() != options::OPT_fno_finite_math_only && -A->getOption().getID() != options::OPT_fhonor_infinities) - CmdArgs.push_back("-menable-no-infs"); - if (Arg *A = Args.getLastArg( - options::OPT_ffast_math, FastMathAliasOption, - options::OPT_fno_fast_math, options::OPT_ffinite_math_only, - options::OPT_fno_finite_math_only, options::OPT_fhonor_nans, - options::OPT_fno_honor_nans)) -if (A->getOption().getID() != options::OPT_fno_fast_math && -A->getOption().getID() != options::OPT_fno_finite_math_only && -A->getOption().getID() != options::OPT_fhonor_nans) - CmdArgs.push_back("-menable-no-nans"); - + // appropriate
[PATCH] D30854: [ASTMatchers] Add ObjC matchers for fundamental decls
kastiglione added inline comments. Comment at: unittests/ASTMatchers/ASTMatchersNodeTest.cpp:1547 + std::string ObjCString = +"#pragma clang diagnostic ignored \"-Wobjc-root-class\"\n" +"@protocol Proto " aaron.ballman wrote: > kastiglione wrote: > > kastiglione wrote: > > > aaron.ballman wrote: > > > > Instead of using a pragma for this, I think it would make more sense to > > > > just modify `matchesObjC()` to disable the diagnostic. This is only > > > > intended to test the dynamic AST matchers, so the diagnostics are not > > > > useful in that case anyway. > > > `matchesConditionally()` accepts only one compiler arg, so putting the > > > diagnostics here was a smaller change than refactoring that function. Do > > > you think it would be better to refactor `matchesConditionally()`? > > I notice that many other tests have warnings. Should these tests just allow > > the warnings to be emitted? > We generally let the warnings go -- it's not harmful to have them. However, > if this is a warning that's likely to trigger on most tests, there's no harm > in suppressing it either. Sounds good, I'm for suppressing them. Should I refactor `matchesConditionally()` to allow multiple compile args, and disable these warnings from `matchesObjC()`? Comment at: unittests/ASTMatchers/ASTMatchersTest.h:123 Code, AMatcher, true, -"", FileContentMappings(), "input.m"); +"-fobjc-runtime=macosx", FileContentMappings(), "input.m"); } aaron.ballman wrote: > kastiglione wrote: > > aaron.ballman wrote: > > > Can you explain why this change is required? > > `Code` was not being evaluated as Objective-C 2, which resulted in warnings > > and errors for the test this diff introduces. Setting the runtime was the > > first approach I tried, and it worked so I went with it without looking > > into why it was necessary. Now that you've asked, I stepped through and > > found that the `i386-unknown-unknown` triple is resulting in the use of an > > ELF toolchain and GCC objc runtime. > > > > It can be changed to `-fobjc-nonfragile-abi`, which seems better than a > > specific runtime, do you agree? Is there any reason to not have Objective-C > > 2 be the default? > I think -fobjc-nonfragile-abi may be fine, but I guess I'm surprised that > ObjC1 didn't require any specific runtime and ObjC2 requires one or else you > get errors (warnings are fine, however -- we have plenty of those in these > tests). > > Perhaps it's time to fix the FIXME in `matchesConditionally()` so that we > don't need to specify the triple at all, and then you won't need to specify > the runtime? I don't think that should hold up this patch, however. > I'm surprised that ObjC1 didn't require any specific runtime and ObjC2 > requires one or else you get errors I think this is because the existing ObjC in this test was small in size and coverage of syntax/features. Given the variable name `Objc1String`, it was probably written to avoid ObjC2 specific abi/features. https://reviews.llvm.org/D30854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30700: [Driver] Add flag to request arch-specific-subdir in -rpath
This revision was automatically updated to reflect the committed changes. Closed by commit rL297751: [Driver] Add flag to request arch-specific-subdir in -rpath (authored by pirama). Changed prior to commit: https://reviews.llvm.org/D30700?vs=91743=91744#toc Repository: rL LLVM https://reviews.llvm.org/D30700 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp cfe/trunk/test/Driver/arch-specific-libdir-rpath.c cfe/trunk/test/Driver/arch-specific-libdir.c cfe/trunk/test/lit.cfg Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2098,6 +2098,10 @@ def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group; def rtlib_EQ : Joined<["-", "--"], "rtlib=">, HelpText<"Compiler runtime library to use">; +def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, Flags<[NoArgumentUnused]>, + HelpText<"Add -rpath with architecture-specific resource directory to the linker flags">; +def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, Flags<[NoArgumentUnused]>, + HelpText<"Do not add -rpath with architecture-specific resource directory to the linker flags">; def r : Flag<["-"], "r">, Flags<[LinkerInput,NoArgumentUnused]>, Group; def save_temps_EQ : Joined<["-", "--"], "save-temps=">, Flags<[DriverOption]>, Index: cfe/trunk/test/Driver/arch-specific-libdir.c === --- cfe/trunk/test/Driver/arch-specific-libdir.c +++ cfe/trunk/test/Driver/arch-specific-libdir.c @@ -1,8 +1,6 @@ // Test that the driver adds an arch-specific subdirectory in // {RESOURCE_DIR}/lib/linux to the search path. // -// REQUIRES: linux -// // RUN: %clang %s -### 2>&1 -target i386-unknown-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s Index: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c === --- cfe/trunk/test/Driver/arch-specific-libdir-rpath.c +++ cfe/trunk/test/Driver/arch-specific-libdir-rpath.c @@ -1,50 +1,85 @@ // Test that the driver adds an arch-specific subdirectory in -// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native -// compilations. +// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' // -// -rpath only gets added during native compilation. To keep the test simple, -// just test for x86_64-linux native compilation. -// REQUIRES: x86_64-linux +// Test the default behavior when neither -frtlib-add-rpath nor +// -fno-rtlib-add-rpath is specified, which is to skip -rpath +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ +// RUN: -fsanitize=address -shared-libasan \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s +// +// Test that -rpath is not added under -fno-rtlib-add-rpath even if other +// conditions are met. +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ +// RUN: -fsanitize=address -shared-libasan \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s +// +// Test that -rpath is added only under the right circumstance even if +// -frtlib-add-rpath is specified. // // Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan -// RUN: %clang %s -### 2>&1 -fsanitize=undefined \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s +// +// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan +// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ -// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Add LIBPATH, RPATH for -fsanitize=address -shared-libasan // RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -fsanitize=address -shared-libasan \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ -// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s +// +// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan on aarch64 +// RUN: %clang %s -### 2>&1 -target aarch64-linux \ +// RUN: -fsanitize=address -shared-libasan \ +// RUN:
r297751 - [Driver] Add flag to request arch-specific-subdir in -rpath
Author: pirama Date: Tue Mar 14 11:58:07 2017 New Revision: 297751 URL: http://llvm.org/viewvc/llvm-project?rev=297751=rev Log: [Driver] Add flag to request arch-specific-subdir in -rpath Summary: This patch adds -f[no-]rtlib-add-rpath, which if enabled, embeds the arch-specific subdirectory in resource directory using -rpath (instead of doing so only during native compilation). This patch also re-enables test arch-specific-libdir.c which was silently unsupported because of the REQUIRES tag 'linux'. Reviewers: bkramer, rnk, mgorny Subscribers: srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D30700 Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp cfe/trunk/test/Driver/arch-specific-libdir-rpath.c cfe/trunk/test/Driver/arch-specific-libdir.c cfe/trunk/test/lit.cfg Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=297751=297750=297751=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 14 11:58:07 2017 @@ -2098,6 +2098,10 @@ def resource_dir_EQ : Joined<["-"], "res def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group; def rtlib_EQ : Joined<["-", "--"], "rtlib=">, HelpText<"Compiler runtime library to use">; +def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, Flags<[NoArgumentUnused]>, + HelpText<"Add -rpath with architecture-specific resource directory to the linker flags">; +def fno_rtlib_add_rpath: Flag<["-"], "fno-rtlib-add-rpath">, Flags<[NoArgumentUnused]>, + HelpText<"Do not add -rpath with architecture-specific resource directory to the linker flags">; def r : Flag<["-"], "r">, Flags<[LinkerInput,NoArgumentUnused]>, Group; def save_temps_EQ : Joined<["-", "--"], "save-temps=">, Flags<[DriverOption]>, Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=297751=297750=297751=diff == --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Tue Mar 14 11:58:07 2017 @@ -419,10 +419,6 @@ void tools::AddGoldPlugin(const ToolChai void tools::addArchSpecificRPath(const ToolChain , const ArgList , ArgStringList ) { - // In the cross-compilation case, arch-specific library path is likely - // unavailable at runtime. - if (TC.isCrossCompiling()) return; - std::string CandidateRPath = TC.getArchSpecificLibPath(); if (TC.getVFS().exists(CandidateRPath)) { CmdArgs.push_back("-rpath"); Modified: cfe/trunk/test/Driver/arch-specific-libdir-rpath.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arch-specific-libdir-rpath.c?rev=297751=297750=297751=diff == --- cfe/trunk/test/Driver/arch-specific-libdir-rpath.c (original) +++ cfe/trunk/test/Driver/arch-specific-libdir-rpath.c Tue Mar 14 11:58:07 2017 @@ -1,50 +1,85 @@ // Test that the driver adds an arch-specific subdirectory in -// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native -// compilations. +// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' // -// -rpath only gets added during native compilation. To keep the test simple, -// just test for x86_64-linux native compilation. -// REQUIRES: x86_64-linux +// Test the default behavior when neither -frtlib-add-rpath nor +// -fno-rtlib-add-rpath is specified, which is to skip -rpath +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ +// RUN: -fsanitize=address -shared-libasan \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s +// +// Test that -rpath is not added under -fno-rtlib-add-rpath even if other +// conditions are met. +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ +// RUN: -fsanitize=address -shared-libasan \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s +// +// Test that -rpath is added only under the right circumstance even if +// -frtlib-add-rpath is specified. // // Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan -// RUN: %clang %s -### 2>&1 -fsanitize=undefined \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s +// +// Add
[PATCH] D30700: [Driver] Always add arch-specific-subdir to -rpath
pirama updated this revision to Diff 91743. pirama added a comment. Update commit message https://reviews.llvm.org/D30700 Files: include/clang/Driver/Options.td lib/Driver/ToolChains/CommonArgs.cpp test/Driver/arch-specific-libdir-rpath.c test/Driver/arch-specific-libdir.c test/lit.cfg Index: test/lit.cfg === --- test/lit.cfg +++ test/lit.cfg @@ -397,10 +397,6 @@ if config.host_triple == config.target_triple: config.available_features.add("native") -# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux -if re.match(r'^x86_64.*-linux', config.target_triple): -config.available_features.add("x86_64-linux") - # Case-insensitive file system def is_filesystem_case_insensitive(): handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root) Index: test/Driver/arch-specific-libdir.c === --- test/Driver/arch-specific-libdir.c +++ test/Driver/arch-specific-libdir.c @@ -1,8 +1,6 @@ // Test that the driver adds an arch-specific subdirectory in // {RESOURCE_DIR}/lib/linux to the search path. // -// REQUIRES: linux -// // RUN: %clang %s -### 2>&1 -target i386-unknown-linux \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s Index: test/Driver/arch-specific-libdir-rpath.c === --- test/Driver/arch-specific-libdir-rpath.c +++ test/Driver/arch-specific-libdir-rpath.c @@ -1,50 +1,85 @@ // Test that the driver adds an arch-specific subdirectory in -// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native -// compilations. +// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' // -// -rpath only gets added during native compilation. To keep the test simple, -// just test for x86_64-linux native compilation. -// REQUIRES: x86_64-linux +// Test the default behavior when neither -frtlib-add-rpath nor +// -fno-rtlib-add-rpath is specified, which is to skip -rpath +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ +// RUN: -fsanitize=address -shared-libasan \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s +// +// Test that -rpath is not added under -fno-rtlib-add-rpath even if other +// conditions are met. +// RUN: %clang %s -### 2>&1 -target x86_64-linux \ +// RUN: -fsanitize=address -shared-libasan \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH-X86_64 %s +// +// Test that -rpath is added only under the right circumstance even if +// -frtlib-add-rpath is specified. // // Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan -// RUN: %clang %s -### 2>&1 -fsanitize=undefined \ +// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s +// +// Add LIBPATH but no RPATH for -fsanitizer=address w/o -shared-libasan +// RUN: %clang %s -### 2>&1 -target x86_64-linux -fsanitize=undefined \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ -// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,NO-RPATH %s +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,NO-RPATH %s // // Add LIBPATH, RPATH for -fsanitize=address -shared-libasan // RUN: %clang %s -### 2>&1 -target x86_64-linux \ // RUN: -fsanitize=address -shared-libasan \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ -// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s +// +// Add LIBPATH, RPATH for -fsanitize=address -shared-libasan on aarch64 +// RUN: %clang %s -### 2>&1 -target aarch64-linux \ +// RUN: -fsanitize=address -shared-libasan \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-AArch64,RPATH-AArch64 %s // // Add LIBPATH, RPATH with -fsanitize=address for Android // RUN: %clang %s -### 2>&1 -target x86_64-linux-android -fsanitize=address \ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ -// RUN: | FileCheck --check-prefixes=FILEPATH,LIBPATH,RPATH %s +// RUN: -frtlib-add-rpath \ +// RUN: | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s // // Add LIBPATH, RPATH for OpenMP -// RUN: %clang %s -### 2>&1 -fopenmp \ +// RUN: %clang %s -### 2>&1 -target
r297750 - [ubsan] Use the nicer nullability diagnostic handlers
Author: vedantk Date: Tue Mar 14 11:48:29 2017 New Revision: 297750 URL: http://llvm.org/viewvc/llvm-project?rev=297750=rev Log: [ubsan] Use the nicer nullability diagnostic handlers This is a follow-up to r297700 (Add a nullability sanitizer). It addresses some FIXME's re: using nullability-specific diagnostic handlers from compiler-rt, now that the necessary handlers exist. check-ubsan test updates to follow. Modified: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/test/CodeGenObjC/ubsan-nullability.m Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=297750=297749=297750=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Mar 14 11:48:29 2017 @@ -2938,18 +2938,20 @@ void CodeGenFunction::EmitReturnValueChe // Prefer the returns_nonnull attribute if it's present. SourceLocation AttrLoc; SanitizerMask CheckKind; + SanitizerHandler Handler; if (RetNNAttr) { assert(!requiresReturnValueNullabilityCheck() && "Cannot check nullability and the nonnull attribute"); AttrLoc = RetNNAttr->getLocation(); CheckKind = SanitizerKind::ReturnsNonnullAttribute; +Handler = SanitizerHandler::NonnullReturn; } else { -// FIXME: The runtime shouldn't refer to the 'returns_nonnull' attribute. if (auto *DD = dyn_cast(CurCodeDecl)) if (auto *TSI = DD->getTypeSourceInfo()) if (auto FTL = TSI->getTypeLoc().castAs()) AttrLoc = FTL.getReturnLoc().findNullabilityLoc(); CheckKind = SanitizerKind::NullabilityReturn; +Handler = SanitizerHandler::NullabilityReturn; } SanitizerScope SanScope(this); @@ -2971,8 +2973,7 @@ void CodeGenFunction::EmitReturnValueChe llvm::Constant *StaticData[] = { EmitCheckSourceLocation(EndLoc), EmitCheckSourceLocation(AttrLoc), }; - EmitCheck(std::make_pair(Cond, CheckKind), SanitizerHandler::NonnullReturn, -StaticData, None); + EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, None); if (requiresReturnValueNullabilityCheck()) EmitBlock(NoCheck); @@ -3314,12 +3315,15 @@ void CodeGenFunction::EmitNonNullArgChec SourceLocation AttrLoc; SanitizerMask CheckKind; + SanitizerHandler Handler; if (NNAttr) { AttrLoc = NNAttr->getLocation(); CheckKind = SanitizerKind::NonnullAttribute; +Handler = SanitizerHandler::NonnullArg; } else { AttrLoc = PVD->getTypeSourceInfo()->getTypeLoc().findNullabilityLoc(); CheckKind = SanitizerKind::NullabilityArg; +Handler = SanitizerHandler::NullabilityArg; } SanitizerScope SanScope(this); @@ -3331,8 +3335,7 @@ void CodeGenFunction::EmitNonNullArgChec EmitCheckSourceLocation(ArgLoc), EmitCheckSourceLocation(AttrLoc), llvm::ConstantInt::get(Int32Ty, ArgNo + 1), }; - EmitCheck(std::make_pair(Cond, CheckKind), SanitizerHandler::NonnullArg, -StaticData, None); + EmitCheck(std::make_pair(Cond, CheckKind), Handler, StaticData, None); } void CodeGenFunction::EmitCallArgs( Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=297750=297749=297750=diff == --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Mar 14 11:48:29 2017 @@ -685,11 +685,10 @@ void CodeGenFunction::EmitNullabilityChe // hand side must be nonnull. SanitizerScope SanScope(this); llvm::Value *IsNotNull = Builder.CreateIsNotNull(RHS); - // FIXME: The runtime shouldn't refer to a 'reference'. llvm::Constant *StaticData[] = { EmitCheckSourceLocation(Loc), EmitCheckTypeDescriptor(LHS.getType()), - llvm::ConstantInt::get(Int8Ty, 1), - llvm::ConstantInt::get(Int8Ty, TCK_ReferenceBinding)}; + llvm::ConstantInt::get(Int8Ty, 0), //< The LogAlignment info is unused. + llvm::ConstantInt::get(Int8Ty, TCK_NonnullAssign)}; EmitCheck({{IsNotNull, SanitizerKind::NullabilityAssign}}, SanitizerHandler::TypeMismatch, StaticData, RHS); } Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=297750=297749=297750=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Mar 14 11:48:29 2017 @@ -115,6 +115,8 @@ enum TypeEvaluationKind { SANITIZER_CHECK(MissingReturn, missing_return, 0) \ SANITIZER_CHECK(MulOverflow, mul_overflow, 0) \ SANITIZER_CHECK(NegateOverflow, negate_overflow, 0) \ +
[PATCH] D30854: [ASTMatchers] Add ObjC matchers for fundamental decls
aaron.ballman added inline comments. Comment at: unittests/ASTMatchers/ASTMatchersNodeTest.cpp:1547 + std::string ObjCString = +"#pragma clang diagnostic ignored \"-Wobjc-root-class\"\n" +"@protocol Proto " kastiglione wrote: > kastiglione wrote: > > aaron.ballman wrote: > > > Instead of using a pragma for this, I think it would make more sense to > > > just modify `matchesObjC()` to disable the diagnostic. This is only > > > intended to test the dynamic AST matchers, so the diagnostics are not > > > useful in that case anyway. > > `matchesConditionally()` accepts only one compiler arg, so putting the > > diagnostics here was a smaller change than refactoring that function. Do > > you think it would be better to refactor `matchesConditionally()`? > I notice that many other tests have warnings. Should these tests just allow > the warnings to be emitted? We generally let the warnings go -- it's not harmful to have them. However, if this is a warning that's likely to trigger on most tests, there's no harm in suppressing it either. Comment at: unittests/ASTMatchers/ASTMatchersTest.h:123 Code, AMatcher, true, -"", FileContentMappings(), "input.m"); +"-fobjc-runtime=macosx", FileContentMappings(), "input.m"); } kastiglione wrote: > aaron.ballman wrote: > > Can you explain why this change is required? > `Code` was not being evaluated as Objective-C 2, which resulted in warnings > and errors for the test this diff introduces. Setting the runtime was the > first approach I tried, and it worked so I went with it without looking into > why it was necessary. Now that you've asked, I stepped through and found that > the `i386-unknown-unknown` triple is resulting in the use of an ELF toolchain > and GCC objc runtime. > > It can be changed to `-fobjc-nonfragile-abi`, which seems better than a > specific runtime, do you agree? Is there any reason to not have Objective-C 2 > be the default? I think -fobjc-nonfragile-abi may be fine, but I guess I'm surprised that ObjC1 didn't require any specific runtime and ObjC2 requires one or else you get errors (warnings are fine, however -- we have plenty of those in these tests). Perhaps it's time to fix the FIXME in `matchesConditionally()` so that we don't need to specify the triple at all, and then you won't need to specify the runtime? I don't think that should hold up this patch, however. https://reviews.llvm.org/D30854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros
enyquist added a comment. @sylvestre.ledru No, unfortunately not. My apologies, I've been taken up with work mostly. I will make a marked attempt to do it this weekend :) Repository: rL LLVM https://reviews.llvm.org/D28462 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30923: Warn on enum assignment to bitfields that can't fit all values
hfinkel added a comment. In https://reviews.llvm.org/D30923#700696, @rnk wrote: > In https://reviews.llvm.org/D30923#700626, @hfinkel wrote: > > > In https://reviews.llvm.org/D30923#700620, @thakis wrote: > > > > > Maybe it should have some "to suppress the warning, do X" fixit? > > > > > > I think we should at least include how many bits the field should have to > > fix the problem (pointing to the relevant field definition certainly seems > > helpful). > > > Agreed, I was just hacking that together. :) > > Do you think it's worth indicating that the error can be suppressed with an > explicit cast, or is that wasted space? What might this look like? Also, I don't see a regression test for this. https://reviews.llvm.org/D30923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30931: [clang-tidy] added new identifier naming case type for ignoring case style
berenm added a comment. In https://reviews.llvm.org/D30931#700690, @alexfh wrote: > I understand your use case, but this patch makes the check's behavior more > confusing: having both "any case" and "ignore case" with subtle differences > in behavior seems very misleading. The problem seems to be coming from the > usage of `CT_AnyCase` to denote uninitialized style. Should we just remove > `NamingStyle::isSet` and use `llvm::Optional` instead of > `NamingStyle` where appropriate? I agree https://reviews.llvm.org/D30931 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30923: Warn on enum assignment to bitfields that can't fit all values
rnk updated this revision to Diff 91741. rnk added a comment. - Beef up test as Nico suggests - Add two notes, one to change the bitfield signedness, one to indicate the required bitwidth https://reviews.llvm.org/D30923 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaChecking.cpp test/SemaCXX/warn-bitfield-enum-conversion.cpp Index: test/SemaCXX/warn-bitfield-enum-conversion.cpp === --- /dev/null +++ test/SemaCXX/warn-bitfield-enum-conversion.cpp @@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -verify %s -Wbitfield-enum-conversion +// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux -verify %s -Wbitfield-enum-conversion + +enum TwoBits { Hi1 = 3 } two_bits; +enum TwoBitsSigned { Lo2 = -2, Hi2 = 1 } two_bits_signed; +enum ThreeBits { Hi3 = 7 } three_bits; +enum ThreeBitsSigned { Lo4 = -4, Hi4 = 3 } three_bits_signed; +enum TwoBitsFixed : unsigned { Hi5 = 3 } two_bits_fixed; + +struct Foo { + unsigned two_bits : 2;// expected-note 2 {{widen this field to 3 bits}} expected-note 2 {{type signed}} + int two_bits_signed : 2; // expected-note 2 {{widen this field to 3 bits}} expected-note 1 {{type unsigned}} + unsigned three_bits : 3; // expected-note 2 {{type signed}} + int three_bits_signed : 3;// expected-note 1 {{type unsigned}} + +#ifdef _WIN32 + // expected-note@+2 {{type unsigned}} +#endif + ThreeBits three_bits_enum : 3; + ThreeBits four_bits_enum : 4; +}; + +void f() { + Foo f; + + f.two_bits = two_bits; + f.two_bits = two_bits_signed;// expected-warning {{negative enumerators}} + f.two_bits = three_bits; // expected-warning {{not wide enough}} + f.two_bits = three_bits_signed; // expected-warning {{negative enumerators}} expected-warning {{not wide enough}} + f.two_bits = two_bits_fixed; + + f.two_bits_signed = two_bits;// expected-warning {{needs an extra bit}} + f.two_bits_signed = two_bits_signed; + f.two_bits_signed = three_bits; // expected-warning {{not wide enough}} + f.two_bits_signed = three_bits_signed; // expected-warning {{not wide enough}} + + f.three_bits = two_bits; + f.three_bits = two_bits_signed; // expected-warning {{negative enumerators}} + f.three_bits = three_bits; + f.three_bits = three_bits_signed;// expected-warning {{negative enumerators}} + + f.three_bits_signed = two_bits; + f.three_bits_signed = two_bits_signed; + f.three_bits_signed = three_bits;// expected-warning {{needs an extra bit}} + f.three_bits_signed = three_bits_signed; + +#ifdef _WIN32 + // Enums on Windows are always implicitly 'int', which is signed, so you need + // an extra bit to store values that set the MSB. This is not true on SysV + // platforms like Linux. + // expected-warning@+2 {{needs an extra bit}} +#endif + f.three_bits_enum = three_bits; + f.four_bits_enum = three_bits; +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -8729,13 +8729,65 @@ return false; Expr *OriginalInit = Init->IgnoreParenImpCasts(); + unsigned FieldWidth = Bitfield->getBitWidthValue(S.Context); llvm::APSInt Value; - if (!OriginalInit->EvaluateAsInt(Value, S.Context, Expr::SE_AllowSideEffects)) + if (!OriginalInit->EvaluateAsInt(Value, S.Context, + Expr::SE_AllowSideEffects)) { +// The RHS is not constant. If the RHS has an enum type, make sure the +// bitfield is wide enough to hold all the values of the enum without +// truncation. +if (const auto *EnumTy = OriginalInit->getType()->getAs()) { + EnumDecl *ED = EnumTy->getDecl(); + bool SignedBitfield = BitfieldType->isSignedIntegerType(); + + // Enum types are implicitly signed on Windows, so check if there are any + // negative enumerators to see if the enum was intended to be signed or + // not. + bool SignedEnum = ED->getNumNegativeBits() > 0; + + // Check for surprising sign changes when assigning enum values to a + // bitfield of different signedness. If the bitfield is signed and we + // have exactly the right number of bits to store this unsigned enum, + // suggest changing the enum to an unsigned type. This typically happens + // on Windows where unfixed enums always use an underlying type of 'int'. + unsigned DiagID = 0; + if (SignedEnum && !SignedBitfield) { +DiagID = diag::warn_unsigned_bitfield_assigned_signed_enum; + } else if (SignedBitfield && !SignedEnum && + ED->getNumPositiveBits() == FieldWidth) { +DiagID = diag::warn_signed_bitfield_enum_conversion; + } + + if (DiagID) { +S.Diag(InitLoc, DiagID) << Bitfield << ED; +TypeSourceInfo *TSI =
[PATCH] D30923: Warn on enum assignment to bitfields that can't fit all values
rnk added a comment. In https://reviews.llvm.org/D30923#700626, @hfinkel wrote: > In https://reviews.llvm.org/D30923#700620, @thakis wrote: > > > Maybe it should have some "to suppress the warning, do X" fixit? > > > I think we should at least include how many bits the field should have to fix > the problem (pointing to the relevant field definition certainly seems > helpful). Agreed, I was just hacking that together. :) Do you think it's worth indicating that the error can be suppressed with an explicit cast, or is that wasted space? https://reviews.llvm.org/D30923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30931: [clang-tidy] added new identifier naming case type for ignoring case style
alexfh added a comment. BTW, next time please add cfe-commits to subscribers when you create the patch to get it sent properly to the mailing list. https://reviews.llvm.org/D30931 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30854: [ASTMatchers] Add ObjC matchers for fundamental decls
kastiglione updated this revision to Diff 91740. kastiglione added a comment. Use -fobjc-nonfragile-abi https://reviews.llvm.org/D30854 Files: docs/LibASTMatchersReference.html include/clang/ASTMatchers/ASTMatchers.h lib/ASTMatchers/Dynamic/Registry.cpp unittests/ASTMatchers/ASTMatchersNodeTest.cpp unittests/ASTMatchers/ASTMatchersTest.h Index: unittests/ASTMatchers/ASTMatchersTest.h === --- unittests/ASTMatchers/ASTMatchersTest.h +++ unittests/ASTMatchers/ASTMatchersTest.h @@ -120,7 +120,7 @@ const T ) { return matchesConditionally( Code, AMatcher, true, -"", FileContentMappings(), "input.m"); +"-fobjc-nonfragile-abi", FileContentMappings(), "input.m"); } template @@ -148,7 +148,7 @@ const T ) { return matchesConditionally( Code, AMatcher, false, -"", FileContentMappings(), "input.m"); +"-fobjc-nonfragile-abi", FileContentMappings(), "input.m"); } Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp === --- unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -1498,7 +1498,9 @@ // don't find ObjCMessageExpr where none are present EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(; - std::string Objc1String = + std::string ObjCString = +"#pragma clang diagnostic ignored \"-Wobjc-root-class\"\n" +"#pragma clang diagnostic ignored \"-Wobjc-method-access\"\n" "@interface Str " " - (Str *)uppercaseString:(Str *)str;" "@end " @@ -1513,32 +1515,73 @@ "} " "@end "; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(anything(; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(hasSelector("contents"; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(matchesSelector("cont*"; EXPECT_FALSE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(matchesSelector("?cont*"; EXPECT_TRUE(notMatchesObjC( -Objc1String, +ObjCString, objcMessageExpr(hasSelector("contents"), hasNullSelector(; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(hasSelector("contents"), hasUnarySelector(; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(hasSelector("contents"), numSelectorArgs(0; EXPECT_TRUE(matchesObjC( -Objc1String, +ObjCString, objcMessageExpr(matchesSelector("uppercase*"), argumentCountIs(0) ))); } +TEST(ObjCDeclMacher, CoreDecls) { + std::string ObjCString = +"#pragma clang diagnostic ignored \"-Wobjc-root-class\"\n" +"@protocol Proto " +"- (void)protoDidThing; " +"@end " +"@interface Thing " +"@property int enabled; " +"@end " +"@interface Thing (ABC) " +"- (void)abc_doThing; " +"@end " +"@implementation Thing " +"{ id _ivar; } " +"- (void)anything {} " +"@end " +; + + EXPECT_TRUE(matchesObjC( +ObjCString, +objcProtocolDecl(hasName("Proto"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcCategoryDecl(hasName("ABC"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcMethodDecl(hasName("protoDidThing"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcMethodDecl(hasName("abc_doThing"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcMethodDecl(hasName("anything"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcIvarDecl(hasName("_ivar"; + EXPECT_TRUE(matchesObjC( +ObjCString, +objcPropertyDecl(hasName("enabled"; +} + } // namespace ast_matchers } // namespace clang Index: lib/ASTMatchers/Dynamic/Registry.cpp === --- lib/ASTMatchers/Dynamic/Registry.cpp +++ lib/ASTMatchers/Dynamic/Registry.cpp @@ -360,6 +360,11 @@ REGISTER_MATCHER(numSelectorArgs); REGISTER_MATCHER(ofClass); REGISTER_MATCHER(objcInterfaceDecl); + REGISTER_MATCHER(objcProtocolDecl); + REGISTER_MATCHER(objcCategoryDecl); + REGISTER_MATCHER(objcMethodDecl); + REGISTER_MATCHER(objcIvarDecl); + REGISTER_MATCHER(objcPropertyDecl); REGISTER_MATCHER(objcMessageExpr); REGISTER_MATCHER(objcObjectPointerType); REGISTER_MATCHER(on); Index: include/clang/ASTMatchers/ASTMatchers.h === --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -1118,6 +1118,69 @@ Decl, ObjCInterfaceDecl> objcInterfaceDecl; +/// \brief Matches Objective-C protocol declarations. +/// +/// Example matches FooDelegate +/// \code +/// @protocol FooDelegate +/// @end +/// \endcode +const internal::VariadicDynCastAllOfMatcher< + Decl, +
[PATCH] D30854: [ASTMatchers] Add ObjC matchers for fundamental decls
kastiglione added inline comments. Comment at: unittests/ASTMatchers/ASTMatchersNodeTest.cpp:1547 + std::string ObjCString = +"#pragma clang diagnostic ignored \"-Wobjc-root-class\"\n" +"@protocol Proto " kastiglione wrote: > aaron.ballman wrote: > > Instead of using a pragma for this, I think it would make more sense to > > just modify `matchesObjC()` to disable the diagnostic. This is only > > intended to test the dynamic AST matchers, so the diagnostics are not > > useful in that case anyway. > `matchesConditionally()` accepts only one compiler arg, so putting the > diagnostics here was a smaller change than refactoring that function. Do you > think it would be better to refactor `matchesConditionally()`? I notice that many other tests have warnings. Should these tests just allow the warnings to be emitted? https://reviews.llvm.org/D30854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30946: [ScopePrinting] Added support to print full scopes of types and declarations.
schroedersi created this revision. Herald added subscribers: mgorny, klimek. PrintingPolicy::SuppressScope was replaced by PrintingPolicy::Scope. Possible values for PrintingPolicy::Scope are: - FullScope: Print all nested name specifiers (including the global scope specifier). This is necessary if a printed non-absolute scope would not select the desired scope. Example: Consider the following code: namespace Z { namespace Z { namespace Y { class X { }; // (1) } } namespace Y { class X { }; // (2) } // (3) } Printing type ::Z::Y::X (marked with (2)) without FullScope results in "Z::Y::X". If this is used at the position marked with (3), it will select the wrong type ::Z::Z::Y::X (marked with (1)). With FullScope the result is "::Z::Y::X" and the correct type is selected. Please note that in some cases it is not possible to print the full scope. For example in case of a local class or a dependent name. - DefaultScope: This corresponds to the previous behavior with SuppressScope==false: In case of an elaborated type, print the outer scope as written in the source. (If there is a tag keyword and no scope in the source then no scope is printed.) Otherwise print the full scope but without the global scope specifier. This distinction is made for inner scopes recursively. - SuppressScope: Do not print any scope. https://reviews.llvm.org/D30946 Files: include/clang/AST/PrettyPrinter.h include/clang/AST/TemplateName.h lib/AST/Decl.cpp lib/AST/NestedNameSpecifier.cpp lib/AST/TemplateName.cpp lib/AST/TypePrinter.cpp lib/CodeGen/CGDebugInfo.cpp lib/Tooling/Core/QualTypeNames.cpp test/CXX/class.access/p6.cpp unittests/AST/AbsoluteScopeTest.cpp unittests/AST/CMakeLists.txt unittests/AST/NamedDeclPrinterTest.cpp unittests/AST/TypePrinterTest.cpp Index: unittests/AST/TypePrinterTest.cpp === --- /dev/null +++ unittests/AST/TypePrinterTest.cpp @@ -0,0 +1,471 @@ +//===- unittests/AST/TypePrinterTest.cpp -- TypePrinter printer tests -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +// This file contains tests for TypePrinter::print(...). +// +// These tests have a coding convention: +// * variable whose type to be printed is named 'A' unless it should have some +// special name +// * additional helper classes/namespaces/... are 'Z', 'Y', 'X' and so on. +// +//===--===// + +#include "clang/AST/ASTContext.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Tooling/Tooling.h" +#include "llvm/ADT/SmallString.h" +#include "gtest/gtest.h" + +using namespace clang; +using namespace ast_matchers; +using namespace tooling; +namespace { + +class PrintMatch : public MatchFinder::MatchCallback { + SmallString<1024> Printed; + unsigned NumFoundDecls; + bool SuppressUnwrittenScope; + ScopePrintingKind::ScopePrintingKind Scope; + +public: + explicit PrintMatch(bool suppressUnwrittenScope, + ScopePrintingKind::ScopePrintingKind scope) +: NumFoundDecls(0), SuppressUnwrittenScope(suppressUnwrittenScope), + Scope(scope) { } + + void run(const MatchFinder::MatchResult ) override { +const ValueDecl *VD = Result.Nodes.getNodeAs("id"); +if (!VD) + return; +NumFoundDecls++; +if (NumFoundDecls > 1) + return; + +llvm::raw_svector_ostream Out(Printed); +PrintingPolicy Policy = Result.Context->getPrintingPolicy(); +Policy.SuppressUnwrittenScope = SuppressUnwrittenScope; +Policy.Scope = Scope; +QualType Type = VD->getType(); +Type.print(Out, Policy); + } + + StringRef getPrinted() const { +return Printed; + } + + unsigned getNumFoundDecls() const { +return NumFoundDecls; + } +}; + +::testing::AssertionResult +PrintedTypeMatches(StringRef Code, const std::vector , + bool SuppressUnwrittenScope, + const DeclarationMatcher , + StringRef ExpectedPrinted, StringRef FileName, + ScopePrintingKind::ScopePrintingKind Scope) { + PrintMatch Printer(SuppressUnwrittenScope, Scope); + MatchFinder Finder; + Finder.addMatcher(NodeMatch, ); + std::unique_ptr Factory = + newFrontendActionFactory(); + + if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName)) +return testing::AssertionFailure() +<< "Parsing error in \"" << Code.str() << "\""; + + if (Printer.getNumFoundDecls() == 0) +return testing::AssertionFailure() +<< "Matcher didn't find any value declarations"; + + if (Printer.getNumFoundDecls() > 1) +return testing::AssertionFailure() +<< "Matcher should match only one value declaration " + "(found " <<
[PATCH] D29757: [libcxx] Threading support: Externalize hardware_concurrency()
rmaprath added a comment. @EricWF: Ping? https://reviews.llvm.org/D29757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29818: [libcxx] Threading support: Attempt to externalize system_clock::now() and steady_clock::now() implementations
rmaprath added a comment. @EricWF: Ping? https://reviews.llvm.org/D29818 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30945: Fix mis-spelled enum
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM, thank you! https://reviews.llvm.org/D30945 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30945: Fix mis-spelled enum
jroelofs created this revision. https://reviews.llvm.org/D30945 Files: include/clang/Parse/Parser.h lib/Parse/ParseOpenMP.cpp lib/Parse/ParseStmt.cpp Index: lib/Parse/ParseStmt.cpp === --- lib/Parse/ParseStmt.cpp +++ lib/Parse/ParseStmt.cpp @@ -97,7 +97,7 @@ /// StmtResult Parser::ParseStatementOrDeclaration(StmtVector , -AllowedContsructsKind Allowed, +AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc) { ParenBraceBracketBalancer BalancerRAIIObj(*this); @@ -150,7 +150,7 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes(StmtVector , - AllowedContsructsKind Allowed, SourceLocation *TrailingElseLoc, + AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc, ParsedAttributesWithRange ) { const char *SemiError = nullptr; StmtResult Res; @@ -1903,7 +1903,7 @@ } StmtResult Parser::ParsePragmaLoopHint(StmtVector , - AllowedContsructsKind Allowed, + AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc, ParsedAttributesWithRange ) { // Create temporary attribute list. Index: lib/Parse/ParseOpenMP.cpp === --- lib/Parse/ParseOpenMP.cpp +++ lib/Parse/ParseOpenMP.cpp @@ -806,7 +806,7 @@ /// annot_pragma_openmp_end /// StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective( -AllowedContsructsKind Allowed) { +AllowedConstructsKind Allowed) { assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!"); ParenBraceBracketBalancer BalancerRAIIObj(*this); SmallVector Clauses; Index: include/clang/Parse/Parser.h === --- include/clang/Parse/Parser.h +++ include/clang/Parse/Parser.h @@ -1686,7 +1686,7 @@ StmtResult ParseStatement(SourceLocation *TrailingElseLoc = nullptr, bool AllowOpenMPStandalone = false); - enum AllowedContsructsKind { + enum AllowedConstructsKind { /// \brief Allow any declarations, statements, OpenMP directives. ACK_Any, /// \brief Allow only statements and non-standalone OpenMP directives. @@ -1695,11 +1695,11 @@ ACK_StatementsOpenMPAnyExecutable }; StmtResult - ParseStatementOrDeclaration(StmtVector , AllowedContsructsKind Allowed, + ParseStatementOrDeclaration(StmtVector , AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc = nullptr); StmtResult ParseStatementOrDeclarationAfterAttributes( StmtVector , - AllowedContsructsKind Allowed, + AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc, ParsedAttributesWithRange ); StmtResult ParseExprStatement(); @@ -1728,7 +1728,7 @@ StmtResult ParseAsmStatement(bool ); StmtResult ParseMicrosoftAsmStatement(SourceLocation AsmLoc); StmtResult ParsePragmaLoopHint(StmtVector , - AllowedContsructsKind Allowed, + AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc, ParsedAttributesWithRange ); @@ -2587,7 +2587,7 @@ /// executable directives are allowed. /// StmtResult - ParseOpenMPDeclarativeOrExecutableDirective(AllowedContsructsKind Allowed); + ParseOpenMPDeclarativeOrExecutableDirective(AllowedConstructsKind Allowed); /// \brief Parses clause of kind \a CKind for directive of a kind \a Kind. /// /// \param DKind Kind of current directive. Index: lib/Parse/ParseStmt.cpp === --- lib/Parse/ParseStmt.cpp +++ lib/Parse/ParseStmt.cpp @@ -97,7 +97,7 @@ /// StmtResult Parser::ParseStatementOrDeclaration(StmtVector , -AllowedContsructsKind Allowed, +AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc) { ParenBraceBracketBalancer BalancerRAIIObj(*this); @@ -150,7 +150,7 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes(StmtVector , - AllowedContsructsKind Allowed, SourceLocation *TrailingElseLoc, + AllowedConstructsKind Allowed, SourceLocation *TrailingElseLoc, ParsedAttributesWithRange ) { const char *SemiError = nullptr; StmtResult Res; @@ -1903,7 +1903,7 @@ } StmtResult Parser::ParsePragmaLoopHint(StmtVector , -
[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin
pirama updated this revision to Diff 91738. pirama added a comment. Explicitly pass -O2 instead of relying on the default opt level. https://reviews.llvm.org/D30920 Files: lib/Driver/ToolChains/CommonArgs.cpp test/Driver/gold-lto.c Index: test/Driver/gold-lto.c === --- test/Driver/gold-lto.c +++ test/Driver/gold-lto.c @@ -26,3 +26,12 @@ // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID // CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so" +// +// Test that -Os and -Oz are not passed to the plugin +// RUN: %clang -### %t.o -flto -Os 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Os" \ +// RUN: --check-prefix=CHECK-O2 +// RUN: %clang -### %t.o -flto -Oz 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Oz" \ +// RUN: --check-prefix=CHECK-O2 +// CHECK-O2: "-plugin-opt=O2" Index: lib/Driver/ToolChains/CommonArgs.cpp === --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -368,9 +368,16 @@ if (A->getOption().matches(options::OPT_O4) || A->getOption().matches(options::OPT_Ofast)) OOpt = "3"; -else if (A->getOption().matches(options::OPT_O)) - OOpt = A->getValue(); -else if (A->getOption().matches(options::OPT_O0)) +else if (A->getOption().matches(options::OPT_O)) { + StringRef OptLevel = A->getValue(); + // -Os and -Oz add corresponding attributes to functions. Just use -O2 + // for these optimization levels. Pass other optimization levels through + // to the plugin. + if (OptLevel == "s" || OptLevel == "z") +OOpt = "2"; + else +OOpt = OptLevel; +} else if (A->getOption().matches(options::OPT_O0)) OOpt = "0"; if (!OOpt.empty()) CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt)); Index: test/Driver/gold-lto.c === --- test/Driver/gold-lto.c +++ test/Driver/gold-lto.c @@ -26,3 +26,12 @@ // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID // CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so" +// +// Test that -Os and -Oz are not passed to the plugin +// RUN: %clang -### %t.o -flto -Os 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Os" \ +// RUN: --check-prefix=CHECK-O2 +// RUN: %clang -### %t.o -flto -Oz 2>&1 \ +// RUN: | FileCheck %s --implicit-check-not "-plugin-opt=Oz" \ +// RUN: --check-prefix=CHECK-O2 +// CHECK-O2: "-plugin-opt=O2" Index: lib/Driver/ToolChains/CommonArgs.cpp === --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -368,9 +368,16 @@ if (A->getOption().matches(options::OPT_O4) || A->getOption().matches(options::OPT_Ofast)) OOpt = "3"; -else if (A->getOption().matches(options::OPT_O)) - OOpt = A->getValue(); -else if (A->getOption().matches(options::OPT_O0)) +else if (A->getOption().matches(options::OPT_O)) { + StringRef OptLevel = A->getValue(); + // -Os and -Oz add corresponding attributes to functions. Just use -O2 + // for these optimization levels. Pass other optimization levels through + // to the plugin. + if (OptLevel == "s" || OptLevel == "z") +OOpt = "2"; + else +OOpt = OptLevel; +} else if (A->getOption().matches(options::OPT_O0)) OOpt = "0"; if (!OOpt.empty()) CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30854: [ASTMatchers] Add ObjC matchers for fundamental decls
kastiglione added inline comments. Comment at: unittests/ASTMatchers/ASTMatchersNodeTest.cpp:1501 - std::string Objc1String = + std::string ObjCString = +"#pragma clang diagnostic ignored \"-Wobjc-root-class\"\n" aaron.ballman wrote: > These changes are unrelated and should be in a separate commit. They're related to the use of either `-fobjc-runtime=` or `fobjc-nonfragile-abi`. Comment at: unittests/ASTMatchers/ASTMatchersNodeTest.cpp:1547 + std::string ObjCString = +"#pragma clang diagnostic ignored \"-Wobjc-root-class\"\n" +"@protocol Proto " aaron.ballman wrote: > Instead of using a pragma for this, I think it would make more sense to just > modify `matchesObjC()` to disable the diagnostic. This is only intended to > test the dynamic AST matchers, so the diagnostics are not useful in that case > anyway. `matchesConditionally()` accepts only one compiler arg, so putting the diagnostics here was a smaller change than refactoring that function. Do you think it would be better to refactor `matchesConditionally()`? Comment at: unittests/ASTMatchers/ASTMatchersTest.h:123 Code, AMatcher, true, -"", FileContentMappings(), "input.m"); +"-fobjc-runtime=macosx", FileContentMappings(), "input.m"); } aaron.ballman wrote: > Can you explain why this change is required? `Code` was not being evaluated as Objective-C 2, which resulted in warnings and errors for the test this diff introduces. Setting the runtime was the first approach I tried, and it worked so I went with it without looking into why it was necessary. Now that you've asked, I stepped through and found that the `i386-unknown-unknown` triple is resulting in the use of an ELF toolchain and GCC objc runtime. It can be changed to `-fobjc-nonfragile-abi`, which seems better than a specific runtime, do you agree? Is there any reason to not have Objective-C 2 be the default? https://reviews.llvm.org/D30854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: LLVM Lab SVN mirror is behind
r297634 was the 4.0.0 release commit. We'll probably see similar-size commits for 4.0.1 and 5.0.0. Can we make the buildbot svn mirror ignore that component of the repository to avoid this happening again? - Hans On Tue, Mar 14, 2017 at 12:23 AM, Galina Kistanova via cfe-commitswrote: > The SVN mirror is back up and running. > Please let me know if you would see any issues. > > Thanks for your patience. > > > On Mon, Mar 13, 2017 at 4:26 PM, Galina Kistanova > wrote: >> >> A quick update. >> >> The SVN mirror got corrupted by r297634. Svnsync does not like huge >> commits. >> I'm in the middle of restoring and synch-ing up the mirror. Too soon to >> give any ETA, unfortunately. >> >> Thank you for your patience. >> >> Thanks >> >> Galina >> >> >> >> >> On Mon, Mar 13, 2017 at 12:36 PM, Galina Kistanova >> wrote: >>> >>> Hello everyone, >>> >>> The SVN mirror in the LLVM Lab seems behind with the changes. >>> I'm looking at the issue. >>> >>> Thank you for understanding. >>> >>> Thanks >>> >> > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30923: Warn on enum assignment to bitfields that can't fit all values
hfinkel added a comment. In https://reviews.llvm.org/D30923#700620, @thakis wrote: > Maybe it should have some "to suppress the warning, do X" fixit? I think we should at least include how many bits the field should have to fix the problem (pointing to the relevant field definition certainly seems helpful). https://reviews.llvm.org/D30923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30923: Warn on enum assignment to bitfields that can't fit all values
thakis added a comment. Maybe it should have some "to suppress the warning, do X" fixit? https://reviews.llvm.org/D30923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30923: Warn on enum assignment to bitfields that can't fit all values
thakis accepted this revision. thakis added a comment. This revision is now accepted and ready to land. Looks like a cool warning. Two suggestions for more exhaustive testing, but I think this looks good. Comment at: test/SemaCXX/warn-bitfield-enum-conversion.cpp:1 +// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -verify %s -Wbitfield-enum-conversion + Consider also running this test with a triple where enums don't default to signed. Comment at: test/SemaCXX/warn-bitfield-enum-conversion.cpp:15 + + ThreeBits three_bits_enum : 3; +}; Also add a : 4 version and check that that doesn't warn? https://reviews.llvm.org/D30923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] r297744 - DarwinParser: include limits
Author: compnerd Date: Tue Mar 14 10:17:55 2017 New Revision: 297744 URL: http://llvm.org/viewvc/llvm-project?rev=297744=rev Log: DarwinParser: include limits In debug mode, we have assertions that the values do not exceed the limits of the type holding them. In order to account for the type being derived from the AddressSpace and thus a typedef, we use `std::numeric_limits`. Include the appropriate header. Thanks to Marshal Clow for pointing out the missing include! Modified: libunwind/trunk/src/DwarfParser.hpp Modified: libunwind/trunk/src/DwarfParser.hpp URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=297744=297743=297744=diff == --- libunwind/trunk/src/DwarfParser.hpp (original) +++ libunwind/trunk/src/DwarfParser.hpp Tue Mar 14 10:17:55 2017 @@ -17,6 +17,7 @@ #include #include #include +#include #include "libunwind.h" #include "dwarf2.h" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30937: [OpenCL] Added diagnostic for checking length of vector
Anastasia added inline comments. Comment at: lib/Sema/SemaExprMember.cpp:287 +// OpenCL spec (Section 6.1.7 Vector Components): +// The component group notation can occur on the left hand side of an expression. To form an lvalue, The format is normally: OpenCL v1.1, s6.1.7 Comment at: lib/Sema/SemaExprMember.cpp:288 +// OpenCL spec (Section 6.1.7 Vector Components): +// The component group notation can occur on the left hand side of an expression. To form an lvalue, +// swizzling must be applied to an l-value of vector type, contain no duplicate components, Does this text have much relation to the function? I don't feel that copying it from the spec is helping much in understanding of this function. It's probably just Ok to have the reference to the spec section and concisely summarize that the component swizzle length must be in accordance with the acceptable vector sizes. Also would it be better to rename this to something like: IsValidOpenCLComponentSwizzleLength Comment at: lib/Sema/SemaExprMember.cpp:389 + if (S.getLangOpts().OpenCL && !HalvingSwizzle) { +compStr = CompName->getNameStart(); I think the logic in this function is all for OpenCL, but we didn't check it . Anyways, let's leave it for now. Comment at: lib/Sema/SemaExprMember.cpp:395 + +unsigned swizzleLength = StringRef(compStr).size(); +if (IsValidSwizzleLength(swizzleLength) == false) { Variable name doesn't adhere the coding style: http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly Also you could use CompName->getLength() instead of constructing a new StringRef object. Comment at: test/SemaOpenCL/vector_swizzle_length.cl:8 + +f2.s01234; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} +} Could we add a non-numeric swizzle too? https://reviews.llvm.org/D30937 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin
mehdi_amini added a comment. In https://reviews.llvm.org/D30920#700433, @tejohnson wrote: > In https://reviews.llvm.org/D30920#700133, @pcc wrote: > > > In https://reviews.llvm.org/D30920#700077, @tejohnson wrote: > > > > > Until everything is converted to using size attributes, it seems like a > > > correct fix for the bug is to accept these options in the gold-plugin and > > > pass through the LTO API to the PassManagerBuilder. > > > > > > Not necessarily. There is no requirement (from a correctness perspective) > > that `-Os` at link time should exactly match the behaviour of `-Os` at > > compile time. > > > Sure, but there is certainly a perception that optimization flags affecting > the non-LTO pipeline should similarly affect the LTO pipeline. LTO should be > transparent to the user, so if -Os behaves one way without LTO, it seems > problematic to me if it behaves a different way with LTO. > > That being said, agree that the best way to enforce that is to pass the > relevant flags through the IR. (On the flip side, if the user passes -O1 to > the link step, it does get passed through to the plugin and affects the LTO > optimization pipeline...) I agree that I don't like the discrepancy: the driver should *not* drop -Os silently if it passes down -O1/-O2/-O3, a warning is the minimum. https://reviews.llvm.org/D30920 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30415: Fix -mno-altivec cannot overwrite -maltivec option
hfinkel added a comment. In https://reviews.llvm.org/D30415#700534, @nemanjai wrote: > This seems to change the relationship between -m[no-]altivec and > -f[no-]altivec which has been kind of contentious for a while. Can you add a > note as to whether the new behaviour matches the GCC behaviour. Also, perhaps > @echristo might want to chime in as to whether this is the desired behaviour > or not. Why do you say this? It only seems to affect whether the syntax extensions can be disabled via the appropriate flag. https://reviews.llvm.org/D30415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30415: Fix -mno-altivec cannot overwrite -maltivec option
nemanjai added a subscriber: echristo. nemanjai added a comment. This seems to change the relationship between -m[no-]altivec and -f[no-]altivec which has been kind of contentious for a while. Can you add a note as to whether the new behaviour matches the GCC behaviour. Also, perhaps @echristo might want to chime in as to whether this is the desired behaviour or not. https://reviews.llvm.org/D30415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27334: [OpenCL] Ambiguous function call.
Anastasia added a comment. I don't actually. But remembering the follow up discussion: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20161205/178846.html and since we have to deviate from the standard C/C++ implementation anyways I am wondering whether modifying overloading resolution is a better way to go? https://reviews.llvm.org/D27334 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30743: enable -save-temps with -finclude-defult-header
guansong updated this revision to Diff 91718. guansong added a comment. Thanks, update as suggested. https://reviews.llvm.org/D30743 Files: lib/Driver/Tools.cpp test/Driver/include-default-header.cl Index: test/Driver/include-default-header.cl === --- /dev/null +++ test/Driver/include-default-header.cl @@ -0,0 +1,4 @@ +// RUN: %clang -v -save-temps -x cl -Xclang -cl-std=CL2.0 -Xclang -finclude-default-header -target amdgcn -S -c %s + +void test() {} + Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -5285,7 +5285,20 @@ // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option // parser. - Args.AddAllArgValues(CmdArgs, options::OPT_Xclang); + // -finclude-default-header flag is for preprocessor, + // do not pass it to other cc1 commands when save-temps is enabled + if (C.getDriver().isSaveTempsEnabled() && + !isa(JA)) { +for (auto Arg : Args.filtered(options::OPT_Xclang)) { + Arg->claim(); + if (StringRef(Arg->getValue()) != "-finclude-default-header") +CmdArgs.push_back(Arg->getValue()); +} + } + else { +Args.AddAllArgValues(CmdArgs, options::OPT_Xclang); + } + for (const Arg *A : Args.filtered(options::OPT_mllvm)) { A->claim(); Index: test/Driver/include-default-header.cl === --- /dev/null +++ test/Driver/include-default-header.cl @@ -0,0 +1,4 @@ +// RUN: %clang -v -save-temps -x cl -Xclang -cl-std=CL2.0 -Xclang -finclude-default-header -target amdgcn -S -c %s + +void test() {} + Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -5285,7 +5285,20 @@ // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option // parser. - Args.AddAllArgValues(CmdArgs, options::OPT_Xclang); + // -finclude-default-header flag is for preprocessor, + // do not pass it to other cc1 commands when save-temps is enabled + if (C.getDriver().isSaveTempsEnabled() && + !isa(JA)) { +for (auto Arg : Args.filtered(options::OPT_Xclang)) { + Arg->claim(); + if (StringRef(Arg->getValue()) != "-finclude-default-header") +CmdArgs.push_back(Arg->getValue()); +} + } + else { +Args.AddAllArgValues(CmdArgs, options::OPT_Xclang); + } + for (const Arg *A : Args.filtered(options::OPT_mllvm)) { A->claim(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30415: Fix -mno-altivec cannot overwrite -maltivec option
hfinkel accepted this revision. hfinkel added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D30415 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25866: [Sema] Support implicit scalar to vector conversions
sdardis updated this revision to Diff 91716. sdardis added a comment. Addressed review comments, add C++ specific test. https://reviews.llvm.org/D25866 Files: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Sema/Sema.h lib/Sema/SemaExpr.cpp test/Sema/vector-cast.c test/Sema/vector-g++-compat.cpp test/Sema/vector-gcc-compat.c test/Sema/vector-ops.c test/Sema/zvector.c test/SemaCXX/vector-no-lax.cpp Index: test/SemaCXX/vector-no-lax.cpp === --- test/SemaCXX/vector-no-lax.cpp +++ test/SemaCXX/vector-no-lax.cpp @@ -4,6 +4,6 @@ vSInt32 foo (vUInt32 a) { vSInt32 b = { 0, 0, 0, 0 }; - b += a; // expected-error{{cannot convert between vector values}} + b += a; // expected-error{{cannot convert between vector type 'vUInt32' (vector of 4 'unsigned int' values) and vector type 'vSInt32' (vector of 4 'int' values) as implicit conversion would cause truncation}} return b; } Index: test/Sema/zvector.c === --- test/Sema/zvector.c +++ test/Sema/zvector.c @@ -326,14 +326,14 @@ bc = bc + sc2; // expected-error {{incompatible type}} bc = sc + bc2; // expected-error {{incompatible type}} - sc = sc + sc_scalar; // expected-error {{cannot convert}} - sc = sc + uc_scalar; // expected-error {{cannot convert}} - sc = sc_scalar + sc; // expected-error {{cannot convert}} - sc = uc_scalar + sc; // expected-error {{cannot convert}} - uc = uc + sc_scalar; // expected-error {{cannot convert}} - uc = uc + uc_scalar; // expected-error {{cannot convert}} - uc = sc_scalar + uc; // expected-error {{cannot convert}} - uc = uc_scalar + uc; // expected-error {{cannot convert}} + sc = sc + sc_scalar; + sc = sc + uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}} + sc = sc_scalar + sc; + sc = uc_scalar + sc; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}} + uc = uc + sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}} + uc = uc + uc_scalar; + uc = sc_scalar + uc; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}} + uc = uc_scalar + uc; ss = ss + ss2; us = us + us2; @@ -368,10 +368,10 @@ sc += sl2; // expected-error {{cannot convert}} sc += fd2; // expected-error {{cannot convert}} - sc += sc_scalar; // expected-error {{cannot convert}} - sc += uc_scalar; // expected-error {{cannot convert}} - uc += sc_scalar; // expected-error {{cannot convert}} - uc += uc_scalar; // expected-error {{cannot convert}} + sc += sc_scalar; + sc += uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}} + uc += sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}} + uc += uc_scalar; ss += ss2; us += us2; Index: test/Sema/vector-ops.c === --- test/Sema/vector-ops.c +++ test/Sema/vector-ops.c @@ -13,7 +13,7 @@ (void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}} // Comparison operators - v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'int __attribute__((ext_vector_type(2)))' (vector of 2 'int' values)}} + v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int int' (vector of 2 'int' values)}} v2sa = (v2ua==v2sa); // Arrays Index: test/Sema/vector-gcc-compat.c === --- /dev/null +++ test/Sema/vector-gcc-compat.c @@ -0,0 +1,335 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything + +// Test the compatibility of clang's vector extensions with gcc's vector +// extensions for C. Notably &&, ||, ?: and ! are not available. +typedef long long v2i64 __attribute__((vector_size(16))); +typedef int v2i32 __attribute__((vector_size(8))); +typedef short v2i16 __attribute__((vector_size(4))); +typedef char v2i8 __attribute__((vector_size(2))); + +typedef unsigned long long v2u64 __attribute__((vector_size(16))); +typedef unsigned int v2u32 __attribute__((vector_size(8))); +typedef unsigned short v2u16
[PATCH] D30816: [OpenCL] Added implicit conversion rank for overloading functions with vector data type in OpenCL
echuraev updated this revision to Diff 91713. echuraev marked 2 inline comments as done. https://reviews.llvm.org/D30816 Files: include/clang/Sema/Overload.h lib/Sema/SemaOverload.cpp test/CodeGenOpenCL/overload.cl test/SemaOpenCL/overload_addrspace_resolution.cl Index: test/SemaOpenCL/overload_addrspace_resolution.cl === --- test/SemaOpenCL/overload_addrspace_resolution.cl +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - -triple x86_64-unknown-unknown %s | FileCheck %s - -void __attribute__((overloadable)) foo(global int *a, global int *b); -void __attribute__((overloadable)) foo(generic int *a, generic int *b); -void __attribute__((overloadable)) bar(generic int *global *a, generic int *global *b); -void __attribute__((overloadable)) bar(generic int *generic *a, generic int *generic *b); - -void kernel ker() { - global int *a; - global int *b; - generic int *c; - local int *d; - generic int *generic *gengen; - generic int *local *genloc; - generic int *global *genglob; - // CHECK: call void @_Z3fooPU8CLglobaliS0_(i32* undef, i32* undef) - foo(a, b); - // CHECK: call void @_Z3fooPU9CLgenericiS0_(i32* undef, i32* undef) - foo(b, c); - // CHECK: call void @_Z3fooPU9CLgenericiS0_(i32* undef, i32* undef) - foo(a, d); - - // CHECK: call void @_Z3barPU9CLgenericPU9CLgenericiS2_(i32** undef, i32** undef) - bar(gengen, genloc); - // CHECK: call void @_Z3barPU9CLgenericPU9CLgenericiS2_(i32** undef, i32** undef) - bar(gengen, genglob); - // CHECK: call void @_Z3barPU8CLglobalPU9CLgenericiS2_(i32** undef, i32** undef) - bar(genglob, genglob); -} Index: test/CodeGenOpenCL/overload.cl === --- /dev/null +++ test/CodeGenOpenCL/overload.cl @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck %s + +typedef short short4 __attribute__((ext_vector_type(4))); + +// CHECK-DAG: declare spir_func <4 x i16> @_Z5clampDv4_sS_S_(<4 x i16>, <4 x i16>, <4 x i16>) +short4 __attribute__ ((overloadable)) clamp(short4 x, short4 minval, short4 maxval); +// CHECK-DAG: declare spir_func <4 x i16> @_Z5clampDv4_sss(<4 x i16>, i16 signext, i16 signext) +short4 __attribute__ ((overloadable)) clamp(short4 x, short minval, short maxval); +void __attribute__((overloadable)) foo(global int *a, global int *b); +void __attribute__((overloadable)) foo(generic int *a, generic int *b); +void __attribute__((overloadable)) bar(generic int *global *a, generic int *global *b); +void __attribute__((overloadable)) bar(generic int *generic *a, generic int *generic *b); + +// Checking address space resolution +void kernel test1() { + global int *a; + global int *b; + generic int *c; + local int *d; + generic int *generic *gengen; + generic int *local *genloc; + generic int *global *genglob; + // CHECK-DAG: call spir_func void @_Z3fooPU3AS1iS0_(i32 addrspace(1)* undef, i32 addrspace(1)* undef) + foo(a, b); + // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* undef, i32 addrspace(4)* undef) + foo(b, c); + // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* undef, i32 addrspace(4)* undef) + foo(a, d); + + // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* addrspace(4)* undef, i32 addrspace(4)* addrspace(4)* undef) + bar(gengen, genloc); + // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* addrspace(4)* undef, i32 addrspace(4)* addrspace(4)* undef) + bar(gengen, genglob); + // CHECK-DAG: call spir_func void @_Z3barPU3AS1PU3AS4iS2_(i32 addrspace(4)* addrspace(1)* undef, i32 addrspace(4)* addrspace(1)* undef) + bar(genglob, genglob); +} + +// Checking vector vs scalar resolution +void kernel test2() { + short4 e0=0; + + // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sss(<4 x i16> zeroinitializer, i16 signext 0, i16 signext 255) + clamp(e0, 0, 255); + // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sS_S_(<4 x i16> zeroinitializer, <4 x i16> zeroinitializer, <4 x i16> zeroinitializer) + clamp(e0, e0, e0); +} Index: lib/Sema/SemaOverload.cpp === --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -131,7 +131,7 @@ ICR_Conversion, ICR_Conversion, ICR_Conversion, -ICR_Conversion, +ICR_OCL_Scalar_Widening, ICR_Complex_Real_Conversion, ICR_Conversion, ICR_Conversion, Index: include/clang/Sema/Overload.h === --- include/clang/Sema/Overload.h +++ include/clang/Sema/Overload.h @@ -98,6 +98,7 @@ ICR_Exact_Match = 0, ///< Exact Match ICR_Promotion, ///< Promotion ICR_Conversion, ///< Conversion +ICR_OCL_Scalar_Widening, ///< OpenCL Scalar Widening ICR_Complex_Real_Conversion, ///<
[PATCH] D30743: enable -save-temps with -finclude-defult-header
Anastasia accepted this revision. Anastasia added a comment. This revision is now accepted and ready to land. LGTM! Thanks! Comment at: lib/Driver/Tools.cpp:5290 + !isa(JA)) { +//Args.AddAllArgValues(CmdArgs, options::OPT_Xclang); +for (auto Arg : Args.filtered(options::OPT_Xclang)) { Anastasia wrote: > Remove the commented code, please! I think the comment could be lifted up before the if statement. :) https://reviews.llvm.org/D30743 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30810: Preserve vec3 type.
Anastasia added a comment. In https://reviews.llvm.org/D30810#699827, @jaykang10 wrote: > In https://reviews.llvm.org/D30810#699695, @bruno wrote: > > > Hi JinGu, > > > > I just read the discussion on cfe-dev, some comments: > > > > > My colleague and I are implementing a transformation pass between LLVM IR > > > and another IR and we want to keep the 3-component vector types in our > > > target IR > > > > Why can't you go back through the shuffle to find out that it comes from a > > vec3 -> vec4 transformation? Adding a flag here just for that seems very > > odd. > > > Hi Bruno, > > Thanks for your comment. We have a pass to undo the vec4 to vec3. I wondered > why clang generates the vec4 for vec3 load/store. As you can see the comment > on clang's code, they are generated for better performance. I had a questions > at this point. clang should consider vector load/store aligned by 4 > regardless of target??? llvm's codegen could handle vec3 according to > targets' vector load/store with their alignment. I agree the flag looks odd > but I was concerned some llvm's targets depend on the vec4 so I suggested to > add the flag. If I missed something, please let me know. I think doing this transformation in a frontend was not the best choice because we are losing the source information too early. But some targets can offer a better support for vec3 natively than converting to vec4. Regarding the option, I am wondering whether adding this as a part of TargetInfo would be a better solution. Although, I don't think any currently available upstream targets support this. https://reviews.llvm.org/D30810 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30816: [OpenCL] Added implicit conversion rank for overloading functions with vector data type in OpenCL
Anastasia added inline comments. Comment at: test/SemaOpenCL/overload_addrspace_resolution.cl:1 -// RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - -triple x86_64-unknown-unknown %s | FileCheck %s +// RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck %s bader wrote: > Egor, I think you forgot to move the test to CodeGenOpenCL directory. Yes, I think we can also rename it to something more generic like overload.cl. It would also be nice to start every separate testing section with a comment. Like here could be: 1. Checking address space resolution 2. Checking vector vs scalar resolution https://reviews.llvm.org/D30816 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30937: Added diagnostic for checking length of vector
echuraev created this revision. https://reviews.llvm.org/D30937 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExprMember.cpp test/SemaOpenCL/vector_swizzle_length.cl Index: test/SemaOpenCL/vector_swizzle_length.cl === --- /dev/null +++ test/SemaOpenCL/vector_swizzle_length.cl @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +typedef float float8 __attribute__((ext_vector_type(8))); + +void foo() { +float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0); + +f2.s01234; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} +} Index: lib/Sema/SemaExprMember.cpp === --- lib/Sema/SemaExprMember.cpp +++ lib/Sema/SemaExprMember.cpp @@ -284,6 +284,16 @@ } } +// OpenCL spec (Section 6.1.7 Vector Components): +// The component group notation can occur on the left hand side of an expression. To form an lvalue, +// swizzling must be applied to an l-value of vector type, contain no duplicate components, +// and it results in an l-value of scalar or vector type, depending on number of components +// specified. Each component must be a supported scalar or vector type. +static bool IsValidSwizzleLength(unsigned len) +{ + return (len >= 1 && len <= 4) || len == 8 || len == 16; +} + /// Check an ext-vector component access expression. /// /// VK should be set in advance to the value kind of the base @@ -376,6 +386,20 @@ } } + if (S.getLangOpts().OpenCL && !HalvingSwizzle) { +compStr = CompName->getNameStart(); + +if (HexSwizzle) + compStr++; + +unsigned swizzleLength = StringRef(compStr).size(); +if (IsValidSwizzleLength(swizzleLength) == false) { + S.Diag(OpLoc, diag::err_opencl_ext_vector_component_invalid_length) +<< swizzleLength << SourceRange(CompLoc); + return QualType(); +} + } + // The component accessor looks fine - now we need to compute the actual type. // The vector type is implied by the component accessor. For example, // vec4.b is a float, vec4.xy is a vec2, vec4.rgb is a vec3, etc. Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -8219,6 +8219,8 @@ def err_kernel_arg_address_space : Error< "pointer arguments to kernel functions must reside in '__global', " "'__constant' or '__local' address space">; +def err_opencl_ext_vector_component_invalid_length : Error< + "vector component access has invalid length %0. Supported: 1,2,3,4,8,16.">; def err_opencl_function_variable : Error< "%select{non-kernel function|function scope}0 variable cannot be declared in %1 address space">; def err_static_function_scope : Error< Index: test/SemaOpenCL/vector_swizzle_length.cl === --- /dev/null +++ test/SemaOpenCL/vector_swizzle_length.cl @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +typedef float float8 __attribute__((ext_vector_type(8))); + +void foo() { +float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0); + +f2.s01234; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} +} Index: lib/Sema/SemaExprMember.cpp === --- lib/Sema/SemaExprMember.cpp +++ lib/Sema/SemaExprMember.cpp @@ -284,6 +284,16 @@ } } +// OpenCL spec (Section 6.1.7 Vector Components): +// The component group notation can occur on the left hand side of an expression. To form an lvalue, +// swizzling must be applied to an l-value of vector type, contain no duplicate components, +// and it results in an l-value of scalar or vector type, depending on number of components +// specified. Each component must be a supported scalar or vector type. +static bool IsValidSwizzleLength(unsigned len) +{ + return (len >= 1 && len <= 4) || len == 8 || len == 16; +} + /// Check an ext-vector component access expression. /// /// VK should be set in advance to the value kind of the base @@ -376,6 +386,20 @@ } } + if (S.getLangOpts().OpenCL && !HalvingSwizzle) { +compStr = CompName->getNameStart(); + +if (HexSwizzle) + compStr++; + +unsigned swizzleLength = StringRef(compStr).size(); +if (IsValidSwizzleLength(swizzleLength) == false) { + S.Diag(OpLoc, diag::err_opencl_ext_vector_component_invalid_length) +<< swizzleLength << SourceRange(CompLoc); + return QualType(); +} + } + // The component accessor looks fine - now we need to compute the actual type. // The vector type is implied by the component accessor. For example, // vec4.b is a float, vec4.xy is a vec2, vec4.rgb is a vec3, etc. Index: include/clang/Basic/DiagnosticSemaKinds.td
[PATCH] D30920: Do not pass -Os and -Oz to the Gold plugin
tejohnson added a comment. In https://reviews.llvm.org/D30920#700133, @pcc wrote: > In https://reviews.llvm.org/D30920#700077, @tejohnson wrote: > > > Until everything is converted to using size attributes, it seems like a > > correct fix for the bug is to accept these options in the gold-plugin and > > pass through the LTO API to the PassManagerBuilder. > > > Not necessarily. There is no requirement (from a correctness perspective) > that `-Os` at link time should exactly match the behaviour of `-Os` at > compile time. Sure, but there is certainly a perception that optimization flags affecting the non-LTO pipeline should similarly affect the LTO pipeline. LTO should be transparent to the user, so if -Os behaves one way without LTO, it seems problematic to me if it behaves a different way with LTO. That being said, agree that the best way to enforce that is to pass the relevant flags through the IR. (On the flip side, if the user passes -O1 to the link step, it does get passed through to the plugin and affects the LTO optimization pipeline...) Pirama - can you file a bug (and cc me on it) for the need to convert existing users of the sizeLevel flag to instead use the relevant function attributes? Comment at: lib/Driver/ToolChains/CommonArgs.cpp:376 + if (OptLevel != "s" && OptLevel != "z") +OOpt = OptLevel; +} else if (A->getOption().matches(options::OPT_O0)) Note that -Os and -Oz are supposed to map to -O2 minus some size increasing options. Not setting OOpt in that case works because the OptLevel in the gold-plugin defaults to -O2. I'd rather make it explicit here, i.e. add an else that sets OOpt to "2" under these options. You can add a check for that in your tests. https://reviews.llvm.org/D30920 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30582: [Driver] Restructure handling of -ffast-math and similar options
rengolin added inline comments. Comment at: lib/Driver/ToolChains/Clang.cpp:2320 + + for (Arg *A : Args) + { format Comment at: lib/Driver/ToolChains/Clang.cpp:2324 +{ +// Options controlling individual features +case options::OPT_fhonor_infinities:HonorInfs = true;break; default should be the first item, for readability. Comment at: lib/Driver/ToolChains/Clang.cpp:2382 + if (!OFastEnabled) +continue; +case options::OPT_ffast_math: Use `LLVM_FALLTHROUGH` Comment at: lib/Driver/ToolChains/Clang.cpp:2452 + if (!HonorInfs && !HonorNans && !MathErrno && AssociativeMath && + ReciprocalMath && !SignedZeros && !TrappingMath && FpContract == "fast") +CmdArgs.push_back("-ffast-math"); This is technically correct, but users will be confused if they choose `-ffast-math -ffp-contract=on` and not see `-ffast-math` coming out on the other side. Also, `fp-contract=on` doesn't preclude `-ffast-math` for the languages that support it, so I wouldn't add `FpContract` to this list at all. Repository: rL LLVM https://reviews.llvm.org/D30582 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30675: [clangd] Fix not being able to attach a debugger on macOS
malaperle-ericsson added a comment. Ping :) https://reviews.llvm.org/D30675 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30643: [OpenCL] Extended diagnostics for atomic initialization
bader added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8263 +def err_atomic_init_addressspace : Error< + "initialization of atomic variables is restricted to variables in global address space">; def err_atomic_init_constant : Error< Anastasia wrote: > bader wrote: > > bader wrote: > > > Anastasia wrote: > > > > echuraev wrote: > > > > > Anastasia wrote: > > > > > > Could we combine this error diag with the one below? I guess they > > > > > > are semantically very similar apart from one is about > > > > > > initialization and another is about assignment? > > > > > I'm not sure that it is a good idea to combine these errors. For > > > > > example, if developer had declared a variable non-constant and not in > > > > > global address space he would have got the same message for both > > > > > errors. And it can be difficult to determine what the exact problem > > > > > is. He can fix one of the problems but he will still get the same > > > > > error. > > > > Well, I don't actually see that we check for constant anywhere so it's > > > > also OK if you want to drop this bit. Although I think the original > > > > intension of this message as I understood was to provide the most > > > > complete hint. > > > > > > > > My concern is that these two errors seem to be reporting nearly the > > > > same issue and ideally we would like to keep diagnostic list as small > > > > as possible. This also makes the file more concise and messages more > > > > consistent. > > > I suggest adding a test case with non-constant initialization case to > > > validate that existing checks cover this case for atomic types already. > > > If so, we can adjust existing diagnostic message to cover both cases: > > > initialization and assignment expression. > > I don't think it's quite true. > > There are two requirements here that must be met the same time. Atomic > > variables *declared in the global address space* can be initialized only > > with "compile time constant'. > > If understand the spec correctly this code is also valid: > > > > kernel void foo() { > > static global atomic_int a = 42; // although it's not clear if we must > > use ATOMIC_VAR_INIT here. > > ... > > } > Precisely, but I think checking for compile time constant should be inherited > from the general C implementation? I don't think we do anything extra for it. > Regarding the macro I am not sure we can suitably diagnose it anyways... > Precisely, but I think checking for compile time constant should be inherited > from the general C implementation? Agree. I suggested checking this above by extending OpenCL tests, but this can be done separately. https://reviews.llvm.org/D30643 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30837: [libcxx] Support for shared_ptr<T()>
erik.pilkington added a comment. In https://reviews.llvm.org/D30837#698305, @EricWF wrote: > We can't just use an arbitrary allocator type for a number of reasons: > > - You just changed the type of the control block. That's ABI breaking. Ah, I didn't think of that. This new patch only selects `allocator` when _Yp is a function type, which is only permitted as of this patch. > - `allocator` allocates ints, nothing else. Since we only use `allocator` for a rebind, we don't violate this rule. > - It may mean we don't select a valid user specialization of `allocator`. In the new patch, `allocator` is only selected if `is_function<_Yp>`, I don't believe that there is any valid user specialization of `std::allocator`. This is because [namespace.std] p1: > A program may add a template specialization for any standard library template > to namespace std only if [...] the specialization meets the standard library > requirements for the original template [...] In this case, the original template is the default allocator, which is supposed to have overloads of `address` taking a `const_reference` and a `reference` ([allocator.members] p2-3), which will be ambiguous for function types with the given definitions of `const_reference` and `reference`. Is this a valid argument? https://reviews.llvm.org/D30837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D30837: [libcxx] Support for shared_ptr<T()>
erik.pilkington updated this revision to Diff 91660. erik.pilkington added a comment. In this new patch: - We only select `allocator` when _Yp is a function type, fixing the ABI break @EricWF pointed out. - Only try to select a different allocator if we're using the `__shared_ptr_pointer` layout; `make_shared` doesn't make sense. - Improve the testcase Thanks for the feedback! Erik https://reviews.llvm.org/D30837 Files: include/memory test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp === --- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp +++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp @@ -45,6 +45,13 @@ virtual ~Foo() = default; }; +struct Result {}; +static Result theFunction() { return Result(); } +static int resultDeletorCount; +static void resultDeletor(Result (*pf)()) { + assert(pf == theFunction); + ++resultDeletorCount; +} int main() { @@ -65,7 +72,11 @@ std::shared_ptr p2 = std::make_shared(); assert(p2.get()); } - +{ // https://bugs.llvm.org/show_bug.cgi?id=27566 + std::shared_ptr x(, ); + std::shared_ptr y(theFunction, resultDeletor); +} +assert(resultDeletorCount == 2); #if TEST_STD_VER >= 11 nc = globalMemCounter.outstanding_new; { Index: include/memory === --- include/memory +++ include/memory @@ -3884,13 +3884,25 @@ } } -_LIBCPP_INLINE_VISIBILITY -void __enable_weak_this(const volatile void*, const volatile void*) _NOEXCEPT {} +_LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {} template friend class _LIBCPP_TEMPLATE_VIS shared_ptr; template friend class _LIBCPP_TEMPLATE_VIS weak_ptr; }; +template ::value> +struct __shared_ptr_default_allocator; + +template struct __shared_ptr_default_allocator<_Tp, false> +{ +typedef allocator<_Tp> type; +}; + +template struct __shared_ptr_default_allocator<_Tp, true> +{ +typedef allocator type; +}; + template inline _LIBCPP_CONSTEXPR @@ -3916,8 +3928,9 @@ : __ptr_(__p) { unique_ptr<_Yp> __hold(__p); -typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>()); +typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, _AllocT > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), _AllocT()); __hold.release(); __enable_weak_this(__p, __p); } @@ -3932,8 +3945,9 @@ try { #endif // _LIBCPP_NO_EXCEPTIONS -typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>()); +typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; +typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); __enable_weak_this(__p, __p); #ifndef _LIBCPP_NO_EXCEPTIONS } @@ -3954,8 +3968,9 @@ try { #endif // _LIBCPP_NO_EXCEPTIONS -typedef __shared_ptr_pointer > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>()); +typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; +typedef __shared_ptr_pointer _CntrlBlk; +__cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -4094,8 +4109,9 @@ typename enable_if ::value, __nat>::type) : __ptr_(__r.get()) { -typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); +typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; +typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, _AllocT > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), _AllocT()); __enable_weak_this(__r.get(), __r.get()); __r.release(); } @@ -4123,8 +4139,9 @@ else #endif { -typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk; -__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>()); +typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; +typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk; +__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), _AllocT());