[llvm-commits] CVS: llvm/lib/VMCore/Function.cpp

Chris Lattner sabre at nondot.org
Tue Sep 9 12:03:02 PDT 2003


> Reverting back to the previous revision.
> We want to check for length 5 because we might get the "llvm." string as the
> name.  That string is in the LLVM namespace and should be checked as such.
> We also don't have to worry about garbage data because (I believe) the string
> class will return a valid value.  So, the switch statement will work and we
> don't have to worry about the code wandering into segfault land.

I don't understand why we could ever get a segfault here.  We only access
portions of the string if we know it to be LONGER than 5 characters.  In
fact, the check should be size() < 5, to consider the "llvm." function as
part of the name space.

Am I missing something here?

-Chris

> Diffs of the changes:
>
> Index: llvm/lib/VMCore/Function.cpp
> diff -u llvm/lib/VMCore/Function.cpp:1.48 llvm/lib/VMCore/Function.cpp:1.49
> --- llvm/lib/VMCore/Function.cpp:1.48	Tue Sep  9 11:36:09 2003
> +++ llvm/lib/VMCore/Function.cpp	Tue Sep  9 11:58:41 2003
> @@ -159,7 +159,7 @@
>  /// llvm/Intrinsics.h.
>  ///
>  unsigned Function::getIntrinsicID() const {
> -  if (getName().size() <= 6 || getName()[4] != '.' || getName()[0] != 'l' ||
> +  if (getName().size() <= 5 || getName()[4] != '.' || getName()[0] != 'l' ||
>        getName()[1] != 'l' || getName()[2] != 'v' || getName()[3] != 'm')
>      return 0;  // All intrinsics start with 'llvm.'
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvm-commits
>

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-commits mailing list